From f28f3a6a9cc3047c5c1aa2e7a0b456d1f4197f1b Mon Sep 17 00:00:00 2001 From: Erik Broes Date: Wed, 16 Mar 2011 21:27:24 +0100 Subject: [PATCH] BlockInteract fixed for pressure plates --- .../minecraft/server/BlockPressurePlate.java | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/main/java/net/minecraft/server/BlockPressurePlate.java b/src/main/java/net/minecraft/server/BlockPressurePlate.java index fc8a940f0c..de3a0f6918 100644 --- a/src/main/java/net/minecraft/server/BlockPressurePlate.java +++ b/src/main/java/net/minecraft/server/BlockPressurePlate.java @@ -68,24 +68,6 @@ public class BlockPressurePlate extends Block { public void a(World world, int i, int j, int k, Entity entity) { if (!world.isStatic) { if (world.getData(i, j, k) != 1) { - - // CraftBukkit start - Interact Pressure Plate - if (entity instanceof EntityLiving) { - CraftServer server = ((WorldServer) world).getServer(); - CraftWorld craftWorld = ((WorldServer) world).getWorld(); - Type eventType = Type.BLOCK_INTERACT; - CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k); - org.bukkit.entity.LivingEntity who = (entity == null) ? null : (LivingEntity) entity.getBukkitEntity(); - - BlockInteractEvent event = new BlockInteractEvent(eventType, block, who); - server.getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return; - } - } - // CraftBukkit end - this.g(world, i, j, k); } } @@ -113,13 +95,32 @@ public class BlockPressurePlate extends Block { flag1 = true; } - // CraftBukkit start + // CraftBukkit start - Interact Pressure Plate + CraftServer server = ((WorldServer) world).getServer(); + CraftWorld craftWorld = ((WorldServer) world).getWorld(); + CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k); + if (flag != flag1) { - CraftWorld craftWorld = ((WorldServer) world).getWorld(); - CraftServer server = ((WorldServer) world).getServer(); - CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k); + if (flag1) { + for (Object object: list) { + if (object != null && object instanceof EntityLiving) { + EntityLiving entity = (EntityLiving) object; + Type eventType = Type.BLOCK_INTERACT; + org.bukkit.entity.LivingEntity who = (LivingEntity) entity.getBukkitEntity(); + + BlockInteractEvent event = new BlockInteractEvent(eventType, block, who); + server.getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return; + } + } + } + } + BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, flag ? 1 : 0, flag1 ? 1 : 0); server.getPluginManager().callEvent(eventRedstone); + flag1 = eventRedstone.getNewCurrent() > 0; } // CraftBukkit end