0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git synced 2024-11-22 10:06:16 +00:00
craftbukkit/nms-patches/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.patch
2024-10-23 02:15:00 +11:00

33 lines
1.5 KiB
Diff

--- a/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java
+++ b/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java
@@ -10,6 +10,11 @@
import net.minecraft.world.level.block.BlockRedstoneWire;
import net.minecraft.world.level.block.state.IBlockData;
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.event.block.BlockRedstoneEvent;
+// CraftBukkit end
+
public class DefaultRedstoneWireEvaluator extends RedstoneWireEvaluator {
public DefaultRedstoneWireEvaluator(BlockRedstoneWire blockredstonewire) {
@@ -20,7 +25,16 @@
public void updatePowerStrength(World world, BlockPosition blockposition, IBlockData iblockdata, @Nullable Orientation orientation, boolean flag) {
int i = this.calculateTargetStrength(world, blockposition);
- if ((Integer) iblockdata.getValue(BlockRedstoneWire.POWER) != i) {
+ // CraftBukkit start
+ int oldPower = iblockdata.getValue(BlockRedstoneWire.POWER);
+ if (oldPower != i) {
+ BlockRedstoneEvent event = new BlockRedstoneEvent(CraftBlock.at(world, blockposition), oldPower, i);
+ world.getCraftServer().getPluginManager().callEvent(event);
+
+ i = event.getNewCurrent();
+ }
+ if (oldPower != i) {
+ // CraftBukkit end
if (world.getBlockState(blockposition) == iblockdata) {
world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockRedstoneWire.POWER, i), 2);
}