2017-05-04 23:08:52 +00:00
From 27d2f7402fbcc5a781235180d7e34cea0e58de11 Mon Sep 17 00:00:00 2001
2016-03-29 02:04:43 +00:00
From: Aikar <aikar@aikar.co>
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
2017-03-25 05:22:02 +00:00
index 0a2823686..8eba70b01 100644
2016-03-29 02:04:43 +00:00
--- a/src/main/java/net/minecraft/server/BlockFlowing.java
+++ b/src/main/java/net/minecraft/server/BlockFlowing.java
2016-12-10 00:07:35 +00:00
@@ -96,6 +96,7 @@ public class BlockFlowing extends BlockFluids {
2016-03-29 02:04:43 +00:00
if (this.h(world, blockposition.down(), iblockdata2)) {
2016-12-10 00:07:35 +00:00
// CraftBukkit start
2016-03-29 02:04:43 +00:00
+ if (!canFlowTo(world, source, BlockFace.DOWN)) { return; } // Paper
BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN);
2016-12-10 00:07:35 +00:00
world.getServer().getPluginManager().callEvent(event);
2016-11-17 02:23:38 +00:00
@@ -136,6 +137,7 @@ public class BlockFlowing extends BlockFluids {
2016-03-29 02:04:43 +00:00
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));
2016-12-10 00:07:35 +00:00
world.getServer().getPluginManager().callEvent(event);
@@ -148,8 +150,14 @@ public class BlockFlowing extends BlockFluids {
2016-03-29 02:04:43 +00:00
}
+ // 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
2016-06-09 03:57:14 +00:00
if (iblockdata.getMaterial() != Material.AIR) {
2016-03-29 02:04:43 +00:00
if (this.material == Material.LAVA) {
this.fizz(world, blockposition);
--
2017-05-04 23:08:52 +00:00
2.12.2
2016-03-29 02:04:43 +00:00