3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-20 13:30:05 +01:00

SPIGOT-5405: Use correct damage source for HangingBreakByEntityEvent

Dieser Commit ist enthalten in:
Brokkonaut 2019-11-28 06:31:04 +01:00 committet von md_5
Ursprung ccd47a503a
Commit eafd74240d

Datei anzeigen

@ -108,16 +108,17 @@
this.die(); this.die();
this.a((Entity) null); this.a((Entity) null);
} }
@@ -139,6 +175,21 @@ @@ -139,6 +175,22 @@
return false; return false;
} else { } else {
if (!this.dead && !this.world.isClientSide) { if (!this.dead && !this.world.isClientSide) {
+ // CraftBukkit start - fire break events + // CraftBukkit start - fire break events
+ HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.DEFAULT); + Entity damager = (damagesource instanceof EntityDamageSourceIndirect) ? ((EntityDamageSourceIndirect) damagesource).getProximateDamageSource() : damagesource.getEntity();
+ if (damagesource.getEntity() != null) { + HangingBreakEvent event;
+ event = new HangingBreakByEntityEvent((Hanging) this.getBukkitEntity(), damagesource.getEntity() == null ? null : damagesource.getEntity().getBukkitEntity(), damagesource.isExplosion() ? HangingBreakEvent.RemoveCause.EXPLOSION : HangingBreakEvent.RemoveCause.ENTITY); + if (damager != null) {
+ } else if (damagesource.isExplosion()) { + event = new HangingBreakByEntityEvent((Hanging) this.getBukkitEntity(), damager.getBukkitEntity(), damagesource.isExplosion() ? HangingBreakEvent.RemoveCause.EXPLOSION : HangingBreakEvent.RemoveCause.ENTITY);
+ event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.EXPLOSION); + } else {
+ event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), damagesource.isExplosion() ? HangingBreakEvent.RemoveCause.EXPLOSION : HangingBreakEvent.RemoveCause.DEFAULT);
+ } + }
+ +
+ this.world.getServer().getPluginManager().callEvent(event); + this.world.getServer().getPluginManager().callEvent(event);
@ -130,7 +131,7 @@
this.die(); this.die();
this.velocityChanged(); this.velocityChanged();
this.a(damagesource.getEntity()); this.a(damagesource.getEntity());
@@ -151,6 +202,18 @@ @@ -151,6 +203,18 @@
@Override @Override
public void move(EnumMoveType enummovetype, Vec3D vec3d) { public void move(EnumMoveType enummovetype, Vec3D vec3d) {
if (!this.world.isClientSide && !this.dead && vec3d.g() > 0.0D) { if (!this.world.isClientSide && !this.dead && vec3d.g() > 0.0D) {
@ -149,7 +150,7 @@
this.die(); this.die();
this.a((Entity) null); this.a((Entity) null);
} }
@@ -159,7 +222,7 @@ @@ -159,7 +223,7 @@
@Override @Override
public void f(double d0, double d1, double d2) { public void f(double d0, double d1, double d2) {