Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6893479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:39:50+00:00 2026-05-27T06:39:50+00:00

I am working on a minecraft mod. The id system for EntityC4 is not

  • 0

I am working on a minecraft mod. The id system for EntityC4 is not working. The code is

public static List C4 = new ArrayList();  

public static EntityC4 getitemfromnumber(int num)
{
    EntityC4 entity = (EntityC4)C4.get(num);

    return entity;
}
public static void createdetonater(EntityC4 c4, int num)
{
    C4.add(num, c4);


}
public static int getnum(){
     int num = 0;
      for(boolean a = true; a != false;){
          EntityC4 c = (EntityC4)C4.get(num);
          System.out.print("current num : " + num);

            if(c != null)
            {
                a = false;
            }else{
                System.out.print("entity " + num + " is null" );
         num++;
            }
      }
      return num;
   }

And when I use getnum() an error shows up that says

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.RangeCheck(Unknown Source)
    at java.util.ArrayList.get(Unknown Source)

EDIT:Ty and the loop was supposed the first non-existent space in the list.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:39:51+00:00Added an answer on May 27, 2026 at 6:39 am

    You create a new ArrayList C4, you never put anything in the List, and then you ask it for the element at index 0. This element does not exists since the List is still empty, and it throws an exception.

    You can avoid this exception by adjusting your method

    public static EntityC4 getitemfromnumber(int num)
    {
      EntityC4 entity = null;
      if ( num >=0 && num < C4.size ){
        entity = (EntityC4)C4.get(num);
      }
      return entity;
    }
    

    This will avoid the exception, but you will get stuck in your loop since you never find the element (which isn’t available in the list)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a fix for a mod for the game minecraft. but
I'm working on Minecraft Mod Installer and thinking about moving the engine from C#
Working on an extension that use the new experimental devtools apis. How do you
I'm working on a Minecraft-like engine as a hobby project to see how far
I'm working on a Minecraft-style game, and I need a way to reduce the
I'm working with the Minecraft Server To Client protocol documentation for a server I
I am working on a building game (in the same vein as MineCraft, Roboblox
I am currently working on a program, that can handle Minecraft servers. I am
Working in C#, I need to find all local peaks in a List of
working on an old translation sample code for windows phone 7. Recently, I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.