summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmosar <maxi.cass11@gmail.com>2018-08-09 14:44:57 +0200
committermd_5 <git@md-5.net>2018-08-10 08:39:18 +1000
commiteb36029f1cc9e4dffaa757da980c7d100cf86605 (patch)
tree0439318ccba04eb42f2261e32809deda1cabcca0
parent4487c1f9d9146743e347d7d7d8ae28f08559a273 (diff)
downloadcraftbukkit-eb36029f1cc9e4dffaa757da980c7d100cf86605.tar
craftbukkit-eb36029f1cc9e4dffaa757da980c7d100cf86605.tar.gz
craftbukkit-eb36029f1cc9e4dffaa757da980c7d100cf86605.tar.lz
craftbukkit-eb36029f1cc9e4dffaa757da980c7d100cf86605.tar.xz
craftbukkit-eb36029f1cc9e4dffaa757da980c7d100cf86605.zip
SPIGOT-2719: Comparator and Observer don't trigger BlockRedstoneEvent
-rw-r--r--nms-patches/BlockObserver.patch30
-rw-r--r--nms-patches/BlockRedstoneComparator.patch30
2 files changed, 60 insertions, 0 deletions
diff --git a/nms-patches/BlockObserver.patch b/nms-patches/BlockObserver.patch
new file mode 100644
index 00000000..49c01c13
--- /dev/null
+++ b/nms-patches/BlockObserver.patch
@@ -0,0 +1,30 @@
+--- a/net/minecraft/server/BlockObserver.java
++++ b/net/minecraft/server/BlockObserver.java
+@@ -2,6 +2,8 @@
+
+ import java.util.Random;
+
++import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
++
+ public class BlockObserver extends BlockDirectional {
+
+ public static final BlockStateBoolean b = BlockProperties.t;
+@@ -25,8 +27,18 @@
+
+ public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
+ if (((Boolean) iblockdata.get(BlockObserver.b)).booleanValue()) {
++ // CraftBukkit start
++ if (CraftEventFactory.callRedstoneChange(world, blockposition, 15, 0).getNewCurrent() != 0) {
++ return;
++ }
++ // CraftBukkit end
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockObserver.b, Boolean.valueOf(false)), 2);
+ } else {
++ // CraftBukkit start
++ if (CraftEventFactory.callRedstoneChange(world, blockposition, 0, 15).getNewCurrent() != 15) {
++ return;
++ }
++ // CraftBukkit end
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockObserver.b, Boolean.valueOf(true)), 2);
+ world.I().a(blockposition, this, 2);
+ }
diff --git a/nms-patches/BlockRedstoneComparator.patch b/nms-patches/BlockRedstoneComparator.patch
new file mode 100644
index 00000000..de272ab4
--- /dev/null
+++ b/nms-patches/BlockRedstoneComparator.patch
@@ -0,0 +1,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);
+ }
+