summaryrefslogtreecommitdiffstats
path: root/nms-patches/BlockLever.patch
blob: 945ac935641155f355403ad3ae63a9d9aedbf0a6 (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
--- a/net/minecraft/server/BlockLever.java
+++ b/net/minecraft/server/BlockLever.java
@@ -1,5 +1,7 @@
 package net.minecraft.server;
 
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
 public class BlockLever extends BlockAttachable {
 
     public static final BlockStateBoolean POWERED = BlockProperties.t;
@@ -73,6 +75,20 @@
 
             return true;
         } else {
+            // CraftBukkit start - Interact Lever
+            boolean powered = iblockdata.get(POWERED);
+            org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+            int old = (powered) ? 15 : 0;
+            int current = (!powered) ? 15 : 0;
+
+            BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
+            world.getServer().getPluginManager().callEvent(eventRedstone);
+
+            if ((eventRedstone.getNewCurrent() > 0) != (!powered)) {
+                return true;
+            }
+            // CraftBukkit end
+
             world.setTypeAndData(blockposition, iblockdata, 3);
             float f3 = flag ? 0.6F : 0.5F;