Skip to content

Commit

Permalink
Fixed ArrayIndexOutOfBoundsException on DiamondApple getUnlocalizedNa…
Browse files Browse the repository at this point in the history
…me()
  • Loading branch information
CandiceJoy committed Aug 2, 2015
1 parent 95bb455 commit 7ba86b1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/java/tconstruct/armor/items/DiamondApple.java
Expand Up @@ -75,6 +75,18 @@ public void registerIcons (IIconRegister iconRegister)
@Override
public String getUnlocalizedName (ItemStack itemstack)
{
return (new StringBuilder()).append("item.food.").append(itemNames[itemstack.getItemDamage()]).toString();
int damage = itemstack.getItemDamage();
int name_index = 0;

if( damage < 0 )
{
name_index = 0;
}
else if( damage >= itemNames.length )
{
name_index = itemNames.length-1;
}

return (new StringBuilder()).append("item.food.").append(itemNames[name_index]).toString();
}
}

0 comments on commit 7ba86b1

Please sign in to comment.