diff options
author | draknyte1 <draknyte1@hotmail.com> | 2017-03-25 11:00:34 +1000 |
---|---|---|
committer | draknyte1 <draknyte1@hotmail.com> | 2017-03-25 11:00:34 +1000 |
commit | 03eeaa665109cb6bcdcf115d8c167727556fda6b (patch) | |
tree | ec7d4495d7e099f4fc6bcf40e8fc7c9dc6d94403 /src/Java/gtPlusPlus/core | |
parent | a1021ae7e3f2357a541aaef8d8bde72044478bcd (diff) | |
download | GT5-Unofficial-03eeaa665109cb6bcdcf115d8c167727556fda6b.tar.gz GT5-Unofficial-03eeaa665109cb6bcdcf115d8c167727556fda6b.tar.bz2 GT5-Unofficial-03eeaa665109cb6bcdcf115d8c167727556fda6b.zip |
$ Fixed the durability of Multi-pickaxes overflowing the Integer maxDamage.
Diffstat (limited to 'src/Java/gtPlusPlus/core')
-rw-r--r-- | src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java index da152bb8d8..871c286bc7 100644 --- a/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java @@ -31,20 +31,27 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ return 0; } + protected boolean canBreak = true; protected final int colour; protected final String materialName; protected final String displayName; public boolean isValid = true; private final Pair<?, ?> enchantment; - public MultiPickaxeBase(final String unlocalizedName, final ToolMaterial material, final int materialDurability, final int colour, final Object enchant) { + public MultiPickaxeBase(final String unlocalizedName, final ToolMaterial material, final long materialDurability, final int colour, final Object enchant) { super(Utils.sanitizeString(unlocalizedName), material); this.setUnlocalizedName(Utils.sanitizeString(unlocalizedName)); //this.setTextureName(CORE.MODID + ":" + "itemPickaxe"); this.setTextureName("minecraft"+":"+"iron_pickaxe"); this.FACING_HORIZONTAL=true; this.setMaxStackSize(1); - this.setMaxDamage(materialDurability*3); + if ((materialDurability*3) <= Integer.MAX_VALUE){ + this.setMaxDamage((int) (materialDurability*3)); + } + else { + this.setMaxDamage(Integer.MAX_VALUE); + this.canBreak = false; + } this.colour = colour; this.materialName = material.name(); this.displayName = unlocalizedName; @@ -132,25 +139,6 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ @Override public String getItemStackDisplayName(final ItemStack iStack) { return this.displayName; - /*String name; - if (getUnlocalizedName().toLowerCase().contains("wood")){ - name = "Wooden"; - } - else if (getUnlocalizedName().toLowerCase().contains("cobblestone")){ - name = "Cobblestone"; - } - else if (getUnlocalizedName().toLowerCase().contains("iron")){ - name = "Iron"; - } - else if (getUnlocalizedName().toLowerCase().contains("gold")){ - name = "Gold"; - } - else if (getUnlocalizedName().toLowerCase().contains("diamond")){ - name = "Diamond"; - } - else { - } - return name+" Multipickaxe";*/ } @Override @@ -230,12 +218,16 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ @Override public void damageItem(final ItemStack item, final int damage, final EntityPlayer localPlayer){ - item.damageItem(damage, localPlayer); + if (this.canBreak){ + item.damageItem(damage, localPlayer); + } } @Override public void setItemDamage(final ItemStack item, final int damage){ - item.setItemDamage(damage-1); + if (this.canBreak){ + item.setItemDamage(damage-1); + } } @@ -295,5 +287,21 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ } } + + + /** + * + * Time to Override Minecraft stupid mechanics, allowing unbreakable stuff. + * + */ + public boolean isDamageable(){ + if (this.getMaxDamage() > 0 && !this.hasSubtypes){ + if (this.canBreak){ + return true; + } + } + return false; + } + } |