Jump to content

Recommended Posts

Posted

Hi I am making a mod and i am getting a ArrayOutOfBounds error i know it means that its looking for something out of my bounds but i cant find it pls help thx

 

  Reveal hidden contents

 

 

 

  Reveal hidden contents

 

Posted

Well arrays start at the 'key' value of zero. so you have an array[x, y] which is accessed by either array[0] for x or array[1] for y... So your index is out of bounds since calling for the array[2] is looking for the third value in a two value array

 

 

Look here in your code:

    public ItemStack getStackInSlot(int i) {
        if(i < 3) {
            return this.slots[2];
        }
        return this.slots;
    }

slots[2] is actually the third value in a two value array, hence the index error

  Quote
I think its my java of the variables.

Posted

Here is my container code

 

  Reveal hidden contents

 

Posted

The container code is not necessary. RANKSHANK is correct: your getStackInSlot() method is trying to return this.slots[2], which is the third element in the slots array, but you've initialized slots to only have 2 elements. Hence your index of 2 is out of bounds.

Whatever Minecraft needs, it is most likely not yet another tool tier.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.