summaryrefslogtreecommitdiffstats
path: root/nms-patches/BlockRedstoneComparator.patch
blob: de272ab413dd1a385258eb6553aaf6cf73ed5dc0 (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
--- a/net/minecraft/server/BlockRedstoneComparator.java
+++ b/net/minecraft/server/BlockRedstoneComparator.java
@@ -5,6 +5,8 @@
 import java.util.function.Predicate;
 import javax.annotation.Nullable;
 
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
 public class BlockRedstoneComparator extends BlockDiodeAbstract implements ITileEntity {
 
     public static final BlockStateEnum<BlockPropertyComparatorMode> MODE = BlockProperties.ap;
@@ -118,8 +120,18 @@
             boolean flag1 = ((Boolean) iblockdata.get(BlockRedstoneComparator.c)).booleanValue();
 
             if (flag1 && !flag) {
+                // CraftBukkit start
+                if (CraftEventFactory.callRedstoneChange(world, blockposition, 15, 0).getNewCurrent() != 0) {
+                    return;
+                }
+                // CraftBukkit end
                 world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneComparator.c, Boolean.valueOf(false)), 2);
             } else if (!flag1 && flag) {
+                // CraftBukkit start
+                if (CraftEventFactory.callRedstoneChange(world, blockposition, 0, 15).getNewCurrent() != 15) {
+                    return;
+                }
+                // CraftBukkit end
                 world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneComparator.c, Boolean.valueOf(true)), 2);
             }