From 6ed8a189660db58e31d4768a1916a3e79a73d544 Mon Sep 17 00:00:00 2001 From: anhcraft Date: Wed, 28 Aug 2019 18:02:43 +0700 Subject: [PATCH] SPIGOT-5290: Invulnerable and/or Marker armor stand triggers EntityDamageEvent --- nms-patches/EntityArmorStand.patch | 33 ++++++++++++++++-------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/nms-patches/EntityArmorStand.patch b/nms-patches/EntityArmorStand.patch index 342ef38a02..e59b2edf8f 100644 --- a/nms-patches/EntityArmorStand.patch +++ b/nms-patches/EntityArmorStand.patch @@ -52,21 +52,24 @@ if (entityhuman.abilities.canInstantlyBuild && itemstack1.isEmpty() && !itemstack.isEmpty()) { itemstack2 = itemstack.cloneItemStack(); -@@ -396,14 +427,19 @@ - - @Override +@@ -398,12 +429,22 @@ public boolean damageEntity(DamageSource damagesource, float f) { -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) { -+ return false; -+ } -+ // CraftBukkit end if (!this.world.isClientSide && !this.dead) { if (DamageSource.OUT_OF_WORLD.equals(damagesource)) { - this.die(); ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) { ++ return false; ++ } ++ // CraftBukkit end + this.killEntity(); // CraftBukkit - this.die() -> this.killEntity() return false; } else if (!this.isInvulnerable(damagesource) && !this.bD && !this.isMarker()) { ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) { ++ return false; ++ } ++ // CraftBukkit end if (damagesource.isExplosion()) { this.g(damagesource); - this.die(); @@ -74,7 +77,7 @@ return false; } else if (DamageSource.FIRE.equals(damagesource)) { if (this.isBurning()) { -@@ -428,7 +464,7 @@ +@@ -428,7 +469,7 @@ } else if (damagesource.v()) { this.F(); this.D(); @@ -83,7 +86,7 @@ return flag1; } else { long i = this.world.getTime(); -@@ -439,7 +475,7 @@ +@@ -439,7 +480,7 @@ } else { this.f(damagesource); this.D(); @@ -92,7 +95,7 @@ } return true; -@@ -466,7 +502,7 @@ +@@ -466,7 +507,7 @@ f1 -= f; if (f1 <= 0.5F) { this.g(damagesource); @@ -101,7 +104,7 @@ } else { this.setHealth(f1); } -@@ -474,13 +510,13 @@ +@@ -474,13 +515,13 @@ } private void f(DamageSource damagesource) { @@ -117,7 +120,7 @@ ItemStack itemstack; int i; -@@ -488,7 +524,7 @@ +@@ -488,7 +529,7 @@ for (i = 0; i < this.handItems.size(); ++i) { itemstack = (ItemStack) this.handItems.get(i); if (!itemstack.isEmpty()) { @@ -126,7 +129,7 @@ this.handItems.set(i, ItemStack.a); } } -@@ -496,10 +532,11 @@ +@@ -496,10 +537,11 @@ for (i = 0; i < this.armorItems.size(); ++i) { itemstack = (ItemStack) this.armorItems.get(i); if (!itemstack.isEmpty()) { @@ -139,7 +142,7 @@ } -@@ -600,8 +637,16 @@ +@@ -600,8 +642,16 @@ return this.isSmall(); }