From daa5c1f5cb2e8e59447405e178159a81d8ccbde9 Mon Sep 17 00:00:00 2001 From: Samsuik Date: Thu, 20 Feb 2025 16:46:08 +0000 Subject: [PATCH] Configure fluids flowing through the world border --- .../0016-Configure-cannon-physics.patch | 8 +++---- .../0020-Legacy-lava-block-formation.patch | 4 ++-- .../world/level/block/LiquidBlock.java.patch | 12 ++++++++++ .../level/material/FlowingFluid.java.patch | 22 +++++++++++++++++-- .../configuration/WorldConfiguration.java | 1 + 5 files changed, 39 insertions(+), 8 deletions(-) diff --git a/sakura-server/minecraft-patches/features/0016-Configure-cannon-physics.patch b/sakura-server/minecraft-patches/features/0016-Configure-cannon-physics.patch index 34fdfe6..2c975be 100644 --- a/sakura-server/minecraft-patches/features/0016-Configure-cannon-physics.patch +++ b/sakura-server/minecraft-patches/features/0016-Configure-cannon-physics.patch @@ -650,12 +650,12 @@ index 352aa47ba6d4e434bcf2af8e70c5abcb734056eb..c615d4fa56d9237f9b71800ee77f6be2 case NORTH: // Sakura start - protect block shapes against plugins diff --git a/net/minecraft/world/level/block/LiquidBlock.java b/net/minecraft/world/level/block/LiquidBlock.java -index 78aa0ae9ce937b7232eac1d65fd987c21489979d..e719be50ff73610046696a21053671332951ca9c 100644 +index fa94f79349483b3ad3676183fa9ee22dabd803df..b9b9f1a47cba3c72a306ec54896690701b76d34d 100644 --- a/net/minecraft/world/level/block/LiquidBlock.java +++ b/net/minecraft/world/level/block/LiquidBlock.java -@@ -190,7 +190,20 @@ public class LiquidBlock extends Block implements BucketPickup { - for (Direction direction : POSSIBLE_FLOW_DIRECTIONS) { - BlockPos blockPos = pos.relative(direction.getOpposite()); +@@ -195,7 +195,20 @@ public class LiquidBlock extends Block implements BucketPickup { + } + // Sakura end - configure fluid ticking outside the world border if (level.getFluidState(blockPos).is(FluidTags.WATER)) { - Block block = level.getFluidState(pos).isSource() ? Blocks.OBSIDIAN : Blocks.COBBLESTONE; + // Sakura start - configure cannon physics diff --git a/sakura-server/minecraft-patches/features/0020-Legacy-lava-block-formation.patch b/sakura-server/minecraft-patches/features/0020-Legacy-lava-block-formation.patch index 5c0a986..e8ccab3 100644 --- a/sakura-server/minecraft-patches/features/0020-Legacy-lava-block-formation.patch +++ b/sakura-server/minecraft-patches/features/0020-Legacy-lava-block-formation.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Legacy lava block formation diff --git a/net/minecraft/world/level/block/LiquidBlock.java b/net/minecraft/world/level/block/LiquidBlock.java -index e719be50ff73610046696a21053671332951ca9c..b096ef72d5a2e9b931be85dda4dc41673229d57f 100644 +index b9b9f1a47cba3c72a306ec54896690701b76d34d..7dd5908068346efa7cd566657cc64d7ee42fc9eb 100644 --- a/net/minecraft/world/level/block/LiquidBlock.java +++ b/net/minecraft/world/level/block/LiquidBlock.java -@@ -194,7 +194,14 @@ public class LiquidBlock extends Block implements BucketPickup { +@@ -199,7 +199,14 @@ public class LiquidBlock extends Block implements BucketPickup { final FluidState fluidState = state.getFluidState(); final Block block = fluidState.isSource() ? Blocks.OBSIDIAN : Blocks.COBBLESTONE; if (block == Blocks.COBBLESTONE) { diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/level/block/LiquidBlock.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/level/block/LiquidBlock.java.patch index 2966266..00120b6 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/level/block/LiquidBlock.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/level/block/LiquidBlock.java.patch @@ -18,3 +18,15 @@ } private static boolean isLava(Level level, BlockPos pos) { final FluidState fluidState = level.getFluidIfLoaded(pos); +@@ -189,6 +_,11 @@ + + for (Direction direction : POSSIBLE_FLOW_DIRECTIONS) { + BlockPos blockPos = pos.relative(direction.getOpposite()); ++ // Sakura start - configure fluid ticking outside the world border ++ if (level.sakuraConfig().environment.disableFluidsFlowingThroughTheWorldBorder && !level.getWorldBorder().isWithinBounds(blockPos)) { ++ continue; ++ } ++ // Sakura end - configure fluid ticking outside the world border + if (level.getFluidState(blockPos).is(FluidTags.WATER)) { + Block block = level.getFluidState(pos).isSource() ? Blocks.OBSIDIAN : Blocks.COBBLESTONE; + // CraftBukkit start diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/level/material/FlowingFluid.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/level/material/FlowingFluid.java.patch index 4f9a9d5..f36b3f1 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/level/material/FlowingFluid.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/level/material/FlowingFluid.java.patch @@ -1,6 +1,12 @@ --- a/net/minecraft/world/level/material/FlowingFluid.java +++ b/net/minecraft/world/level/material/FlowingFluid.java -@@ -157,7 +_,7 @@ +@@ -152,12 +_,12 @@ + } + + protected void spread(ServerLevel level, BlockPos pos, BlockState blockState, FluidState fluidState) { +- if (!fluidState.isEmpty()) { ++ if (!fluidState.isEmpty() && (!level.sakuraConfig().environment.disableFluidsFlowingThroughTheWorldBorder || level.getWorldBorder().isWithinBounds(pos))) { // Sakura - configure fluids flowing through the world border + BlockPos blockPos = pos.below(); BlockState blockState1 = level.getBlockState(blockPos); FluidState fluidState1 = blockState1.getFluidState(); if (this.canMaybePassThrough(level, pos, blockState, Direction.DOWN, blockPos, blockState1, fluidState1)) { @@ -9,6 +15,18 @@ Fluid type = newLiquid.getType(); if (fluidState1.canBeReplacedWith(level, blockPos, type, Direction.DOWN) && canHoldSpecificFluid(level, blockPos, blockState1, type)) { // CraftBukkit start +@@ -199,6 +_,11 @@ + BlockPos blockPos = pos.relative(direction); + final BlockState blockStateIfLoaded = level.getBlockStateIfLoaded(blockPos); // Paper - Prevent chunk loading from fluid flowing + if (blockStateIfLoaded == null) continue; // Paper - Prevent chunk loading from fluid flowing ++ // Sakura start - configure fluids flowing through the world border ++ if (level.sakuraConfig().environment.disableFluidsFlowingThroughTheWorldBorder && !level.getWorldBorder().isWithinBounds(blockPos)) { ++ continue; ++ } ++ // Sakura end - configure fluids flowing through the world border + // CraftBukkit start + org.bukkit.block.Block source = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); + org.bukkit.event.block.BlockFromToEvent event = new org.bukkit.event.block.BlockFromToEvent(source, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(direction)); @@ -214,6 +_,23 @@ } @@ -29,7 +47,7 @@ + } + + private FluidState getLiquidFromSurroundings(final ServerLevel level, final BlockPos pos, final BlockState state) { -+ // Sakura start - optimise new liquid level ++ // Sakura end - optimise new liquid level int i = 0; int i1 = 0; BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); diff --git a/sakura-server/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java b/sakura-server/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java index 30f8308..671acdd 100644 --- a/sakura-server/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java +++ b/sakura-server/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java @@ -215,6 +215,7 @@ public final class WorldConfiguration extends ConfigurationPart { public class Environment extends ConfigurationPart { public boolean allowWaterInTheNether = false; public boolean disableFastNetherLava = false; + public boolean disableFluidsFlowingThroughTheWorldBorder = false; public BlockGeneration blockGeneration = new BlockGeneration(); public class BlockGeneration extends ConfigurationPart {