mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +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
|
--- a/net/minecraft/world/level/block/LecternBlock.java
|
||||||
+++ b/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) {
|
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)) {
|
- if (iblockdata1.is((Block) this.wireBlock) && !((Integer) iblockdata1.getValue(RedStoneWireBlock.POWER)).equals(j)) {
|
||||||
+ // CraftBukkit start
|
+ // 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) {
|
+ if (oldPower != j) {
|
||||||
+ BlockRedstoneEvent event = new BlockRedstoneEvent(CraftBlock.at(world, blockposition1), oldPower, j);
|
+ BlockRedstoneEvent event = new BlockRedstoneEvent(CraftBlock.at(world, blockposition1), oldPower, j);
|
||||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||||
|
Loading…
Reference in New Issue
Block a user