summaryrefslogtreecommitdiffstats
path: root/nms-patches/BlockCommand.patch
blob: 94c248a695968329ed7b2a6e1d94b3af73ae86de (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
39
--- a/net/minecraft/server/BlockCommand.java
+++ b/net/minecraft/server/BlockCommand.java
@@ -2,6 +2,8 @@
 
 import java.util.Random;
 
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
 public class BlockCommand extends BlockTileEntity {
 
     public static final BlockStateDirection a = BlockDirectional.FACING;
@@ -29,7 +31,17 @@
                 boolean flag1 = tileentitycommand.d();
                 boolean flag2 = tileentitycommand.e();
 
-                if (flag && !flag1) {
+            // CraftBukkit start
+            // PAIL: This section - renames, ordering
+            org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+            int old = flag1 ? 15 : 0;
+            int current = flag ? 15 : 0;
+
+            BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, old, current);
+            world.getServer().getPluginManager().callEvent(eventRedstone);
+            // CraftBukkit end
+
+            if (eventRedstone.getNewCurrent() > 0 && !(eventRedstone.getOldCurrent() > 0)) { // CraftBukkit
                     tileentitycommand.a(true);
                     if (tileentitycommand.i() != TileEntityCommand.Type.SEQUENCE && !flag2) {
                         boolean flag3 = !tileentitycommand.j() || this.e(world, blockposition, iblockdata);
@@ -40,7 +52,7 @@
                             this.c(world, blockposition);
                         }
                     }
-                } else if (!flag && flag1) {
+            } else if (!(eventRedstone.getNewCurrent() > 0) && eventRedstone.getOldCurrent() > 0) { // CraftBukkit
                     tileentitycommand.a(false);
                 }