Paper/nms-patches/BlockRedstoneTorch.patch

63 lines
2.7 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/BlockRedstoneTorch.java
+++ b/net/minecraft/server/BlockRedstoneTorch.java
2016-05-10 13:47:39 +02:00
@@ -7,6 +7,8 @@
import java.util.Random;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockRedstoneTorch extends BlockTorch {
2016-06-09 03:43:49 +02:00
private static final Map<World, List<BlockRedstoneTorch.RedstoneUpdateInfo>> g = Maps.newHashMap();
2016-05-10 13:47:39 +02:00
@@ -14,7 +16,7 @@
2015-02-26 23:41:06 +01:00
private boolean a(World world, BlockPosition blockposition, boolean flag) {
2016-02-29 22:32:46 +01:00
if (!BlockRedstoneTorch.g.containsKey(world)) {
- BlockRedstoneTorch.g.put(world, Lists.newArrayList());
+ BlockRedstoneTorch.g.put(world, Lists.<BlockRedstoneTorch.RedstoneUpdateInfo>newArrayList()); // CraftBukkit - fix decompile error
2015-02-26 23:41:06 +01:00
}
2016-02-29 22:32:46 +01:00
List list = (List) BlockRedstoneTorch.g.get(world);
2016-05-10 13:47:39 +02:00
@@ -97,8 +99,25 @@
list.remove(0);
}
2015-02-26 23:41:06 +01:00
+ // 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
2015-02-26 23:41:06 +01:00
+
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)) {
2016-06-09 03:43:49 +02:00
world.a((EntityHuman) null, blockposition, SoundEffects.eR, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F);
2016-05-10 13:47:39 +02:00
@@ -115,6 +134,15 @@
}
}
} 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);
}