[Bleeding] Implement new damage api. Fixes BUKKIT-5326, BUKKIT-3878.

This commit centralizes event handling to where damage is actually applied
to the entity to avoid bugs that have resulted from nodamageticks,
modifications to damage after the event has been called, and similar
mishaps. This also implements new API for getting and setting of
modifications made to the damage amount actually applied to the entity.
This is done by storing the change in the damage amount as each modifier
is applied by vanilla code.

The method that actually damages the armor worn by an entity has been
relocated beneath the event called as to not apply durability loss when
the event has been cancelled.
This commit is contained in:
t00thpick1 authored and Wesley Wolfe committed 2014-06-22 15:23:16 -05:00
1 parent bed3f7f8f5
commit 6f21d3ca8f
12 files changed
+264 -224

No files matched your search

@@ -799,7 +799,12 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen
return (float) i / (float) this.inventory.armor.length;
}
protected void d(DamageSource damagesource, float f) {
// CraftBukkit start
protected boolean d(DamageSource damagesource, float f) { // void -> boolean
if (true) {
return super.d(damagesource, f);
}
// CraftBukkit end
if (!this.isInvulnerable()) {
if (!damagesource.ignoresArmor() && this.isBlocking() && f > 0.0F) {
f = (1.0F + f) * 0.5F;
@@ -819,6 +824,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen
this.aV().a(damagesource, f2, f);
}
}
return false; // CraftBukkit
}
public void openFurnace(TileEntityFurnace tileentityfurnace) {}