From 5a6878b9b1f1be8158c5b10e705d2f69739f4bb2 Mon Sep 17 00:00:00 2001 From: EvilSeph Date: Wed, 14 Mar 2012 23:15:22 -0400 Subject: [PATCH] Made stepping on Redstone Ore fire PlayerInteract events for players, EntityInteract events for other entities. Fixes BUKKIT-1163 and fixes BUKKIT-1182 Note: the client seems to predict redstone ore interacting, so you may see ore lighting up when it shouldn't be. However, cancelled events should function as expected. --- .../net/minecraft/server/BlockRedstoneOre.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/minecraft/server/BlockRedstoneOre.java b/src/main/java/net/minecraft/server/BlockRedstoneOre.java index ac5dd4335d..8d28de8bd8 100644 --- a/src/main/java/net/minecraft/server/BlockRedstoneOre.java +++ b/src/main/java/net/minecraft/server/BlockRedstoneOre.java @@ -25,8 +25,22 @@ public class BlockRedstoneOre extends Block { } public void b(World world, int i, int j, int k, Entity entity) { - this.g(world, i, j, k); - super.b(world, i, j, k, entity); + // CraftBukkit start + if (entity instanceof EntityHuman) { + org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, i, j, k, -1, null); + if (!event.isCancelled()) { + this.g(world, i, j, k); + super.b(world, i, j, k, entity); + } + } else { + org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(i, j, k)); + world.getServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { + this.g(world, i, j, k); + super.b(world, i, j, k, entity); + } + } + // CraftBukkit end } public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {