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

@ -36,7 +36,16 @@ public class ItemIronChest extends ItemBlock
@Override
public String getUnlocalizedName(ItemStack itemstack)
{
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

@ -41,7 +41,16 @@ public class ItemIronShulkerBox extends ItemBlock
@Override
public String getUnlocalizedName(ItemStack itemstack)
{
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);
}
}
}