Browse Source

Readded Impact damage durability cap (and fixed it)

bm01 12 years ago
parent
commit
776821a988
2 changed files with 13 additions and 2 deletions
  1. 2 1
      Changelog.txt
  2. 11 1
      src/main/java/com/gmail/nossr50/skills/axes/ImpactEventHandler.java

+ 2 - 1
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

+ 11 - 1
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() {