diff --git a/Spigot-Server-Patches/0119-Prevent-Waterflow-BlockFromToEvent-from-loading-chun.patch b/Spigot-Server-Patches/0119-Prevent-Waterflow-BlockFromToEvent-from-loading-chun.patch new file mode 100644 index 0000000000..4e1a79da6d --- /dev/null +++ b/Spigot-Server-Patches/0119-Prevent-Waterflow-BlockFromToEvent-from-loading-chun.patch @@ -0,0 +1,52 @@ +From 7c816e1d8b983ebe5f4b22653c75160ea66477da Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Mon, 28 Mar 2016 22:03:09 -0400 +Subject: [PATCH] Prevent Waterflow BlockFromToEvent from loading chunks + +Many protection plugins would unintentionally trigger chunk loads +by calling .getToBlock() on an unloaded chunk, killing performance. + +Simply skip the event call. as CraftBukkit blocks changing the block +of unloaded chunks anyways. + +This keeps behavior consistent, vs inconsistent flowing based on plugin triggered loads. + +diff --git a/src/main/java/net/minecraft/server/BlockFlowing.java b/src/main/java/net/minecraft/server/BlockFlowing.java +index 51b80cb..0a3d673 100644 +--- a/src/main/java/net/minecraft/server/BlockFlowing.java ++++ b/src/main/java/net/minecraft/server/BlockFlowing.java +@@ -105,6 +105,7 @@ public class BlockFlowing extends BlockFluids { + IBlockData iblockdata2 = world.getType(blockposition.down()); + + if (this.h(world, blockposition.down(), iblockdata2)) { ++ if (!canFlowTo(world, source, BlockFace.DOWN)) { return; } // Paper + // CraftBukkit start - Send "down" to the server + BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN); + if (server != null) { +@@ -142,6 +143,7 @@ public class BlockFlowing extends BlockFluids { + EnumDirection enumdirection1 = (EnumDirection) iterator1.next(); + + // CraftBukkit start ++ if (!canFlowTo(world, source, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection1))) { continue; } // Paper + BlockFromToEvent event = new BlockFromToEvent(source, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection1)); + if (server != null) { + server.getPluginManager().callEvent(event); +@@ -156,8 +158,14 @@ public class BlockFlowing extends BlockFluids { + + } + ++ // Paper start ++ private boolean canFlowTo(World world, org.bukkit.block.Block source, BlockFace face) { ++ return source.getWorld().isChunkLoaded((source.getX() + face.getModX()) >> 4, (source.getZ() + face.getModZ()) >> 4); ++ } ++ // Paper end ++ + private void flow(World world, BlockPosition blockposition, IBlockData iblockdata, int i) { +- if (world.isLoaded(blockposition) && this.h(world, blockposition, iblockdata)) { // CraftBukkit - add isLoaded check ++ if (/*world.isLoaded(blockposition) &&*/ this.h(world, blockposition, iblockdata)) { // CraftBukkit - add isLoaded check // Paper - Already checked before we get here for isLoaded + if (iblockdata.getBlock() != Blocks.AIR) { + if (this.material == Material.LAVA) { + this.fizz(world, blockposition); +-- +2.7.4 +