PaperMC/paper-server/nms-patches/net/minecraft/world/level/block/BlockLever.patch

33 lines
1.4 KiB
Diff
Raw Normal View History

2021-03-15 23:00:00 +01:00
--- a/net/minecraft/world/level/block/BlockLever.java
+++ b/net/minecraft/world/level/block/BlockLever.java
@@ -22,6 +22,8 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockLever extends BlockAttachable {
public static final BlockStateBoolean POWERED = BlockProperties.w;
2021-03-15 23:00:00 +01:00
@@ -86,6 +88,20 @@
return EnumInteractionResult.SUCCESS;
} else {
+ // CraftBukkit start - Interact Lever
+ boolean powered = iblockdata.get(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.getServer().getPluginManager().callEvent(eventRedstone);
+
+ if ((eventRedstone.getNewCurrent() > 0) != (!powered)) {
+ return EnumInteractionResult.SUCCESS;
+ }
+ // CraftBukkit end
+
iblockdata1 = this.d(iblockdata, world, blockposition);
float f = (Boolean) iblockdata1.get(BlockLever.POWERED) ? 0.6F : 0.5F;