3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-24 07:10:10 +01:00
Paper/nms-patches/BlockLever.patch

33 Zeilen
1.6 KiB
Diff

2015-02-26 23:41:06 +01:00
--- /home/matt/mc-dev-private//net/minecraft/server/BlockLever.java 2015-02-26 22:40:22.167608144 +0000
+++ src/main/java/net/minecraft/server/BlockLever.java 2015-02-26 22:40:22.171608144 +0000
@@ -2,6 +2,8 @@
import java.util.Iterator;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockLever extends Block {
2015-02-26 23:41:06 +01:00
public static final BlockStateEnum<BlockLever.EnumLeverPosition> FACING = BlockStateEnum.of("facing", BlockLever.EnumLeverPosition.class);
@@ -155,6 +157,20 @@
if (world.isClientSide) {
return true;
} else {
+ // CraftBukkit start - Interact Lever
2015-02-26 23:41:06 +01:00
+ boolean powered = iblockdata.get(POWERED);
+ 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 true;
+ }
+ // CraftBukkit end
2015-02-26 23:41:06 +01:00
+
iblockdata = iblockdata.a(BlockLever.POWERED);
world.setTypeAndData(blockposition, iblockdata, 3);
world.makeSound((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, "random.click", 0.3F, ((Boolean) iblockdata.get(BlockLever.POWERED)).booleanValue() ? 0.6F : 0.5F);