From eafd74240dd38ad733832d8ff6b93938fc34ec55 Mon Sep 17 00:00:00 2001 From: Brokkonaut Date: Thu, 28 Nov 2019 06:31:04 +0100 Subject: [PATCH] SPIGOT-5405: Use correct damage source for HangingBreakByEntityEvent --- nms-patches/EntityHanging.patch | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/nms-patches/EntityHanging.patch b/nms-patches/EntityHanging.patch index 36c850d97d..5e34d6d85c 100644 --- a/nms-patches/EntityHanging.patch +++ b/nms-patches/EntityHanging.patch @@ -108,16 +108,17 @@ this.die(); this.a((Entity) null); } -@@ -139,6 +175,21 @@ +@@ -139,6 +175,22 @@ return false; } else { if (!this.dead && !this.world.isClientSide) { + // CraftBukkit start - fire break events -+ HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.DEFAULT); -+ if (damagesource.getEntity() != null) { -+ event = new HangingBreakByEntityEvent((Hanging) this.getBukkitEntity(), damagesource.getEntity() == null ? null : damagesource.getEntity().getBukkitEntity(), damagesource.isExplosion() ? HangingBreakEvent.RemoveCause.EXPLOSION : HangingBreakEvent.RemoveCause.ENTITY); -+ } else if (damagesource.isExplosion()) { -+ event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.EXPLOSION); ++ Entity damager = (damagesource instanceof EntityDamageSourceIndirect) ? ((EntityDamageSourceIndirect) damagesource).getProximateDamageSource() : damagesource.getEntity(); ++ HangingBreakEvent event; ++ if (damager != null) { ++ event = new HangingBreakByEntityEvent((Hanging) this.getBukkitEntity(), damager.getBukkitEntity(), damagesource.isExplosion() ? HangingBreakEvent.RemoveCause.EXPLOSION : HangingBreakEvent.RemoveCause.ENTITY); ++ } else { ++ event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), damagesource.isExplosion() ? HangingBreakEvent.RemoveCause.EXPLOSION : HangingBreakEvent.RemoveCause.DEFAULT); + } + + this.world.getServer().getPluginManager().callEvent(event); @@ -130,7 +131,7 @@ this.die(); this.velocityChanged(); this.a(damagesource.getEntity()); -@@ -151,6 +202,18 @@ +@@ -151,6 +203,18 @@ @Override public void move(EnumMoveType enummovetype, Vec3D vec3d) { if (!this.world.isClientSide && !this.dead && vec3d.g() > 0.0D) { @@ -149,7 +150,7 @@ this.die(); this.a((Entity) null); } -@@ -159,7 +222,7 @@ +@@ -159,7 +223,7 @@ @Override public void f(double d0, double d1, double d2) {