craftbukkit/nms-patches/net/minecraft/world/level/block/BlockRedstoneWire.patch

30 lines
1.4 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/level/block/BlockRedstoneWire.java
+++ b/net/minecraft/world/level/block/BlockRedstoneWire.java
2023-12-06 03:40:00 +11:00
@@ -37,6 +37,8 @@
2021-03-16 09:00:00 +11:00
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
import net.minecraft.world.phys.shapes.VoxelShapes;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockRedstoneWire extends Block {
2023-12-06 03:40:00 +11:00
public static final MapCodec<BlockRedstoneWire> CODEC = simpleCodec(BlockRedstoneWire::new);
@@ -261,7 +263,16 @@
2021-11-22 09:00:00 +11:00
private void updatePowerStrength(World world, BlockPosition blockposition, IBlockData iblockdata) {
int i = this.calculateTargetStrength(world, blockposition);
2015-02-26 22:41:06 +00:00
2021-11-22 09:00:00 +11:00
- if ((Integer) iblockdata.getValue(BlockRedstoneWire.POWER) != i) {
+ // CraftBukkit start
2021-11-22 09:00:00 +11:00
+ int oldPower = (Integer) iblockdata.getValue(BlockRedstoneWire.POWER);
2020-06-25 10:00:00 +10:00
+ if (oldPower != i) {
+ BlockRedstoneEvent event = new BlockRedstoneEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), oldPower, i);
+ world.getCraftServer().getPluginManager().callEvent(event);
+
2020-06-25 10:00:00 +10:00
+ i = event.getNewCurrent();
+ }
+ if (oldPower != i) {
2020-06-25 10:00:00 +10:00
+ // CraftBukkit end
2021-11-22 09:00:00 +11:00
if (world.getBlockState(blockposition) == iblockdata) {
world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockRedstoneWire.POWER, i), 2);
2020-06-25 10:00:00 +10:00
}