Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
fix: Compatibility of fluid physics with CoreProtect
Browse files Browse the repository at this point in the history
  • Loading branch information
404Setup committed Oct 22, 2024
1 parent 640f52b commit e8081ac
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 53 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
- And some fixes from various places.
<br />

## Compatibility
- `CoreProtect` is incompatible with `feature.liquid-physics` (Generates an error, but does not cause the server to crash)

## Benchmark
I don't know

Expand Down
11 changes: 8 additions & 3 deletions patches/api/0005-Vine-Config.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Subject: [PATCH] Vine Config

diff --git a/src/main/java/one/tranic/vine/config/VineConfig.java b/src/main/java/one/tranic/vine/config/VineConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..fb5b6306efe79a7f7d5ba2fc8e4200997fd09621
index 0000000000000000000000000000000000000000..f10bcb077e93b4f9d491780de0d546c572ec0d07
--- /dev/null
+++ b/src/main/java/one/tranic/vine/config/VineConfig.java
@@ -0,0 +1,149 @@
@@ -0,0 +1,154 @@
+package one.tranic.vine.config;
+
+import one.tranic.vine.region.Compression;
Expand Down Expand Up @@ -47,7 +47,6 @@ index 0000000000000000000000000000000000000000..fb5b6306efe79a7f7d5ba2fc8e420099
+ // If the player is blocked on the top of the player's head, he will not try to rebirth the player on the ceiling.
+ public static boolean disableRespawnCeiling = false;
+ public static boolean flattenTriangularDistribution = false;
+ public static boolean liquidPhysics = false;
+ /**
+ * Switch to a 1024-bit secure seed to protect it from being cracked.
+ * Destroy the ambitions of those cheaters.
Expand All @@ -73,6 +72,12 @@ index 0000000000000000000000000000000000000000..fb5b6306efe79a7f7d5ba2fc8e420099
+ public static boolean fireworks = false;
+ }
+
+ public static class liquidPhysics {
+ public static boolean base = false;
+ // Allow explosions underwater
+ public static boolean aeu = false;
+ }
+
+ public static class Region {
+ // Support: ANVIL (Vanilla), LINEAR, SECTORFILE
+ public static Format format = Format.ANVIL;
Expand Down
34 changes: 30 additions & 4 deletions patches/server/0011-Vine-Config-Feature.patch
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,34 @@ index 0000000000000000000000000000000000000000..657642f146baea146e6b2274052eb76a
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/one/tranic/vine/config/module/feature/LiquidPhysics.kt b/src/main/kotlin/one/tranic/vine/config/module/feature/LiquidPhysics.kt
new file mode 100644
index 0000000000000000000000000000000000000000..3e1b0a8928b6703fcaffef38476a66e090650841
--- /dev/null
+++ b/src/main/kotlin/one/tranic/vine/config/module/feature/LiquidPhysics.kt
@@ -0,0 +1,21 @@
+package one.tranic.vine.config.module.feature
+
+import one.tranic.vine.config.VineConfig.Feature
+import one.tranic.vine.config.impl.ConfigImpl
+import one.tranic.vine.config.util.ConfigHelper
+
+object LiquidPhysics : ConfigImpl, ConfigHelper() {
+ private const val BASEPATH = "feature.liquid-physics"
+ override fun default() {
+ addDefault("$BASEPATH.base", false)
+ addDefault("$BASEPATH.aeu", false, "Allow explosions to destroy fluids")
+ addComment(BASEPATH, "The new liquid physics system may affect some mechanisms.")
+ }
+
+ override fun load() {
+ Feature.liquidPhysics.base = getBoolean("$BASEPATH.base")
+ Feature.liquidPhysics.aeu = getBoolean("$BASEPATH.aeu")
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/main/kotlin/one/tranic/vine/config/module/feature/PlayerProfile.kt b/src/main/kotlin/one/tranic/vine/config/module/feature/PlayerProfile.kt
new file mode 100644
index 0000000000000000000000000000000000000000..4c9654fd67f8b68a30af044b0886e146412cf34b
Expand Down Expand Up @@ -161,10 +189,10 @@ index 0000000000000000000000000000000000000000..0beda6c4679b93cdde58c58cd5b69e86
\ No newline at end of file
diff --git a/src/main/kotlin/one/tranic/vine/config/module/feature/Value.kt b/src/main/kotlin/one/tranic/vine/config/module/feature/Value.kt
new file mode 100644
index 0000000000000000000000000000000000000000..782e236848d0d684750f152b28df1ef145227b54
index 0000000000000000000000000000000000000000..7853408d6788116deb8822721c325dc9f958b63c
--- /dev/null
+++ b/src/main/kotlin/one/tranic/vine/config/module/feature/Value.kt
@@ -0,0 +1,59 @@
@@ -0,0 +1,57 @@
+package one.tranic.vine.config.module.feature
+
+import one.tranic.vine.config.VineConfig.Feature
Expand Down Expand Up @@ -193,7 +221,6 @@ index 0000000000000000000000000000000000000000..782e236848d0d684750f152b28df1ef1
+ "With that edge cases are more likely to happen"
+ )
+ )
+ addDefault("feature.liquid-physics", false, "The new liquid physics system may affect some mechanisms.")
+ addDefault(
+ "feature.secure-seed", false, listOf(
+ "Changes the seed from 64bit to 1024bit, this will strictly secure your seed,",
Expand All @@ -211,7 +238,6 @@ index 0000000000000000000000000000000000000000..782e236848d0d684750f152b28df1ef1
+ Feature.disableSpark = getBoolean("feature.disable-spark")
+ Feature.disableRespawnCeiling = getBoolean("feature.disable-respawn-ceiling")
+ Feature.flattenTriangularDistribution = getBoolean("feature.flatten-triangular-distribution")
+ Feature.liquidPhysics = getBoolean("feature.liquid-physics")
+ getBoolean("feature.secure-seed") {
+ if (Locker.secureSeed == null) {
+ Feature.secureSeed = it
Expand Down
38 changes: 19 additions & 19 deletions patches/server/0122-Kiterino-New-liquid-physics.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Subject: [PATCH] Kiterino: New liquid physics
You can find the original code on https://github.com/SoSeDiKs-Universe/Kiterino

diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
index ca5d3e0dd4da0aab64a566e6facd8492a166f323..c40bd571195e5a094bee9bbc429c1663cf99fdf7 100644
index ca5d3e0dd4da0aab64a566e6facd8492a166f323..07e63d2bd79e80c20d1d1f402b1b3d766881608d 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
@@ -616,6 +616,7 @@ public class Boat extends VehicleEntity implements VariantHolder<Boat.Type> {
int j = Mth.ceil(axisalignedbb.maxX);
int k = Mth.floor(axisalignedbb.minY);
int l = Mth.ceil(axisalignedbb.minY + 0.001D);
+ if (one.tranic.vine.config.VineConfig.Feature.liquidPhysics) l++; // Vine - Kiterino extra height
+ if (one.tranic.vine.config.VineConfig.Feature.liquidPhysics.base) l++; // Vine - Kiterino extra height
int i1 = Mth.floor(axisalignedbb.minZ);
int j1 = Mth.ceil(axisalignedbb.maxZ);
boolean flag = false;
Expand All @@ -22,32 +22,32 @@ index ca5d3e0dd4da0aab64a566e6facd8492a166f323..c40bd571195e5a094bee9bbc429c1663
if (fluid.is(FluidTags.WATER) && d0 < (double) ((float) blockposition_mutableblockposition.getY() + fluid.getHeight(this.level(), blockposition_mutableblockposition))) {
if (!fluid.isSource()) {
- return Boat.Status.UNDER_FLOWING_WATER;
+ return one.tranic.vine.config.VineConfig.Feature.liquidPhysics ? Boat.Status.UNDER_FLOWING_WATER : (fluid.getAmount() == 8 ? Boat.Status.UNDER_FLOWING_WATER : Boat.Status.IN_WATER); // Vine - Kiterino Do not sink boats in flowing water
+ return one.tranic.vine.config.VineConfig.Feature.liquidPhysics.base ? Boat.Status.UNDER_FLOWING_WATER : (fluid.getAmount() == 8 ? Boat.Status.UNDER_FLOWING_WATER : Boat.Status.IN_WATER); // Vine - Kiterino Do not sink boats in flowing water
}

flag = true;
diff --git a/src/main/java/net/minecraft/world/level/block/Blocks.java b/src/main/java/net/minecraft/world/level/block/Blocks.java
index ce639e4a2d87202a10ef4fc73274c4b2c4e95720..793cfa19bd8ca96239683f0f269accd2db03a062 100644
index ce639e4a2d87202a10ef4fc73274c4b2c4e95720..c2dc94cee4e1610654d6856d382cfb3e73e1b956 100644
--- a/src/main/java/net/minecraft/world/level/block/Blocks.java
+++ b/src/main/java/net/minecraft/world/level/block/Blocks.java
@@ -347,7 +347,7 @@ public class Blocks {
.replaceable()
.noCollission()
.strength(100.0F)
- .pushReaction(PushReaction.DESTROY)
+ .pushReaction(one.tranic.vine.config.VineConfig.Feature.liquidPhysics ? PushReaction.PUSH_ONLY : PushReaction.DESTROY) // Vine - Kiterino pushable water
+ .pushReaction(one.tranic.vine.config.VineConfig.Feature.liquidPhysics.base ? PushReaction.PUSH_ONLY : PushReaction.DESTROY) // Vine - Kiterino pushable water
.noLootTable()
.liquid()
.sound(SoundType.EMPTY)
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
index e0c62227b279a5fe0f3868fbf9ce8c78c515a09c..79a1ed3b7e38d1addb611d464be9e3cb40d6ff7f 100644
index e0c62227b279a5fe0f3868fbf9ce8c78c515a09c..1c2b960d6d4213f2ff0ef6853523703b7ae10a13 100644
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
@@ -313,6 +313,20 @@ public class PistonBaseBlock extends DirectionalBlock {
}

public static boolean isPushable(BlockState state, Level world, BlockPos pos, Direction direction, boolean canBreak, Direction pistonDir) {
+ if (one.tranic.vine.config.VineConfig.Feature.liquidPhysics) {
+ if (one.tranic.vine.config.VineConfig.Feature.liquidPhysics.base) {
+ // Vine start - Kiterino New liquid physics
+ net.minecraft.world.level.material.FluidState fluidState = state.getFluidState();
+ if (!fluidState.isEmpty() && fluidState.isSourceOfType(net.minecraft.world.level.material.Fluids.WATER)) {
Expand All @@ -68,7 +68,7 @@ index e0c62227b279a5fe0f3868fbf9ce8c78c515a09c..79a1ed3b7e38d1addb611d464be9e3cb
}
// CraftBukkit end

+ if (one.tranic.vine.config.VineConfig.Feature.liquidPhysics) {
+ if (one.tranic.vine.config.VineConfig.Feature.liquidPhysics.base) {
+ // Kiterino start
+ Direction oppositeDir = dir.getOpposite();
+
Expand Down Expand Up @@ -112,15 +112,15 @@ index e0c62227b279a5fe0f3868fbf9ce8c78c515a09c..79a1ed3b7e38d1addb611d464be9e3cb
int j;
BlockState iblockdata1;
diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/SpringFeature.java b/src/main/java/net/minecraft/world/level/levelgen/feature/SpringFeature.java
index 72c7179ea7743c67f2489573c0e886f20871fe60..8c90c1d15811444c2edd0eb1b9e05b6b08b52672 100644
index 72c7179ea7743c67f2489573c0e886f20871fe60..c5ae32e6eede98430cdf4566b3b68a7e9df5939c 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/SpringFeature.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/feature/SpringFeature.java
@@ -69,7 +69,28 @@ public class SpringFeature extends Feature<SpringConfiguration> {
}

if (j == springConfiguration.rockCount && k == springConfiguration.holeCount) {
- worldGenLevel.setBlock(blockPos, springConfiguration.state.createLegacyBlock(), 2);
+ if (one.tranic.vine.config.VineConfig.Feature.liquidPhysics) {
+ if (one.tranic.vine.config.VineConfig.Feature.liquidPhysics.base) {
+ // Vine start - Kiterino make water springs out of corals and spawn magma block next to lava, so they could persist the fluid physics changes
+ BlockState springState;
+ if (springConfiguration.state.is(net.minecraft.world.level.material.Fluids.WATER)) {
Expand All @@ -146,15 +146,15 @@ index 72c7179ea7743c67f2489573c0e886f20871fe60..8c90c1d15811444c2edd0eb1b9e05b6b
i++;
}
diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
index 16f1ed279fb05d47d97692f26d083683dd942dc4..9780df3f4cacb305ee6cb95f1c3bcbf9bfc4489d 100644
index 16f1ed279fb05d47d97692f26d083683dd942dc4..e413226becf02d3a710e1d79a28e4074cb27e159 100644
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
@@ -227,7 +227,11 @@ public abstract class FlowingFluid extends Fluid {
}
}

- if (this.canConvertToSource(world) && j >= getRequiredSources(world)) {
+ boolean b1 = one.tranic.vine.config.VineConfig.Feature.liquidPhysics ?
+ boolean b1 = one.tranic.vine.config.VineConfig.Feature.liquidPhysics.base ?
+ (this.canConvertToSource(world, pos) && j >= getRequiredSources(world)):
+ (this.canConvertToSource(world) && j >= getRequiredSources(world));
+
Expand All @@ -166,7 +166,7 @@ index 16f1ed279fb05d47d97692f26d083683dd942dc4..9780df3f4cacb305ee6cb95f1c3bcbf9
VoxelShape voxelshape1 = fromState.getCollisionShape(world, fromPos);
boolean flag = !Shapes.mergedFaceOccludes(voxelshape, voxelshape1, face);

+ if (one.tranic.vine.config.VineConfig.Feature.liquidPhysics) {
+ if (one.tranic.vine.config.VineConfig.Feature.liquidPhysics.base) {
+ // Vine start
+ if (!flag) {
+ if (state.is(BlockTags.LEAVES)) {
Expand Down Expand Up @@ -202,7 +202,7 @@ index 16f1ed279fb05d47d97692f26d083683dd942dc4..9780df3f4cacb305ee6cb95f1c3bcbf9
+ // Vine end
+
protected void spreadTo(LevelAccessor world, BlockPos pos, BlockState state, Direction direction, FluidState fluidState) {
+ if (one.tranic.vine.config.VineConfig.Feature.liquidPhysics && flowTo(world, pos, state, direction)) return; // Kiterino
+ if (one.tranic.vine.config.VineConfig.Feature.liquidPhysics.base && flowTo(world, pos, state, direction)) return; // Kiterino
if (state.getBlock() instanceof LiquidBlockContainer) {
((LiquidBlockContainer) state.getBlock()).placeLiquid(world, pos, state, fluidState);
} else {
Expand Down Expand Up @@ -383,7 +383,7 @@ index 16f1ed279fb05d47d97692f26d083683dd942dc4..9780df3f4cacb305ee6cb95f1c3bcbf9
}

protected boolean canSpreadTo(BlockGetter world, BlockPos fluidPos, BlockState fluidBlockState, Direction flowDirection, BlockPos flowTo, BlockState flowToBlockState, FluidState fluidState, Fluid fluid) {
+ if (one.tranic.vine.config.VineConfig.Feature.liquidPhysics && canFlowTo(world, flowDirection, flowTo, flowToBlockState, fluidState)) return true; // Vine
+ if (one.tranic.vine.config.VineConfig.Feature.liquidPhysics.base && canFlowTo(world, flowDirection, flowTo, flowToBlockState, fluidState)) return true; // Vine
return fluidState.canBeReplacedWith(world, flowTo, fluid, flowDirection) && this.canPassThroughWall(flowDirection, world, fluidPos, fluidBlockState, flowTo, flowToBlockState) && this.canHoldFluid(world, flowTo, flowToBlockState, fluid);
}

Expand Down Expand Up @@ -451,26 +451,26 @@ index 16f1ed279fb05d47d97692f26d083683dd942dc4..9780df3f4cacb305ee6cb95f1c3bcbf9

protected int getSpreadDelay(Level world, BlockPos pos, FluidState oldState, FluidState newState) {
diff --git a/src/main/java/net/minecraft/world/level/material/WaterFluid.java b/src/main/java/net/minecraft/world/level/material/WaterFluid.java
index 9dcdb2f4001115db0c26fdbf86531dbe6098485d..4971cc45d95ae6b8aac8daad2888168e28941ea0 100644
index 9dcdb2f4001115db0c26fdbf86531dbe6098485d..cc18fd04041966d86614374eccdcbffd273d80b0 100644
--- a/src/main/java/net/minecraft/world/level/material/WaterFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/WaterFluid.java
@@ -77,9 +77,32 @@ public abstract class WaterFluid extends FlowingFluid {

@Override
protected boolean canConvertToSource(Level world) {
- return world.getGameRules().getBoolean(GameRules.RULE_WATER_SOURCE_CONVERSION);
+ return !one.tranic.vine.config.VineConfig.Feature.liquidPhysics && world.getGameRules().getBoolean(GameRules.RULE_WATER_SOURCE_CONVERSION); // Vine - Kiterino - Don't convert to source
+ return !one.tranic.vine.config.VineConfig.Feature.liquidPhysics.base && world.getGameRules().getBoolean(GameRules.RULE_WATER_SOURCE_CONVERSION); // Vine - Kiterino - Don't convert to source
}

+ // Vine start
+ @Override
+ protected boolean canConvertToSource(Level world, BlockPos pos) {
+ return one.tranic.vine.config.VineConfig.Feature.liquidPhysics ? (isInInfiniteBiome(world, pos) || canConvertToSource(world)) : super.canConvertToSource(world, pos);
+ return one.tranic.vine.config.VineConfig.Feature.liquidPhysics.base ? (isInInfiniteBiome(world, pos) || canConvertToSource(world)) : super.canConvertToSource(world, pos);
+ }
+
+ @Override
+ protected boolean isUnfillableInBiome(Fluid fluid, LevelReader world, BlockPos flowTo) {
+ return one.tranic.vine.config.VineConfig.Feature.liquidPhysics ? isInInfiniteBiome(world, flowTo) : super.isUnfillableInBiome(fluid, world, flowTo);
+ return one.tranic.vine.config.VineConfig.Feature.liquidPhysics.base ? isInInfiniteBiome(world, flowTo) : super.isUnfillableInBiome(fluid, world, flowTo);
+ }
+
+ private boolean isInInfiniteBiome(LevelReader world, BlockPos pos) {
Expand Down
Loading

0 comments on commit e8081ac

Please sign in to comment.