I'm probably missing something stupid or obvious. With that said, I've created an item with different names and icons for different damage values. I have 3 sub-items with damage values 0, 1, and 2. I am changing the itemstack damage value in the onItemRightClick callback.
This looks to work for damage values of 0 or 1, but when I set the damage value to 2, it resets to 0 an instant later. The icon briefly changes to the damage value 2 icon, and then swaps back to the one for damage 0.
The item source is here in full https://github.com/jco2641/SuperOreProcessCraft/blob/master/src/main/java/jco/mods/sopc/item/ItemuniversalMultitool.java
Here is the function:
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
if(world.isRemote) {
if (player.isSneaking()) {
LogHelper.info("Entering routine, damage = " + this.getDamage(itemStack));
switch (this.getDamage(itemStack)) {
case 0:
this.setDamage(itemStack, 1);
LogHelper.info("Setting damage from 0 to 1");
break;
case 1:
this.setDamage(itemStack, 2);
LogHelper.info("Setting damage from 1 to 2");
break;
case 2:
this.setDamage(itemStack, 0);
LogHelper.info("Setting damage from 2 to 0");
break;
}
}
}
return super.onItemRightClick(itemStack, world, player);
}