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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
--- ../work/decompile-8eb82bde//net/minecraft/server/BlockRedstoneTorch.java 2014-11-28 17:43:42.949707438 +0000
+++ src/main/java/net/minecraft/server/BlockRedstoneTorch.java 2014-11-28 17:38:19.000000000 +0000
@@ -6,6 +6,8 @@
import java.util.Map;
import java.util.Random;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockRedstoneTorch extends BlockTorch {
private static Map b = Maps.newHashMap();
@@ -95,9 +97,26 @@
while (list != null && !list.isEmpty() && world.getTime() - ((RedstoneUpdateInfo) list.get(0)).b > 60L) {
list.remove(0);
}
+
+ // CraftBukkit start
+ org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ int oldCurrent = this.isOn ? 15 : 0;
+
+ BlockRedstoneEvent event = new BlockRedstoneEvent(block, oldCurrent, oldCurrent);
+ // CraftBukkit end
if (this.isOn) {
if (flag) {
+ // CraftBukkit start
+ if (oldCurrent != 0) {
+ event.setNewCurrent(0);
+ manager.callEvent(event);
+ if (event.getNewCurrent() != 0) {
+ return;
+ }
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, Blocks.UNLIT_REDSTONE_TORCH.getBlockData().set(BlockRedstoneTorch.FACING, iblockdata.get(BlockRedstoneTorch.FACING)), 3);
if (this.a(world, blockposition, true)) {
world.makeSound((double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.5F), (double) ((float) blockposition.getZ() + 0.5F), "random.fizz", 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F);
@@ -114,6 +133,16 @@
}
}
} else if (!flag && !this.a(world, blockposition, false)) {
+ // CraftBukkit start
+ if (oldCurrent != 15) {
+ event.setNewCurrent(15);
+ manager.callEvent(event);
+ if (event.getNewCurrent() != 15) {
+ return;
+ }
+ }
+ // CraftBukkit end
+
world.setTypeAndData(blockposition, Blocks.REDSTONE_TORCH.getBlockData().set(BlockRedstoneTorch.FACING, iblockdata.get(BlockRedstoneTorch.FACING)), 3);
}
|