mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-10-31 17:23:42 +01:00 
			
		
		
		
	Fix for impact armor damage formula (#4425)
* Update SkillUtils.java Add handleArmorDurabilityChange() to handle armor damage reduction correctly * Update AxesManager.java Changed method to handle impact damage calculation * Update SkillUtils.java
This commit is contained in:
		| @@ -120,7 +120,7 @@ public class AxesManager extends SkillManager { | |||||||
|         for (ItemStack armor : target.getEquipment().getArmorContents()) { |         for (ItemStack armor : target.getEquipment().getArmorContents()) { | ||||||
|             if (armor != null && ItemUtils.isArmor(armor)) { |             if (armor != null && ItemUtils.isArmor(armor)) { | ||||||
|                 if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_STATIC_CHANCE, SubSkillType.AXES_ARMOR_IMPACT, getPlayer())) { |                 if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_STATIC_CHANCE, SubSkillType.AXES_ARMOR_IMPACT, getPlayer())) { | ||||||
|                     SkillUtils.handleDurabilityChange(armor, durabilityDamage, 1); |                     SkillUtils.handleArmorDurabilityChange(armor, durabilityDamage, 1); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -236,14 +236,14 @@ public final class SkillUtils { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Modify the durability of an ItemStack. |      * Modify the durability of an ItemStack, using Tools specific formula for unbreaking enchant damage reduction | ||||||
|      * |      * | ||||||
|      * @param itemStack The ItemStack which durability should be modified |      * @param itemStack The ItemStack which durability should be modified | ||||||
|      * @param durabilityModifier the amount to modify the durability by |      * @param durabilityModifier the amount to modify the durability by | ||||||
|      * @param maxDamageModifier the amount to adjust the max damage by |      * @param maxDamageModifier the amount to adjust the max damage by | ||||||
|      */ |      */ | ||||||
|     public static void handleDurabilityChange(ItemStack itemStack, double durabilityModifier, double maxDamageModifier) { |     public static void handleDurabilityChange(ItemStack itemStack, double durabilityModifier, double maxDamageModifier) { | ||||||
|         if(itemStack.getItemMeta() != null && itemStack.getItemMeta().isUnbreakable()) { |         if(itemStack.hasItemMeta() && itemStack.getItemMeta().isUnbreakable()) { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -263,6 +263,26 @@ public final class SkillUtils { | |||||||
|  |  | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
|  |      | ||||||
|  |      | ||||||
|  |     /** | ||||||
|  |      * Modify the durability of an ItemStack, using Armor specific formula for unbreaking enchant damage reduction | ||||||
|  |      * | ||||||
|  |      * @param itemStack The ItemStack which durability should be modified | ||||||
|  |      * @param durabilityModifier the amount to modify the durability by | ||||||
|  |      * @param maxDamageModifier the amount to adjust the max damage by | ||||||
|  |      */ | ||||||
|  |     public static void handleArmorDurabilityChange(ItemStack itemStack, double durabilityModifier, double maxDamageModifier) { | ||||||
|  |         if(itemStack.hasItemMeta() && itemStack.getItemMeta().isUnbreakable()) { | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         Material type = itemStack.getType(); | ||||||
|  |         short maxDurability = mcMMO.getRepairableManager().isRepairable(type) ? mcMMO.getRepairableManager().getRepairable(type).getMaximumDurability() : type.getMaxDurability(); | ||||||
|  |         durabilityModifier = (int) Math.min(durabilityModifier * (0.6 + 0.4/ (itemStack.getEnchantmentLevel(Enchantment.DURABILITY) + 1)), maxDurability * maxDamageModifier); | ||||||
|  |  | ||||||
|  |         itemStack.setDurability((short) Math.min(itemStack.getDurability() + durabilityModifier, maxDurability)); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     @Nullable |     @Nullable | ||||||
|     public static Material getRepairAndSalvageItem(@NotNull ItemStack inHand) { |     public static Material getRepairAndSalvageItem(@NotNull ItemStack inHand) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 emanondev
					emanondev