From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Byteflux Date: Wed, 8 Aug 2018 16:33:21 -0600 Subject: [PATCH] Configurable speed for water flowing over lava diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java index 661694da6cfbed5e3e26de2355e67a5a6d17a3fc..37bd28f18d3f48767d8141bde3395b8443d5650a 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -394,4 +394,10 @@ public class PaperWorldConfig { this.armorStandTick = this.getBoolean("armor-stands-tick", this.armorStandTick); log("ArmorStand ticking is " + (this.armorStandTick ? "enabled" : "disabled") + " by default"); } + + public int waterOverLavaFlowSpeed; + private void waterOverLavaFlowSpeed() { + waterOverLavaFlowSpeed = getInt("water-over-lava-flow-speed", 5); + log("Water over lava flow speed: " + waterOverLavaFlowSpeed); + } } diff --git a/src/main/java/net/minecraft/server/BlockFluids.java b/src/main/java/net/minecraft/server/BlockFluids.java index f00b403e1e12acbb8eb6ad55da219b257219a8f4..a28ac8b00b22a8c7afc2b64f9720a4e32b653e5f 100644 --- a/src/main/java/net/minecraft/server/BlockFluids.java +++ b/src/main/java/net/minecraft/server/BlockFluids.java @@ -76,11 +76,28 @@ public class BlockFluids extends Block implements IFluidSource { @Override public void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag) { if (this.a(world, blockposition, iblockdata)) { - world.getFluidTickList().a(blockposition, iblockdata.getFluid().getType(), this.b.a((IWorldReader) world)); + world.getFluidTickList().a(blockposition, iblockdata.getFluid().getType(), this.getFlowSpeed(world, blockposition)); // Paper } } + // Paper start - Get flow speed. Throttle if its water and flowing adjacent to lava + public int getFlowSpeed(World world, BlockPosition blockposition) { + if (this.material == Material.WATER) { + if ( + world.getMaterialIfLoaded(blockposition.north(1)) == Material.LAVA || + world.getMaterialIfLoaded(blockposition.south(1)) == Material.LAVA || + world.getMaterialIfLoaded(blockposition.west(1)) == Material.LAVA || + world.getMaterialIfLoaded(blockposition.east(1)) == Material.LAVA + ) { + return world.paperConfig.waterOverLavaFlowSpeed; + } + } + return this.b.a(world); + } + // Paper end + + @Override public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { if (iblockdata.getFluid().isSource() || iblockdata1.getFluid().isSource()) { @@ -93,7 +110,7 @@ public class BlockFluids extends Block implements IFluidSource { @Override public void doPhysics(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) { if (this.a(world, blockposition, iblockdata)) { - world.getFluidTickList().a(blockposition, iblockdata.getFluid().getType(), this.b.a((IWorldReader) world)); + world.getFluidTickList().a(blockposition, iblockdata.getFluid().getType(), this.getFlowSpeed(world, blockposition)); // Paper } }