Readded Impact damage durability cap (and fixed it)

This commit is contained in:
bm01 2013-02-13 14:49:35 +01:00
parent 1380e64c0b
commit 776821a988
2 changed files with 13 additions and 2 deletions

View File

@ -32,7 +32,8 @@ Version 1.4.00-dev
+ Added "Chinese (Taiwan)" localization files (zh_TW) + Added "Chinese (Taiwan)" localization files (zh_TW)
+ Added '/hardcore' and '/vampirism' commands for toggling these modes on or off. + 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 /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 multiple commands not working properly on offline players
= Fixed /mmoedit not giving feedback when modifying another players stats = Fixed /mmoedit not giving feedback when modifying another players stats
= Fixed the guide usage string showing up every time /skillname was called = Fixed the guide usage string showing up every time /skillname was called

View File

@ -8,6 +8,7 @@ import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mods.ModChecks;
import com.gmail.nossr50.util.ItemChecks; import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
@ -49,13 +50,22 @@ public class ImpactEventHandler {
} }
private void damageArmor(ItemStack armor) { private void damageArmor(ItemStack armor) {
// Modifier simulate the durability enchantment behavior
float modifier = 1; float modifier = 1;
if (armor.containsEnchantment(Enchantment.DURABILITY)) { if (armor.containsEnchantment(Enchantment.DURABILITY)) {
modifier /= armor.getEnchantmentLevel(Enchantment.DURABILITY) + 1; 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() { protected void applyGreaterImpact() {