From 776821a9889155eac76ecda3c2d2bf0357d93abe Mon Sep 17 00:00:00 2001 From: bm01 Date: Wed, 13 Feb 2013 14:49:35 +0100 Subject: [PATCH] Readded Impact damage durability cap (and fixed it) --- Changelog.txt | 3 ++- .../nossr50/skills/axes/ImpactEventHandler.java | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index cbf68eae7..7c56a7603 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -32,7 +32,8 @@ Version 1.4.00-dev + Added "Chinese (Taiwan)" localization files (zh_TW) + Added '/hardcore' and '/vampirism' commands for toggling these modes on or off. = Fixed /ptp telporting the target to the player, rather than the other way around. - = Fixed Impact reducing durability of non-armor equipped blocks + = Fixed Impact reducing the durability of non-armor equipped blocks + = Fixed Impact reducing improperly the durability of armors (as a consequence it is now more effective) = Fixed multiple commands not working properly on offline players = Fixed /mmoedit not giving feedback when modifying another players stats = Fixed the guide usage string showing up every time /skillname was called diff --git a/src/main/java/com/gmail/nossr50/skills/axes/ImpactEventHandler.java b/src/main/java/com/gmail/nossr50/skills/axes/ImpactEventHandler.java index be04c0d49..946d7ea00 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/ImpactEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/ImpactEventHandler.java @@ -8,6 +8,7 @@ import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mods.ModChecks; import com.gmail.nossr50.util.ItemChecks; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -49,13 +50,22 @@ public class ImpactEventHandler { } private void damageArmor(ItemStack armor) { + // Modifier simulate the durability enchantment behavior float modifier = 1; if (armor.containsEnchantment(Enchantment.DURABILITY)) { modifier /= armor.getEnchantmentLevel(Enchantment.DURABILITY) + 1; } - armor.setDurability((short) (durabilityDamage * modifier + armor.getDurability())); + float modifiedDurabilityDamage = durabilityDamage * modifier; + short maxDurabilityDamage = ModChecks.isCustomArmor(armor) ? ModChecks.getArmorFromItemStack(armor).getDurability() : armor.getType().getMaxDurability(); + maxDurabilityDamage *= Axes.impactMaxDurabilityDamageModifier; + + if (modifiedDurabilityDamage > maxDurabilityDamage) { + modifiedDurabilityDamage = maxDurabilityDamage; + } + + armor.setDurability((short) (modifiedDurabilityDamage + armor.getDurability())); } protected void applyGreaterImpact() {