3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-23 23:00:08 +01:00
Paper/nms-patches/BlockRedstoneTorch.patch
2019-04-23 12:00:00 +10:00

53 Zeilen
2.1 KiB
Diff

--- a/net/minecraft/server/BlockRedstoneTorch.java
+++ b/net/minecraft/server/BlockRedstoneTorch.java
@@ -6,6 +6,8 @@
import java.util.Random;
import java.util.WeakHashMap;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockRedstoneTorch extends BlockTorch {
public static final BlockStateBoolean LIT = BlockProperties.r;
@@ -70,8 +72,24 @@
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 = ((Boolean) iblockdata.get(BlockRedstoneTorch.LIT)).booleanValue() ? 15 : 0;
+
+ BlockRedstoneEvent event = new BlockRedstoneEvent(block, oldCurrent, oldCurrent);
+ // CraftBukkit end
if ((Boolean) iblockdata.get(BlockRedstoneTorch.LIT)) {
if (flag) {
+ // CraftBukkit start
+ if (oldCurrent != 0) {
+ event.setNewCurrent(0);
+ manager.callEvent(event);
+ if (event.getNewCurrent() != 0) {
+ return;
+ }
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneTorch.LIT, false), 3);
if (a(world, blockposition, true)) {
world.triggerEffect(1502, blockposition, 0);
@@ -79,6 +97,15 @@
}
}
} else if (!flag && !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, (IBlockData) iblockdata.set(BlockRedstoneTorch.LIT, true), 3);
}