summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGJ <gjmcferrin@gmail.com>2013-12-16 23:16:16 -0500
committerNate Mortensen <nate.richard.mortensen@gmail.com>2014-01-30 21:44:36 -0700
commit19521b7f1c570af427df5525419210e0808d35e3 (patch)
treea975cb8375ed659fbc5edfcf2760e5804d9ce9b2
parent6a0095998059c6d02b903478a600c08d3bab4466 (diff)
downloadcraftbukkit-19521b7f1c570af427df5525419210e0808d35e3.tar
craftbukkit-19521b7f1c570af427df5525419210e0808d35e3.tar.gz
craftbukkit-19521b7f1c570af427df5525419210e0808d35e3.tar.lz
craftbukkit-19521b7f1c570af427df5525419210e0808d35e3.tar.xz
craftbukkit-19521b7f1c570af427df5525419210e0808d35e3.zip
[Bleeding] Fire interact events for Weighted Pressure Plates. Fixes BUKKIT-5053
In 1.7, Minecraft changed Weighted Pressure Plates to allow players and entities to interact with them, rather than simply changing redstone signal based on the number of items on the pressure plate. This commit adds calls to PlayerInteractEvent or EntityInteractEvent for every entity that steps on the plate.
-rw-r--r--src/main/java/net/minecraft/server/BlockPressurePlateWeighted.java27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/main/java/net/minecraft/server/BlockPressurePlateWeighted.java b/src/main/java/net/minecraft/server/BlockPressurePlateWeighted.java
index 70855690..8bc708fc 100644
--- a/src/main/java/net/minecraft/server/BlockPressurePlateWeighted.java
+++ b/src/main/java/net/minecraft/server/BlockPressurePlateWeighted.java
@@ -2,6 +2,8 @@ package net.minecraft.server;
import java.util.List;
+import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
+
public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract {
private final int a;
@@ -11,7 +13,30 @@ public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract {
}
protected int e(World world, int i, int j, int k) {
- int l = Math.min(world.a(Entity.class, this.a(i, j, k)).size(), this.a);
+ // CraftBukkit start
+ int l = 0;
+ java.util.Iterator iterator = world.a(Entity.class, this.a(i, j, k)).iterator();
+
+ while (iterator.hasNext()) {
+ Entity entity = (Entity) iterator.next();
+
+ org.bukkit.event.Cancellable cancellable;
+
+ if (entity instanceof EntityHuman) {
+ cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, i, j, k, -1, null);
+ } else {
+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(i, j, k));
+ world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
+ }
+
+ // We only want to block turning the plate on if all events are cancelled
+ if (!cancellable.isCancelled()) {
+ l++;
+ }
+ }
+
+ l = Math.min(l, this.a);
+ // CraftBukkit end
if (l <= 0) {
return 0;