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

33 lines
1.4 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/level/block/BlockLever.java
+++ b/net/minecraft/world/level/block/BlockLever.java
2022-06-08 02:00:00 +10:00
@@ -24,6 +24,8 @@
2021-03-16 09:00:00 +11:00
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
2018-07-15 10:00:00 +10:00
public class BlockLever extends BlockAttachable {
2021-06-11 15:00:00 +10:00
public static final BlockStateBoolean POWERED = BlockProperties.POWERED;
2022-06-08 02:00:00 +10:00
@@ -91,6 +93,20 @@
2019-12-11 09:00:00 +11:00
return EnumInteractionResult.SUCCESS;
} else {
+ // CraftBukkit start - Interact Lever
2021-11-22 09:00:00 +11:00
+ boolean powered = iblockdata.getValue(BlockLever.POWERED); // Old powered state
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ int old = (powered) ? 15 : 0;
+ int current = (!powered) ? 15 : 0;
+
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
+ world.getCraftServer().getPluginManager().callEvent(eventRedstone);
+
+ if ((eventRedstone.getNewCurrent() > 0) != (!powered)) {
2019-12-11 09:00:00 +11:00
+ return EnumInteractionResult.SUCCESS;
+ }
+ // CraftBukkit end
2016-03-01 08:32:46 +11:00
+
2021-11-22 09:00:00 +11:00
iblockdata1 = this.pull(iblockdata, world, blockposition);
float f = (Boolean) iblockdata1.getValue(BlockLever.POWERED) ? 0.6F : 0.5F;
2018-07-15 10:00:00 +10:00