From d4ab21c0476da2034c233831b5af07764fc8a80b Mon Sep 17 00:00:00 2001 From: Warrior <50800980+Warriorrrr@users.noreply.github.com> Date: Wed, 13 Sep 2023 05:46:10 +0200 Subject: [PATCH] Call BlockRedstoneEvents properly Call BlockRedstoneEvents for lecterns. Fix previous power level for experimental redstone wire. --- .../world/level/block/LecternBlock.java.patch | 19 ++++++++++++++++++- ...perimentalRedstoneWireEvaluator.java.patch | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/LecternBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/LecternBlock.java.patch index c8bf8cd74f..bfec1523db 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/LecternBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/LecternBlock.java.patch @@ -1,6 +1,23 @@ --- a/net/minecraft/world/level/block/LecternBlock.java +++ b/net/minecraft/world/level/block/LecternBlock.java -@@ -206,11 +206,12 @@ +@@ -175,6 +175,16 @@ + } + + private static void changePowered(Level world, BlockPos pos, BlockState state, boolean powered) { ++ // Paper start - Call BlockRedstoneEvent properly ++ final int currentRedstoneLevel = state.getValue(LecternBlock.POWERED) ? 15 : 0, targetRedstoneLevel = powered ? 15 : 0; ++ if (currentRedstoneLevel != targetRedstoneLevel) { ++ final org.bukkit.event.block.BlockRedstoneEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, pos, currentRedstoneLevel, targetRedstoneLevel); ++ ++ if (event.getNewCurrent() != targetRedstoneLevel) { ++ return; ++ } ++ } ++ // Paper end - Call BlockRedstoneEvent properly + world.setBlock(pos, (BlockState) state.setValue(LecternBlock.POWERED, powered), 3); + LecternBlock.updateBelow(world, pos, state); + } +@@ -206,11 +216,12 @@ } private void popBook(BlockState state, Level world, BlockPos pos) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.java.patch b/paper-server/patches/sources/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.java.patch index 722dc6d4f7..73e662622f 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.java.patch @@ -17,7 +17,7 @@ - if (iblockdata1.is((Block) this.wireBlock) && !((Integer) iblockdata1.getValue(RedStoneWireBlock.POWER)).equals(j)) { + // CraftBukkit start -+ int oldPower = state.getValue(RedStoneWireBlock.POWER); ++ int oldPower = iblockdata1.getValue(RedStoneWireBlock.POWER); // Paper - Call BlockRedstoneEvent properly; get the previous power from the right state + if (oldPower != j) { + BlockRedstoneEvent event = new BlockRedstoneEvent(CraftBlock.at(world, blockposition1), oldPower, j); + world.getCraftServer().getPluginManager().callEvent(event);