1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
--- a/net/minecraft/world/level/block/LeverBlock.java
+++ b/net/minecraft/world/level/block/LeverBlock.java
@@ -27,6 +27,7 @@
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
public class LeverBlock extends FaceAttachedHorizontalDirectionalBlock {
@@ -104,11 +102,25 @@
return InteractionResult.SUCCESS;
} else {
- blockstate1 = this.pull(blockstate, level, blockpos);
- float f = (Boolean) blockstate1.getValue(LeverBlock.POWERED) ? 0.6F : 0.5F;
+ // CraftBukkit start - Interact Lever
+ boolean powered = state.getValue(LeverBlock.POWERED); // Old powered state
+ org.bukkit.block.Block block = level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
+ int old = (powered) ? 15 : 0;
+ int current = (!powered) ? 15 : 0;
- level.playSound((Player) null, blockpos, SoundEvents.LEVER_CLICK, SoundSource.BLOCKS, 0.3F, f);
- level.gameEvent((Entity) player, (Boolean) blockstate1.getValue(LeverBlock.POWERED) ? GameEvent.BLOCK_ACTIVATE : GameEvent.BLOCK_DEACTIVATE, blockpos);
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
+ level.getCraftServer().getPluginManager().callEvent(eventRedstone);
+
+ if ((eventRedstone.getNewCurrent() > 0) != (!powered)) {
+ return InteractionResult.SUCCESS;
+ }
+ // CraftBukkit end
+
+ iblockdata1 = this.pull(state, level, pos);
+ float f = (Boolean) iblockdata1.getValue(LeverBlock.POWERED) ? 0.6F : 0.5F;
+
+ level.playSound((Player) null, pos, SoundEvents.LEVER_CLICK, SoundSource.BLOCKS, 0.3F, f);
+ level.gameEvent((Entity) player, (Boolean) iblockdata1.getValue(LeverBlock.POWERED) ? GameEvent.BLOCK_ACTIVATE : GameEvent.BLOCK_DEACTIVATE, pos);
return InteractionResult.CONSUME;
}
}
|