Fix #1749 - Mana Tablets no longer lose durability in storage drawer

This commit is contained in:
Michael Brenan committed 2016-01-15 03:26:31 -06:00
1 parent b7c0c12e5b
commit 54f1dd0478
1 file changed
+25 -9
@@ -49,13 +49,16 @@ public class ItemManaTablet extends ItemMod implements IManaItem, ICreativeManaP
@Override
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
par3List.add(new ItemStack(par1, 1, 10000));
// Empty tablet
par3List.add(new ItemStack(par1, 1));
ItemStack fullPower = new ItemStack(par1, 1, 1);
// Full tablet
ItemStack fullPower = new ItemStack(par1, 1);
setMana(fullPower, MAX_MANA);
par3List.add(fullPower);
ItemStack creative = new ItemStack(par1, 1, 0);
// Creative Tablet
ItemStack creative = new ItemStack(par1, 1);
setMana(creative, MAX_MANA);
setStackCreative(creative);
par3List.add(creative);
@@ -69,13 +72,12 @@ public class ItemManaTablet extends ItemMod implements IManaItem, ICreativeManaP
@Override
public int getDamage(ItemStack stack) {
float mana = getMana(stack);
return 1000 - (int) (mana / MAX_MANA * 1000);
}
// Compatibility shim, so tablets from previous versions of botania
// stack right in barrels and so forth
if(super.getDamage(stack) != 0)
super.setDamage(stack, 0);
@Override
public int getDisplayDamage(ItemStack stack) {
return getDamage(stack);
return 0;
}
@Override
@@ -168,4 +170,18 @@ public class ItemManaTablet extends ItemMod implements IManaItem, ICreativeManaP
public float getManaFractionForDisplay(ItemStack stack) {
return (float) getMana(stack) / (float) getMaxMana(stack);
}
@Override
public boolean showDurabilityBar(ItemStack stack) {
// If the stack is not creative, show the durability bar.
return !isStackCreative(stack);
}
@Override
public double getDurabilityForDisplay(ItemStack stack) {
// I believe Forge has their durability values swapped, hence the (1.0 -).
// This will probably be fixed soon.
return 1.0 - getManaFractionForDisplay(stack);
}
}