From c1349b300c8ee0eca2c0d731154632caf02a5a38 Mon Sep 17 00:00:00 2001 From: AlphaKR93 Date: Tue, 7 Nov 2023 15:34:12 +0900 Subject: [PATCH] Configurable cave lava sea level, Fix MC-237017 --- .../server/0006-Plazma-Configurations.patch | 4 +- ...7-Setup-basic-configuration-sections.patch | 11 +++- .../server/0011-Tweak-console-logging.patch | 4 +- .../0017-Reduce-create-random-instance.patch | 4 +- ...LootTable-for-non-player-interaction.patch | 4 +- ...027-Configurable-cave-lava-sea-level.patch | 57 +++++++++++++++++++ 6 files changed, 74 insertions(+), 10 deletions(-) create mode 100644 patches/server/0027-Configurable-cave-lava-sea-level.patch diff --git a/patches/server/0006-Plazma-Configurations.patch b/patches/server/0006-Plazma-Configurations.patch index aab7836c6..24dafe585 100644 --- a/patches/server/0006-Plazma-Configurations.patch +++ b/patches/server/0006-Plazma-Configurations.patch @@ -784,7 +784,7 @@ index 0000000000000000000000000000000000000000..261734da470664d55d831c801e1e297f +} diff --git a/src/main/java/org/plazmamc/plazma/configurations/PlazmaConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/PlazmaConfigurations.java new file mode 100644 -index 0000000000000000000000000000000000000000..3ae690dfdd0fe3a74418d236805e4af086ddac24 +index 0000000000000000000000000000000000000000..aa92a326ab5456396e783b163457676bfc59697e --- /dev/null +++ b/src/main/java/org/plazmamc/plazma/configurations/PlazmaConfigurations.java @@ -0,0 +1,275 @@ @@ -839,7 +839,7 @@ index 0000000000000000000000000000000000000000..3ae690dfdd0fe3a74418d236805e4af0 +@DefaultQualifier(NonNull.class) +public class PlazmaConfigurations extends Configurations { + -+ private static final Logger LOGGER = LogUtils.getLogger(); ++ static final Logger LOGGER = LogUtils.getLogger(); + static final String GLOBAL_CONFIG_FILE_NAME = "plazma-global.yml"; + static final String WORLD_DEFAULTS_CONFIG_FILE_NAME = "plazma-world-defaults.yml"; + static final String WORLD_CONFIG_FILE_NAME = "plazma-world.yml"; diff --git a/patches/server/0007-Setup-basic-configuration-sections.patch b/patches/server/0007-Setup-basic-configuration-sections.patch index 930b55a3d..55eae3626 100644 --- a/patches/server/0007-Setup-basic-configuration-sections.patch +++ b/patches/server/0007-Setup-basic-configuration-sections.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Setup basic configuration sections diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -index 261734da470664d55d831c801e1e297fa057a7f4..902c68c78599fdce42c02ce9d93988d1266a7553 100644 +index 261734da470664d55d831c801e1e297fa057a7f4..7d0d595a87308316a3ae57c0fafc3faa7d96aeea 100644 --- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -@@ -26,4 +26,16 @@ public class GlobalConfiguration extends ConfigurationPart { +@@ -26,4 +26,23 @@ public class GlobalConfiguration extends ConfigurationPart { @Setting(Configuration.VERSION_FIELD) int version = VERSION; @@ -18,6 +18,13 @@ index 261734da470664d55d831c801e1e297fa057a7f4..902c68c78599fdce42c02ce9d93988d1 + + } + ++ @Setting("world-generation") ++ public WorldGeneration worldgen; ++ public class WorldGeneration extends ConfigurationPart { ++ ++ ++ } ++ + public Miscellaneous misc; + public class Miscellaneous extends ConfigurationPart { + diff --git a/patches/server/0011-Tweak-console-logging.patch b/patches/server/0011-Tweak-console-logging.patch index 016e720cf..e0704d0f3 100644 --- a/patches/server/0011-Tweak-console-logging.patch +++ b/patches/server/0011-Tweak-console-logging.patch @@ -77,10 +77,10 @@ index 50720000069a4914c11ef5c402a39c469966196f..58a889fd517698c02a9f13f6018d761c this.server.logChatMessage((unsignedFunction == null ? message.decoratedContent() : unsignedFunction.apply(this.server.console)), params, flag ? null : "Not Secure"); // Paper OutgoingChatMessage outgoingchatmessage = OutgoingChatMessage.create(message); diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -index 902c68c78599fdce42c02ce9d93988d1266a7553..a9a15db9429b3ac08ffff4964bd32f4f3b7127be 100644 +index 7d0d595a87308316a3ae57c0fafc3faa7d96aeea..da2eb2d437fe255801316604a0b8d0c9cc4fb576 100644 --- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -@@ -38,4 +38,13 @@ public class GlobalConfiguration extends ConfigurationPart { +@@ -45,4 +45,13 @@ public class GlobalConfiguration extends ConfigurationPart { } diff --git a/patches/server/0017-Reduce-create-random-instance.patch b/patches/server/0017-Reduce-create-random-instance.patch index fb9c2ce5d..d85f4e0c8 100644 --- a/patches/server/0017-Reduce-create-random-instance.patch +++ b/patches/server/0017-Reduce-create-random-instance.patch @@ -331,10 +331,10 @@ index 6cfdf5a745256774c714d201604d06ff1c7adf7a..78e7583bca7570520264ff880cb112b5 NodePath[] REMOVED_WORLD_PATHS = { }; diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -index a5c8b9c697c1c95553314b0cc789ef1d7b93618e..5cac9ec7ef323134c5992c049ca28b6e7f7a9962 100644 +index ceaf9005336ce229d04df98ae97816846941aa75..71da49901756e379d56a5f24c436a3782d2c230f 100644 --- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -@@ -36,6 +36,8 @@ public class GlobalConfiguration extends ConfigurationPart { +@@ -43,6 +43,8 @@ public class GlobalConfiguration extends ConfigurationPart { public Miscellaneous misc; public class Miscellaneous extends ConfigurationPart { diff --git a/patches/server/0020-Don-t-refresh-LootTable-for-non-player-interaction.patch b/patches/server/0020-Don-t-refresh-LootTable-for-non-player-interaction.patch index 00040bd32..ecd5187cd 100644 --- a/patches/server/0020-Don-t-refresh-LootTable-for-non-player-interaction.patch +++ b/patches/server/0020-Don-t-refresh-LootTable-for-non-player-interaction.patch @@ -29,10 +29,10 @@ index 78e7583bca7570520264ff880cb112b52d708d5b..48096b0be09c6e99d22e0f3b330d2abf NodePath[] REMOVED_GLOBAL_PATH = { }; diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -index 5cac9ec7ef323134c5992c049ca28b6e7f7a9962..654e3744740b816f7822ab884a00b19d79086f74 100644 +index 71da49901756e379d56a5f24c436a3782d2c230f..2ce8bcb92360f5c93494ccbb21133d980934cbc7 100644 --- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -@@ -38,6 +38,7 @@ public class GlobalConfiguration extends ConfigurationPart { +@@ -45,6 +45,7 @@ public class GlobalConfiguration extends ConfigurationPart { public boolean reduceRandom = OPTIMIZE; public boolean ignoreThreadSafeRandom = false; diff --git a/patches/server/0027-Configurable-cave-lava-sea-level.patch b/patches/server/0027-Configurable-cave-lava-sea-level.patch new file mode 100644 index 000000000..5473ea910 --- /dev/null +++ b/patches/server/0027-Configurable-cave-lava-sea-level.patch @@ -0,0 +1,57 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: AlphaKR93 +Date: Tue, 7 Nov 2023 15:32:24 +0900 +Subject: [PATCH] Configurable cave lava sea level + +This patch also fix MC-237017. + +diff --git a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java +index 58609a0911c4e32b6f80f050cd3d23f70ad75b1b..2db6c1b9530b4b082ef6f6ec17c542ba8ad7fa5f 100644 +--- a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java ++++ b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java +@@ -72,6 +72,15 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { + } + + private static Aquifer.FluidPicker createFluidPicker(NoiseGeneratorSettings settings) { ++ // Plazma start ++ if (true) { ++ org.plazmamc.plazma.configurations.GlobalConfiguration config = org.plazmamc.plazma.configurations.GlobalConfiguration.get(); ++ return (x, y, z) -> new Aquifer.FluidStatus( ++ config.worldgen.caveLavaSeaLevel.useCustomSeaLevel ? config.worldgen.caveLavaSeaLevel.customSeaLevel : settings.seaLevel(), ++ config.worldgen.caveLavaSeaLevel.customSeaLevel(settings) ++ ); ++ } ++ // Plazma end + Aquifer.FluidStatus aquifer_b = new Aquifer.FluidStatus(-54, Blocks.LAVA.defaultBlockState()); + int i = settings.seaLevel(); + Aquifer.FluidStatus aquifer_b1 = new Aquifer.FluidStatus(i, settings.defaultFluid()); +diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +index e053ac807246f9ab636270feb62ac36308012110..f417219c70173279536aa33188c56dc39984d44e 100644 +--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java ++++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +@@ -38,6 +38,25 @@ public class GlobalConfiguration extends ConfigurationPart { + public WorldGeneration worldgen; + public class WorldGeneration extends ConfigurationPart { + ++ public CaveLavaSeaLevel caveLavaSeaLevel; ++ public class CaveLavaSeaLevel extends ConfigurationPart { ++ ++ public boolean useCustomSeaLevel = false; ++ public int customSeaLevel = -54; ++ String customSeaBlock = "default"; ++ ++ public net.minecraft.world.level.block.state.BlockState customSeaLevel(net.minecraft.world.level.levelgen.NoiseGeneratorSettings settings) { ++ if (this.customSeaBlock.equalsIgnoreCase("default")) return settings.defaultFluid(); ++ return net.minecraft.core.registries.BuiltInRegistries.BLOCK ++ .getOptional(new net.minecraft.resources.ResourceLocation(this.customSeaBlock)) ++ .orElseGet(() -> { ++ PlazmaConfigurations.LOGGER.warn("Invalid custom sea level block: " + this.customSeaBlock, ", defaulting to lava"); ++ return net.minecraft.world.level.block.Blocks.LAVA; ++ }) ++ .defaultBlockState(); ++ } ++ ++ } + + } +