mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 03:48:01 +01:00
Call BlockRedstoneEvents properly
Call BlockRedstoneEvents for lecterns. Fix previous power level for experimental redstone wire.
This commit is contained in:
parent
5688b5cf50
commit
d4ab21c047
@ -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) {
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user