SPIGOT-2765: Special case entity triggered explosions for HangingBreakEvent

This commit is contained in:
md_5 2016-11-23 10:34:08 +11:00
parent 7691c87df6
commit c1462a24d8

View file

@ -1,18 +1,19 @@
--- a/net/minecraft/server/EntityHanging.java --- a/net/minecraft/server/EntityHanging.java
+++ b/net/minecraft/server/EntityHanging.java +++ b/net/minecraft/server/EntityHanging.java
@@ -4,6 +4,11 @@ @@ -4,6 +4,12 @@
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
+// CraftBukkit start +// CraftBukkit start
+import org.bukkit.entity.Hanging; +import org.bukkit.entity.Hanging;
+import org.bukkit.event.hanging.HangingBreakByEntityEvent;
+import org.bukkit.event.hanging.HangingBreakEvent; +import org.bukkit.event.hanging.HangingBreakEvent;
+// CraftBukkit end +// CraftBukkit end
+ +
public abstract class EntityHanging extends Entity { public abstract class EntityHanging extends Entity {
private static final Predicate<Entity> c = new Predicate() { private static final Predicate<Entity> c = new Predicate() {
@@ -41,43 +46,52 @@ @@ -41,43 +47,52 @@
this.updateBoundingBox(); this.updateBoundingBox();
} }
@ -97,7 +98,7 @@
return i % 32 == 0 ? 0.5D : 0.0D; return i % 32 == 0 ? 0.5D : 0.0D;
} }
@@ -88,6 +102,24 @@ @@ -88,6 +103,24 @@
if (this.d++ == 100 && !this.world.isClientSide) { if (this.d++ == 100 && !this.world.isClientSide) {
this.d = 0; this.d = 0;
if (!this.dead && !this.survives()) { if (!this.dead && !this.survives()) {
@ -122,14 +123,14 @@
this.die(); this.die();
this.a((Entity) null); this.a((Entity) null);
} }
@@ -140,6 +172,21 @@ @@ -140,6 +173,21 @@
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); + HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.DEFAULT);
+ if (damagesource.getEntity() != null) { + if (damagesource.getEntity() != null) {
+ event = new org.bukkit.event.hanging.HangingBreakByEntityEvent((Hanging) this.getBukkitEntity(), damagesource.getEntity() == null ? null : damagesource.getEntity().getBukkitEntity()); + 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()) { + } else if (damagesource.isExplosion()) {
+ event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.EXPLOSION); + event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.EXPLOSION);
+ } + }
@ -144,7 +145,7 @@
this.die(); this.die();
this.ap(); this.ap();
this.a(damagesource.getEntity()); this.a(damagesource.getEntity());
@@ -151,6 +198,18 @@ @@ -151,6 +199,18 @@
public void move(EnumMoveType enummovetype, double d0, double d1, double d2) { public void move(EnumMoveType enummovetype, double d0, double d1, double d2) {
if (!this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { if (!this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) {
@ -163,7 +164,7 @@
this.die(); this.die();
this.a((Entity) null); this.a((Entity) null);
} }
@@ -158,7 +217,7 @@ @@ -158,7 +218,7 @@
} }
public void f(double d0, double d1, double d2) { public void f(double d0, double d1, double d2) {