diff options
author | md_5 <git@md-5.net> | 2016-03-20 10:54:23 +1100 |
---|---|---|
committer | md_5 <git@md-5.net> | 2016-03-20 10:56:05 +1100 |
commit | a8eec15e533e4f15f557844bca87f795f2261a81 (patch) | |
tree | f910ac6d1dfb2b905bddc6f335a034fe00f55ac1 | |
parent | 105df861edd5af531681378274419bca42cdbe05 (diff) | |
download | craftbukkit-a8eec15e533e4f15f557844bca87f795f2261a81.tar craftbukkit-a8eec15e533e4f15f557844bca87f795f2261a81.tar.gz craftbukkit-a8eec15e533e4f15f557844bca87f795f2261a81.tar.lz craftbukkit-a8eec15e533e4f15f557844bca87f795f2261a81.tar.xz craftbukkit-a8eec15e533e4f15f557844bca87f795f2261a81.zip |
SPIGOT-1981: Another attempt at damage
-rw-r--r-- | nms-patches/EntityLiving.patch | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/nms-patches/EntityLiving.patch b/nms-patches/EntityLiving.patch index a4fe72c9..64db669a 100644 --- a/nms-patches/EntityLiving.patch +++ b/nms-patches/EntityLiving.patch @@ -374,6 +374,10 @@ - f = this.applyArmorModifier(damagesource, f); - f = this.applyMagicModifier(damagesource, f); - float f1 = f; +- +- f = Math.max(f - this.getAbsorptionHearts(), 0.0F); +- this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f)); +- if (f != 0.0F) { + // CraftBukkit start + protected boolean damageEntity0(final DamageSource damagesource, float f) { // void -> boolean, add final + if (!this.isInvulnerable(damagesource)) { @@ -384,9 +388,7 @@ + public Double apply(Double f) { + if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && EntityLiving.this.getEquipment(EnumItemSlot.HEAD) != null) { + return -(f - (f * 0.75F)); - -- f = Math.max(f - this.getAbsorptionHearts(), 0.0F); -- this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f)); ++ + } + return -0.0; + } @@ -397,7 +399,7 @@ + Function<Double, Double> blocking = new Function<Double, Double>() { + @Override + public Double apply(Double f) { -+ return (damagesource.a()) ? -0.0 : f * 0.33F; // PAIL: rename ++ return -((EntityLiving.this.d(damagesource)) ? ((damagesource.a()) ? f : (f - (f * 0.33F))) : 0.0); // PAIL: rename + } + }; + float blockingModifier = blocking.apply((double) f).floatValue(); @@ -463,17 +465,16 @@ + } + + // Apply blocking code -+ if (this.d(damagesource)) { // PAIL: rename -+ float blockingDamage = (float) event.getDamage(DamageModifier.BLOCKING); -+ this.k(blockingDamage); // PAIL: rename -+ if (blockingDamage > 0 && damagesource.i() instanceof EntityLiving) { // PAIL: rename ++ if (event.getDamage(DamageModifier.BLOCKING) < 0) { ++ if (damagesource.i() instanceof EntityLiving) {// PAIL: rename ++ this.k(f); // PAIL: rename + ((EntityLiving) damagesource.i()).a(EntityLiving.this, 0.5F, EntityLiving.this.locX - damagesource.i().locX, EntityLiving.this.locZ - damagesource.i().locZ); + } + } + + absorptionModifier = (float) -event.getDamage(DamageModifier.ABSORPTION); + this.setAbsorptionHearts(Math.max(this.getAbsorptionHearts() - absorptionModifier, 0.0F)); - if (f != 0.0F) { ++ if (f > 0) { + if (human) { + // PAIL: Be sure to drag all this code from the EntityHuman subclass each update. + ((EntityHuman) this).applyExhaustion(damagesource.getExhaustionCost()); @@ -486,14 +487,16 @@ this.setHealth(f2 - f); this.getCombatTracker().trackDamage(damagesource, f2, f); +- this.setAbsorptionHearts(this.getAbsorptionHearts() - f); + // CraftBukkit start + if (human) { + return true; + } + // CraftBukkit end - this.setAbsorptionHearts(this.getAbsorptionHearts() - f); ++ this.setAbsorptionHearts(this.getAbsorptionHearts() - f); ++ } else { ++ return false; } -+ return true; } + return false; // CraftBukkit } |