summaryrefslogtreecommitdiffstats
path: root/nms-patches/BlockPressurePlateBinary.patch
blob: 4230b6807f80e68156b70f8420f134bd07e1b3ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
--- /home/matt/mc-dev-private//net/minecraft/server/BlockPressurePlateBinary.java	2015-02-26 22:40:22.215608143 +0000
+++ src/main/java/net/minecraft/server/BlockPressurePlateBinary.java	2015-02-26 22:40:22.215608143 +0000
@@ -3,6 +3,8 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
+
 public class BlockPressurePlateBinary extends BlockPressurePlateAbstract {
 
     public static final BlockStateBoolean POWERED = BlockStateBoolean.of("powered");
@@ -45,6 +47,26 @@
             while (iterator.hasNext()) {
                 Entity entity = (Entity) iterator.next();
 
+                // CraftBukkit start - Call interact event when turning on a pressure plate
+                if (this.e(world.getType(blockposition)) == 0) {
+                    org.bukkit.World bworld = world.getWorld();
+                    org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();
+                    org.bukkit.event.Cancellable cancellable;
+
+                    if (entity instanceof EntityHuman) {
+                        cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null);
+                    } else {
+                        cancellable = new EntityInteractEvent(entity.getBukkitEntity(), bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+                        manager.callEvent((EntityInteractEvent) cancellable);
+                    }
+
+                    // We only want to block turning the plate on if all events are cancelled
+                    if (cancellable.isCancelled()) {
+                        continue;
+                    }
+                }
+                // CraftBukkit end
+
                 if (!entity.aI()) {
                     return 15;
                 }