BuildCraft|Factory

BuildCraft|Factory

7M Downloads

Crash on startup

Adrigamer2950 opened this issue ยท 2 comments

commented

When I open Minecraft with buildcraft and my custom mod minecraft crashes throwing this crash:

This is the crash report:
https://gist.github.com/Adrigamer2950/bb42410fe75761c738ee335e15d2c968

And this is the method in my code that throws the error:
https://gist.github.com/Adrigamer2950/369840147362730eba4308dbb904d17c

commented

It worked!! Thx ๐Ÿ˜

commented

Minecraft uses the special metadata value 32767 (Short.MAX_VALUE) to mean "any metadata". This means you can't trust ItemStack.getItemDamage() to be in the range you want it to be, and instead you'll need to check it (or clamp it) before using it as an array index.

One fix might be:

// In EnumHandler.OreType
public static EnumHandler.OreType get(int index)
{
    if (index < 0 || index >= values().length)
    {
        index = 0;
    }
    return values()[index];
}

// In adrigamer2950.randomthings.bases.blocks.BlockOres
@Override
public String getSpecialName(ItemStack stack)
{
    return EnumHandler.OreType.get(stack.getItemDamage()).getName();
}