PaperMC/nms-patches/BlockRedstoneComparator.patch
2020-06-25 10:00:00 +10:00

40 lines
2.3 KiB
Diff

--- a/net/minecraft/server/BlockRedstoneComparator.java
+++ b/net/minecraft/server/BlockRedstoneComparator.java
@@ -4,6 +4,8 @@
import java.util.Random;
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.aG;
@@ -67,7 +69,8 @@
@Nullable
private EntityItemFrame a(World world, EnumDirection enumdirection, BlockPosition blockposition) {
- List<EntityItemFrame> list = world.a(EntityItemFrame.class, new AxisAlignedBB((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), (double) (blockposition.getX() + 1), (double) (blockposition.getY() + 1), (double) (blockposition.getZ() + 1)), (entityitemframe) -> {
+ // CraftBukkit - decompile error
+ List<EntityItemFrame> list = world.a(EntityItemFrame.class, new AxisAlignedBB((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), (double) (blockposition.getX() + 1), (double) (blockposition.getY() + 1), (double) (blockposition.getZ() + 1)), (java.util.function.Predicate<EntityItemFrame>) (entityitemframe) -> {
return entityitemframe != null && entityitemframe.getDirection() == enumdirection;
});
@@ -122,8 +125,18 @@
boolean flag1 = (Boolean) iblockdata.get(BlockRedstoneComparator.c);
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, 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, true), 2);
}