mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-12 18:55:51 -07:00
Apply setLastDamageCause after processing events and the event has not been canceled. Fixes BUKKIT-1881
This allows previous causes to be available during the event, as well as making the damage cause a valid one. If EntityDamageEvent is canceled, then it's not the last DamageCause. Also prevents setting DamageCause involuntarily through construction.
This commit is contained in:
@@ -274,6 +274,7 @@ public abstract class EntityLiving extends Entity {
|
||||
this.world.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
event.getEntity().setLastDamageCause(event);
|
||||
this.damageEntity(DamageSource.STUCK, event.getDamage());
|
||||
}
|
||||
// CraftBukkit end
|
||||
@@ -301,6 +302,7 @@ public abstract class EntityLiving extends Entity {
|
||||
this.world.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled() && event.getDamage() != 0) {
|
||||
event.getEntity().setLastDamageCause(event);
|
||||
this.damageEntity(DamageSource.DROWN, event.getDamage());
|
||||
}
|
||||
// CraftBukkit end
|
||||
@@ -1362,6 +1364,7 @@ public abstract class EntityLiving extends Entity {
|
||||
return;
|
||||
}
|
||||
|
||||
event.getEntity().setLastDamageCause(event);
|
||||
this.damageEntity(DamageSource.OUT_OF_WORLD, event.getDamage());
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
Reference in New Issue
Block a user