From e03b1a556d889f5ad47d53a4157bde75cbbf4764 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 15 Jul 2017 09:53:22 +1000 Subject: SPIGOT-3417: Event for shearing snowman --- nms-patches/EntitySnowman.patch | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'nms-patches/EntitySnowman.patch') diff --git a/nms-patches/EntitySnowman.patch b/nms-patches/EntitySnowman.patch index 029613e4..bf919be5 100644 --- a/nms-patches/EntitySnowman.patch +++ b/nms-patches/EntitySnowman.patch @@ -1,18 +1,17 @@ --- a/net/minecraft/server/EntitySnowman.java +++ b/net/minecraft/server/EntitySnowman.java -@@ -1,6 +1,11 @@ +@@ -1,6 +1,10 @@ package net.minecraft.server; import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; -+import org.bukkit.craftbukkit.util.CraftMagicNumbers; -+import org.bukkit.event.block.EntityBlockFormEvent; ++import org.bukkit.event.player.PlayerShearEntityEvent; +// CraftBukkit end public class EntitySnowman extends EntityGolem implements IRangedEntity { -@@ -59,7 +64,7 @@ +@@ -59,7 +63,7 @@ } if (this.world.getBiome(new BlockPosition(i, 0, k)).a(new BlockPosition(i, j, k)) > 1.0F) { @@ -21,7 +20,7 @@ } if (!this.world.getGameRules().getBoolean("mobGriefing")) { -@@ -73,7 +78,7 @@ +@@ -73,7 +77,7 @@ BlockPosition blockposition = new BlockPosition(i, j, k); if (this.world.getType(blockposition).getMaterial() == Material.AIR && this.world.getBiome(blockposition).a(blockposition) < 0.8F && Blocks.SNOW_LAYER.canPlace(this.world, blockposition)) { @@ -30,3 +29,19 @@ } } } +@@ -106,6 +110,15 @@ + ItemStack itemstack = entityhuman.b(enumhand); + + if (itemstack.getItem() == Items.SHEARS && this.hasPumpkin() && !this.world.isClientSide) { ++ // CraftBukkit start ++ PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity()); ++ this.world.getServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ return false; ++ } ++ // CraftBukkit end ++ + this.setHasPumpkin(false); + itemstack.damage(1, entityhuman); + } -- cgit v1.2.3