From 147b7961fea0a33dde0cc6041bea578a5e25e7ee Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Thu, 31 Oct 2024 16:48:37 +0100 Subject: [PATCH] get previous redstone level from the right state for experimental wires --- ...all-BlockRedstoneEvents-for-lecterns.patch | 27 ------------ ...71-Call-BlockRedstoneEvents-properly.patch | 42 +++++++++++++++++++ ...-Fix-InventoryOpenEvent-cancellation.patch | 2 +- ...031-Add-PlayerInsertLecternBookEvent.patch | 2 +- 4 files changed, 44 insertions(+), 29 deletions(-) delete mode 100644 patches/server/0871-Call-BlockRedstoneEvents-for-lecterns.patch create mode 100644 patches/server/0871-Call-BlockRedstoneEvents-properly.patch diff --git a/patches/server/0871-Call-BlockRedstoneEvents-for-lecterns.patch b/patches/server/0871-Call-BlockRedstoneEvents-for-lecterns.patch deleted file mode 100644 index 7726626d78..0000000000 --- a/patches/server/0871-Call-BlockRedstoneEvents-for-lecterns.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0000000000000000000000000000000000000000 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 for lecterns - - -diff --git a/src/main/java/net/minecraft/world/level/block/LecternBlock.java b/src/main/java/net/minecraft/world/level/block/LecternBlock.java -index 44d322d26187bd7528799069d0e08dbf571a57f3..3537795720be76483579fc50715914974c97c9c4 100644 ---- a/src/main/java/net/minecraft/world/level/block/LecternBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/LecternBlock.java -@@ -180,6 +180,16 @@ public class LecternBlock extends BaseEntityBlock { - } - - private static void changePowered(Level world, BlockPos pos, BlockState state, boolean powered) { -+ // Paper start - call BlockRedstoneEvents for lecterns -+ 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 BlockRedstoneEvents for lecterns - world.setBlock(pos, (BlockState) state.setValue(LecternBlock.POWERED, powered), 3); - LecternBlock.updateBelow(world, pos, state); - } diff --git a/patches/server/0871-Call-BlockRedstoneEvents-properly.patch b/patches/server/0871-Call-BlockRedstoneEvents-properly.patch new file mode 100644 index 0000000000..54b0e427b8 --- /dev/null +++ b/patches/server/0871-Call-BlockRedstoneEvents-properly.patch @@ -0,0 +1,42 @@ +From 0000000000000000000000000000000000000000 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. + +diff --git a/src/main/java/net/minecraft/world/level/block/LecternBlock.java b/src/main/java/net/minecraft/world/level/block/LecternBlock.java +index 44d322d26187bd7528799069d0e08dbf571a57f3..2864d0dec66980736f7434bff3031c05cff64592 100644 +--- a/src/main/java/net/minecraft/world/level/block/LecternBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/LecternBlock.java +@@ -180,6 +180,16 @@ public class LecternBlock extends BaseEntityBlock { + } + + 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); + } +diff --git a/src/main/java/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.java b/src/main/java/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.java +index 28e0ff0a6fef63a572782704d34c4ccefc7baec1..bad91f7e9ebcf9d73f2d74a65e5235ee496e844e 100644 +--- a/src/main/java/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.java ++++ b/src/main/java/net/minecraft/world/level/redstone/ExperimentalRedstoneWireEvaluator.java +@@ -46,7 +46,7 @@ public class ExperimentalRedstoneWireEvaluator extends RedstoneWireEvaluator { + BlockState iblockdata1 = world.getBlockState(blockposition1); + + // 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); diff --git a/patches/server/1017-Fix-InventoryOpenEvent-cancellation.patch b/patches/server/1017-Fix-InventoryOpenEvent-cancellation.patch index e63b2489a9..2ac771df85 100644 --- a/patches/server/1017-Fix-InventoryOpenEvent-cancellation.patch +++ b/patches/server/1017-Fix-InventoryOpenEvent-cancellation.patch @@ -263,7 +263,7 @@ index b61324fe162f32817b87e4adb80df57b9433259f..005a2a66a6e8a492acfa7ba91117884c } diff --git a/src/main/java/net/minecraft/world/level/block/LecternBlock.java b/src/main/java/net/minecraft/world/level/block/LecternBlock.java -index 3537795720be76483579fc50715914974c97c9c4..ec6ff0b192ae2f1586095519ad2472e76b2b5589 100644 +index 2864d0dec66980736f7434bff3031c05cff64592..d7e14ee2c11f34703b63fcd2e2ad5257003e14c8 100644 --- a/src/main/java/net/minecraft/world/level/block/LecternBlock.java +++ b/src/main/java/net/minecraft/world/level/block/LecternBlock.java @@ -298,8 +298,7 @@ public class LecternBlock extends BaseEntityBlock { diff --git a/patches/server/1031-Add-PlayerInsertLecternBookEvent.patch b/patches/server/1031-Add-PlayerInsertLecternBookEvent.patch index e410ce7bc2..f15585222f 100644 --- a/patches/server/1031-Add-PlayerInsertLecternBookEvent.patch +++ b/patches/server/1031-Add-PlayerInsertLecternBookEvent.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add PlayerInsertLecternBookEvent diff --git a/src/main/java/net/minecraft/world/level/block/LecternBlock.java b/src/main/java/net/minecraft/world/level/block/LecternBlock.java -index ec6ff0b192ae2f1586095519ad2472e76b2b5589..53f388dd0ba6b77fe49a584883e8c9d49d5a5fba 100644 +index d7e14ee2c11f34703b63fcd2e2ad5257003e14c8..70f2e6278e2d970245ca5b46fbd9ffae4727b47b 100644 --- a/src/main/java/net/minecraft/world/level/block/LecternBlock.java +++ b/src/main/java/net/minecraft/world/level/block/LecternBlock.java @@ -158,7 +158,24 @@ public class LecternBlock extends BaseEntityBlock {