From 6495eee0c9fddcce2c2aa9bf9c45118abea180c1 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Sun, 15 Jan 2012 09:11:21 +0000 Subject: [PATCH] Throw an EntityBlockFormEvent for snowmen. Thanks to feildmaster. --- .../net/minecraft/server/EntitySnowman.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/minecraft/server/EntitySnowman.java b/src/main/java/net/minecraft/server/EntitySnowman.java index bf8cf8403e..09afbc4268 100644 --- a/src/main/java/net/minecraft/server/EntitySnowman.java +++ b/src/main/java/net/minecraft/server/EntitySnowman.java @@ -1,7 +1,11 @@ package net.minecraft.server; import java.util.List; +// Craftbukkit start +import org.bukkit.block.BlockState; import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.block.EntityBlockFormEvent; +// Craftbukkit end public class EntitySnowman extends EntityGolem { @@ -39,7 +43,17 @@ public class EntitySnowman extends EntityGolem { int l = MathHelper.floor(this.locZ + (double) ((float) (i / 2 % 2 * 2 - 1) * 0.25F)); if (this.world.getTypeId(j, k, l) == 0 && this.world.getWorldChunkManager().a(j, k, l) < 0.8F && Block.SNOW.canPlace(this.world, j, k, l)) { - this.world.setTypeId(j, k, l, Block.SNOW.id); + // CraftBukkit start + BlockState blockState = this.world.getWorld().getBlockAt(j, k, l).getState(); + blockState.setTypeId(Block.SNOW.id); + + EntityBlockFormEvent event = new EntityBlockFormEvent(this.getBukkitEntity(), blockState.getBlock(), blockState); + this.world.getServer().getPluginManager().callEvent(event); + + if(!event.isCancelled()) { + blockState.update(true); + } + // CraftBukkit end } } } @@ -89,4 +103,4 @@ public class EntitySnowman extends EntityGolem { CraftEventFactory.callEntityDeathEvent(this, loot); // CraftBukkit end } -} +} \ No newline at end of file