diff --git a/forge/forge_common/net/minecraft/src/forge/ArmorProperties.java b/forge/forge_common/net/minecraft/src/forge/ArmorProperties.java index 7078178537..72a253e20b 100755 --- a/forge/forge_common/net/minecraft/src/forge/ArmorProperties.java +++ b/forge/forge_common/net/minecraft/src/forge/ArmorProperties.java @@ -41,11 +41,12 @@ public class ArmorProperties implements Comparable */ public static int ApplyArmor(EntityLiving entity, ItemStack[] inventory, DamageSource source, double damage) { - ArrayList dmgVals = new ArrayList(); if (DEBUG) { - System.out.println("Start: " + damage); + System.out.println("Start: " + damage + " " + (damage * 25)); } + damage *= 25; + ArrayList dmgVals = new ArrayList(); for (int x = 0; x < inventory.length; x++) { ItemStack stack = inventory[x]; @@ -57,13 +58,12 @@ public class ArmorProperties implements Comparable if (stack.getItem() instanceof ISpecialArmor) { ISpecialArmor armor = (ISpecialArmor)stack.getItem(); - prop = armor.getProperties(entity, stack, source, damage, x); + prop = armor.getProperties(entity, stack, source, damage / 25D, x).copy(); } else if (stack.getItem() instanceof ItemArmor && !source.isUnblockable()) { ItemArmor armor = (ItemArmor)stack.getItem(); - prop = new ArmorProperties(0, armor.damageReduceAmount / 25D, - armor.getMaxDamage() - stack.getItemDamage()); + prop = new ArmorProperties(0, armor.damageReduceAmount / 25D, armor.getMaxDamage() + 1 - stack.getItemDamage()); } if (prop != null) { @@ -74,10 +74,9 @@ public class ArmorProperties implements Comparable if (dmgVals.size() > 0) { ArmorProperties[] props = dmgVals.toArray(new ArmorProperties[0]); - StanderdizeList(props, damage); + StandardizeList(props, damage); int level = props[0].Priority; double ratio = 0; - double totalAbsorbed = 0; for (ArmorProperties prop : props) { if (level != prop.Priority) @@ -92,17 +91,18 @@ public class ArmorProperties implements Comparable if (absorb > 0) { ItemStack stack = inventory[prop.Slot]; + int itemDamage = (int)(absorb / 25D < 1 ? 1 : absorb / 25D); if (stack.getItem() instanceof ISpecialArmor) { - ((ISpecialArmor)stack.getItem()).damageArmor(entity, stack, source, (int)(absorb < 1 ? 1 : (int)absorb), prop.Slot); + ((ISpecialArmor)stack.getItem()).damageArmor(entity, stack, source, itemDamage, prop.Slot); } else { if (DEBUG) { - System.out.println("Item: " + stack.toString() + " Absorbed: " + absorb + " Damaged: " + (int)(absorb < 1 ? 1 : (int)absorb)); + System.out.println("Item: " + stack.toString() + " Absorbed: " + (absorb / 25D) + " Damaged: " + itemDamage); } - stack.damageItem((int)(absorb < 1 ? 1 : (int)absorb), entity); + stack.damageItem(itemDamage, entity); } if (stack.stackSize <= 0) { @@ -116,11 +116,13 @@ public class ArmorProperties implements Comparable } damage -= (damage * ratio); } + damage += entity.carryoverDamage; if (DEBUG) { - System.out.println("Return: " + (int)damage + " " + damage); + System.out.println("Return: " + (int)(damage / 25D) + " " + damage); } - return (int)damage; + entity.carryoverDamage = (int)damage % 25; + return (int)(damage / 25D); } /** @@ -129,7 +131,7 @@ public class ArmorProperties implements Comparable * @param armor The armor information * @param damage The total damage being received */ - private static void StanderdizeList(ArmorProperties[] armor, double damage) + private static void StandardizeList(ArmorProperties[] armor, double damage) { Arrays.sort(armor); @@ -253,4 +255,9 @@ public class ArmorProperties implements Comparable { return String.format("%d, %d, %f, %d", Priority, AbsorbMax, AbsorbRatio, (AbsorbRatio == 0 ? 0 : (int)(AbsorbMax * 100.0D / AbsorbRatio))); } + + public ArmorProperties copy() + { + return new ArmorProperties(Priority, AbsorbRatio, AbsorbMax); + } } diff --git a/forge/forge_common/net/minecraft/src/forge/ISpecialArmor.java b/forge/forge_common/net/minecraft/src/forge/ISpecialArmor.java index 8348e62775..62f9cccfc1 100755 --- a/forge/forge_common/net/minecraft/src/forge/ISpecialArmor.java +++ b/forge/forge_common/net/minecraft/src/forge/ISpecialArmor.java @@ -22,8 +22,6 @@ public interface ISpecialArmor { /** * Retrieves the modifiers to be used when calculating armor damage. - * Mods should return a new instance every time as the return values - * will be manipulated by the damage function. * * Armor will higher priority will have damage applied to them before * lower priority ones. If there are multiple pieces of armor with the @@ -36,7 +34,7 @@ public interface ISpecialArmor * properties based on the type or source of damage. * @param damage The total damage being applied to the entity * @param slot The armor slot the item is in. - * + * @return A ArmorProperties instance holding information about how the armor effects damage. */ public ArmorProperties getProperties(EntityLiving player, ItemStack armor, DamageSource source, double damage, int slot); diff --git a/forge/patches/minecraft/net/minecraft/src/EntityLiving.java.patch b/forge/patches/minecraft/net/minecraft/src/EntityLiving.java.patch index 03483fa1f8..7c8bea6c49 100644 --- a/forge/patches/minecraft/net/minecraft/src/EntityLiving.java.patch +++ b/forge/patches/minecraft/net/minecraft/src/EntityLiving.java.patch @@ -1,5 +1,14 @@ --- ../src_base/minecraft/net/minecraft/src/EntityLiving.java 0000-00-00 00:00:00.000000000 -0000 +++ ../src_work/minecraft/net/minecraft/src/EntityLiving.java 0000-00-00 00:00:00.000000000 -0000 +@@ -29,7 +29,7 @@ + public float swingProgress; + protected int health; + public int prevHealth; +- protected int carryoverDamage; ++ public int carryoverDamage; + private int livingSoundTime; + public int hurtTime; + public int maxHurtTime; @@ -835,7 +835,13 @@ int i = MathHelper.floor_double(posX); int j = MathHelper.floor_double(boundingBox.minY); diff --git a/forge/patches/minecraft/net/minecraft/src/EntityPlayer.java.patch b/forge/patches/minecraft/net/minecraft/src/EntityPlayer.java.patch index 3417fbe858..8974e31334 100644 --- a/forge/patches/minecraft/net/minecraft/src/EntityPlayer.java.patch +++ b/forge/patches/minecraft/net/minecraft/src/EntityPlayer.java.patch @@ -93,26 +93,20 @@ public boolean canHarvestBlock(Block block) { return inventory.canHarvestBlock(block); -@@ -768,8 +824,16 @@ +@@ -768,7 +824,11 @@ { i = 1 + i >> 1; } - i = applyArmorCalculations(damagesource, i); -- i = applyPotionDamageCalculations(damagesource, i); -+ int damage = ArmorProperties.ApplyArmor(this, inventory.armorInventory, damagesource, (double)i * 25) + carryoverDamage; -+ -+ carryoverDamage = damage % 25; -+ damage /= 25; -+ if (damage <= 0) ++ i = ArmorProperties.ApplyArmor(this, inventory.armorInventory, damagesource, i); ++ if (i <= 0) + { + return; + } -+ -+ i = applyPotionDamageCalculations(damagesource, damage); + i = applyPotionDamageCalculations(damagesource, i); addExhaustion(damagesource.getHungerDamage()); health -= i; - } -@@ -815,7 +879,9 @@ +@@ -815,7 +875,9 @@ public void destroyCurrentEquippedItem() { @@ -122,7 +116,7 @@ } public double getYOffset() -@@ -834,6 +900,11 @@ +@@ -834,6 +896,11 @@ public void attackTargetEntityWithCurrentItem(Entity entity) { @@ -134,7 +128,7 @@ int i = inventory.getDamageVsEntity(entity); if (isPotionActive(Potion.damageBoost)) { -@@ -947,6 +1018,11 @@ +@@ -947,6 +1014,11 @@ public EnumStatus sleepInBedAt(int i, int j, int k) { diff --git a/forge/patches/minecraft_server/net/minecraft/src/EntityLiving.java.patch b/forge/patches/minecraft_server/net/minecraft/src/EntityLiving.java.patch index 5991df578b..ba880b9b39 100644 --- a/forge/patches/minecraft_server/net/minecraft/src/EntityLiving.java.patch +++ b/forge/patches/minecraft_server/net/minecraft/src/EntityLiving.java.patch @@ -1,5 +1,14 @@ --- ../src_base/minecraft_server/net/minecraft/src/EntityLiving.java 0000-00-00 00:00:00.000000000 -0000 +++ ../src_work/minecraft_server/net/minecraft/src/EntityLiving.java 0000-00-00 00:00:00.000000000 -0000 +@@ -29,7 +29,7 @@ + public float swingProgress; + protected int health; + public int prevHealth; +- protected int carryoverDamage; ++ public int carryoverDamage; + private int livingSoundTime; + public int hurtTime; + public int maxHurtTime; @@ -812,7 +812,9 @@ int i = MathHelper.floor_double(posX); int j = MathHelper.floor_double(boundingBox.minY); diff --git a/forge/patches/minecraft_server/net/minecraft/src/EntityPlayer.java.patch b/forge/patches/minecraft_server/net/minecraft/src/EntityPlayer.java.patch index eb797c7205..748565193a 100644 --- a/forge/patches/minecraft_server/net/minecraft/src/EntityPlayer.java.patch +++ b/forge/patches/minecraft_server/net/minecraft/src/EntityPlayer.java.patch @@ -103,26 +103,20 @@ public boolean canHarvestBlock(Block block) { return inventory.canHarvestBlock(block); -@@ -711,8 +770,16 @@ +@@ -711,7 +770,11 @@ { i = 1 + i >> 1; } - i = applyArmorCalculations(damagesource, i); -- i = applyPotionDamageCalculations(damagesource, i); -+ int damage = ArmorProperties.ApplyArmor(this, inventory.armorInventory, damagesource, (double)i * 25) + carryoverDamage; -+ -+ carryoverDamage = damage % 25; -+ damage /= 25; -+ if (damage <= 0) ++ i = ArmorProperties.ApplyArmor(this, inventory.armorInventory, damagesource, i); ++ if (i <= 0) + { + return; + } -+ -+ i = applyPotionDamageCalculations(damagesource, damage); + i = applyPotionDamageCalculations(damagesource, i); addExhaustion(damagesource.getHungerDamage()); health -= i; - } -@@ -758,7 +825,9 @@ +@@ -758,7 +821,9 @@ public void destroyCurrentEquippedItem() { @@ -132,7 +126,7 @@ } public double getYOffset() -@@ -777,6 +846,11 @@ +@@ -777,6 +842,11 @@ public void attackTargetEntityWithCurrentItem(Entity entity) { @@ -144,7 +138,7 @@ int i = inventory.getDamageVsEntity(entity); if (isPotionActive(Potion.damageBoost)) { -@@ -884,6 +958,11 @@ +@@ -884,6 +954,11 @@ public EnumStatus sleepInBedAt(int i, int j, int k) {