Check for valid metadata before looking up name. Closes #135

This commit is contained in:
alexbegt 2018-10-04 23:08:41 -04:00
parent 443fe18f93
commit c9c1c30d3b
2 changed files with 20 additions and 2 deletions

View File

@ -37,6 +37,15 @@ public class ItemIronChest extends ItemBlock
@Override
public String getUnlocalizedName(ItemStack itemstack)
{
return "tile.ironchest.chest." + IronChestType.VALUES[itemstack.getMetadata()].name().toLowerCase(Locale.US);
int meta = itemstack.getMetadata();
if (meta < IronChestType.VALUES.length)
{
return "tile.ironchest.chest." + IronChestType.VALUES[itemstack.getMetadata()].name().toLowerCase(Locale.US);
}
else
{
return super.getUnlocalizedName(itemstack);
}
}
}

View File

@ -42,6 +42,15 @@ public class ItemIronShulkerBox extends ItemBlock
@Override
public String getUnlocalizedName(ItemStack itemstack)
{
return "tile.ironchest.shulker_box." + IronShulkerBoxType.VALUES[itemstack.getMetadata()].name().toLowerCase(Locale.US) + "." + this.colorName;
int meta = itemstack.getMetadata();
if (meta < IronShulkerBoxType.VALUES.length)
{
return "tile.ironchest.shulker_box." + IronShulkerBoxType.VALUES[itemstack.getMetadata()].name().toLowerCase(Locale.US) + "." + this.colorName;
}
else
{
return super.getUnlocalizedName(itemstack);
}
}
}