0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git synced 2024-11-22 08:56:16 +00:00
craftbukkit/nms-patches/net/minecraft/world/level/redstone/NeighborUpdater.patch
2024-10-23 02:15:00 +11:00

35 lines
1.5 KiB
Diff

--- a/net/minecraft/world/level/redstone/NeighborUpdater.java
+++ b/net/minecraft/world/level/redstone/NeighborUpdater.java
@@ -13,6 +13,13 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.IBlockData;
+// CraftBukkit start
+import net.minecraft.server.level.WorldServer;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.block.data.CraftBlockData;
+import org.bukkit.event.block.BlockPhysicsEvent;
+// CraftBukkit end
public interface NeighborUpdater {
@@ -50,6 +57,17 @@
static void executeUpdate(World world, IBlockData iblockdata, BlockPosition blockposition, Block block, @Nullable Orientation orientation, boolean flag) {
try {
+ // CraftBukkit start
+ CraftWorld cworld = ((WorldServer) world).getWorld();
+ if (cworld != null) {
+ BlockPhysicsEvent event = new BlockPhysicsEvent(CraftBlock.at(world, blockposition), CraftBlockData.fromData(iblockdata));
+ ((WorldServer) world).getCraftServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+ }
+ // CraftBukkit end
iblockdata.handleNeighborChanged(world, blockposition, block, orientation, flag);
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception while updating neighbours");