3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-14 12:00:06 +01:00

get previous redstone level from the right state for experimental wires

Dieser Commit ist enthalten in:
Lulu13022002 2024-10-31 16:48:37 +01:00
Ursprung dfedf79a2f
Commit 147b7961fe
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 491C8F0B8ACDEB01
4 geänderte Dateien mit 44 neuen und 29 gelöschten Zeilen

Datei anzeigen

@ -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);
}

Datei anzeigen

@ -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);

Datei anzeigen

@ -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 {

Datei anzeigen

@ -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 {