From 8aa8b7d26cb8d88b684004514eed2d8e53e2877a Mon Sep 17 00:00:00 2001 From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> Date: Fri, 19 Jul 2024 10:27:30 +0800 Subject: [PATCH] Add back Secure Seed --- .../0068-Matter-Secure-Seed.patch} | 475 ++++++------------ .../0069-Matter-Seed-Command.patch} | 20 +- ...70-Ignore-terminal-provider-warning.patch} | 0 ...71-Fix-console-freeze-above-JAVA-22.patch} | 0 ...output-display-on-Pterodactyl-panel.patch} | 0 ...tch => 0073-Faster-Random-Generator.patch} | 0 ...> 0074-Don-t-save-primed-tnt-entity.patch} | 0 ...075-Don-t-save-falling-block-entity.patch} | 0 ...076-Configurable-connection-message.patch} | 0 ...-in-BlockBehaviour-cache-blockstate.patch} | 0 ...=> 0078-Reduce-worldgen-allocations.patch} | 0 ...-183518.patch => 0079-Fix-MC-183518.patch} | 0 ...e-kickPermission-instead-of-using-g.patch} | 0 ...-place-player-if-the-server-is-full.patch} | 0 ...-200418.patch => 0082-Fix-MC-200418.patch} | 0 ...-119417.patch => 0083-Fix-MC-119417.patch} | 0 ...-223153.patch => 0084-Fix-MC-223153.patch} | 0 ...LeavesProtocolManager-init-protocol.patch} | 0 ...-nearby-fire-or-lava-on-entity-move.patch} | 0 19 files changed, 171 insertions(+), 324 deletions(-) rename patches/{work/server/0073-Matter-Secure-Seed.patch => server/0068-Matter-Secure-Seed.patch} (68%) rename patches/{work/server/0074-Matter-Seed-Command.patch => server/0069-Matter-Seed-Command.patch} (60%) rename patches/server/{0068-Ignore-terminal-provider-warning.patch => 0070-Ignore-terminal-provider-warning.patch} (100%) rename patches/server/{0069-Fix-console-freeze-above-JAVA-22.patch => 0071-Fix-console-freeze-above-JAVA-22.patch} (100%) rename patches/server/{0070-Fix-console-output-display-on-Pterodactyl-panel.patch => 0072-Fix-console-output-display-on-Pterodactyl-panel.patch} (100%) rename patches/server/{0071-Faster-Random-Generator.patch => 0073-Faster-Random-Generator.patch} (100%) rename patches/server/{0072-Don-t-save-primed-tnt-entity.patch => 0074-Don-t-save-primed-tnt-entity.patch} (100%) rename patches/server/{0073-Don-t-save-falling-block-entity.patch => 0075-Don-t-save-falling-block-entity.patch} (100%) rename patches/server/{0074-Configurable-connection-message.patch => 0076-Configurable-connection-message.patch} (100%) rename patches/server/{0075-Remove-stream-in-BlockBehaviour-cache-blockstate.patch => 0077-Remove-stream-in-BlockBehaviour-cache-blockstate.patch} (100%) rename patches/server/{0076-Reduce-worldgen-allocations.patch => 0078-Reduce-worldgen-allocations.patch} (100%) rename patches/server/{0077-Fix-MC-183518.patch => 0079-Fix-MC-183518.patch} (100%) rename patches/server/{0078-Use-caffeine-cache-kickPermission-instead-of-using-g.patch => 0080-Use-caffeine-cache-kickPermission-instead-of-using-g.patch} (100%) rename patches/server/{0079-Do-not-place-player-if-the-server-is-full.patch => 0081-Do-not-place-player-if-the-server-is-full.patch} (100%) rename patches/server/{0080-Fix-MC-200418.patch => 0082-Fix-MC-200418.patch} (100%) rename patches/server/{0081-Fix-MC-119417.patch => 0083-Fix-MC-119417.patch} (100%) rename patches/server/{0082-Fix-MC-223153.patch => 0084-Fix-MC-223153.patch} (100%) rename patches/server/{0083-Optimize-LeavesProtocolManager-init-protocol.patch => 0085-Optimize-LeavesProtocolManager-init-protocol.patch} (100%) rename patches/server/{0084-Optimize-check-nearby-fire-or-lava-on-entity-move.patch => 0086-Optimize-check-nearby-fire-or-lava-on-entity-move.patch} (100%) diff --git a/patches/work/server/0073-Matter-Secure-Seed.patch b/patches/server/0068-Matter-Secure-Seed.patch similarity index 68% rename from patches/work/server/0073-Matter-Secure-Seed.patch rename to patches/server/0068-Matter-Secure-Seed.patch index c7443f29..d64c418a 100644 --- a/patches/work/server/0073-Matter-Secure-Seed.patch +++ b/patches/server/0068-Matter-Secure-Seed.patch @@ -5,140 +5,93 @@ Subject: [PATCH] Matter: Secure Seed TODO - Dreeam: Able to write feature seed in existed level.dat -Fix convert between long[] <-> 1024-bit string Update to BLAKE3 Original license: GPLv3 Original project: https://github.com/plasmoapp/matter diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java -index 307a7596024528ad194eb01d6468aff1f5fe02cf..c873c85643ce21d7362673af311e9609ad46441b 100644 +index f41853c5195cea0293766a79ae95c59afa281fdb..b9309888451336da2b9bb9147358df91b92eff3d 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java -@@ -47,6 +47,10 @@ import org.slf4j.Logger; - import joptsimple.OptionSet; - // CraftBukkit end - -+// Leaf start - Matter - Feature Secure Seed -+import su.plo.matter.Globals; -+// Leaf end - Matter -+ - public class DedicatedServerProperties extends Settings { - - static final Logger LOGGER = LogUtils.getLogger(); -@@ -167,7 +171,21 @@ public class DedicatedServerProperties extends Settings { return GsonHelper.parse(!s1.isEmpty() ? s1 : "{}"); }, new JsonObject()), (String) this.get("level-type", (s1) -> { diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 1a90f1eb0682a307dfab63a5694dadd0f29ab77b..31d789e6559bc72c699f1be5457230fb640be045 100644 +index bc3e4237137683f32e1832499491c33da20efdbd..4345f092c45e6e238a5a30a97decd3518e3f050e 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -44,6 +44,10 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemp - import net.minecraft.world.level.storage.DimensionDataStorage; - import net.minecraft.world.level.storage.LevelStorageSource; - -+// Leaf start - Matter - Feature Secure Seed -+import su.plo.matter.Globals; -+// Leaf end - Matter -+ - public class ServerChunkCache extends ChunkSource { - - public static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger(); // Paper -@@ -728,6 +732,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -605,6 +605,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon } public ChunkGenerator getGenerator() { -+ Globals.setupGlobals(level); // Leaf - Matter - Feature Secure Seed ++ su.plo.matter.Globals.setupGlobals(level); // Leaf - Matter - Feature Secure Seed return this.chunkMap.generator(); } diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 2cb1ce10c24f3a18d2d486c6d63cd24b1f3de2be..dced0a22e924838b13edd0c24a7d3fb3de9242d6 100644 +index b97f3ec10552941892b2b6edd53a873eaf72df86..637d4639e8c360beec17e3958d2e8d85af3be416 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -180,6 +180,10 @@ import org.bukkit.event.weather.LightningStrikeEvent; - import org.bukkit.event.world.TimeSkipEvent; - // CraftBukkit end - -+// Leaf start - Matter - Feature Secure Seed -+import su.plo.matter.Globals; -+// Leaf end - Matter -+ - public class ServerLevel extends Level implements WorldGenLevel { - - public static final BlockPos END_SPAWN_POINT = new BlockPos(100, 50, 0); -@@ -752,6 +756,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -601,6 +601,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. chunkgenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, chunkgenerator, gen); } // CraftBukkit end -+ Globals.setupGlobals(this); // Leaf - Matter - Feature Secure Seed ++ su.plo.matter.Globals.setupGlobals(this); // Leaf - Matter - Feature Secure Seed boolean flag2 = minecraftserver.forceSynchronousWrites(); DataFixer datafixer = minecraftserver.getFixerUpper(); - this.entityStorage = new EntityRegionFileStorage(new RegionStorageInfo(convertable_conversionsession.getLevelId(), resourcekey, "entities"), convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), flag2); // Paper - rewrite chunk system + EntityPersistentStorage entitypersistentstorage = new EntityStorage(new SimpleRegionStorage(new RegionStorageInfo(convertable_conversionsession.getLevelId(), resourcekey, "entities"), convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, DataFixTypes.ENTITY_CHUNK), this, minecraftserver); diff --git a/src/main/java/net/minecraft/world/entity/monster/Slime.java b/src/main/java/net/minecraft/world/entity/monster/Slime.java -index ccf7fea215d3096e76db294daa5874fec00147ca..33092f687246afa733d07b89a12007e33b4c6b3f 100644 +index 40c00f73502be66f2a0f3cdb36b963fb25c60704..76a32897f79852977df85b775c412051eb41adba 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Slime.java +++ b/src/main/java/net/minecraft/world/entity/monster/Slime.java -@@ -431,7 +431,10 @@ public class Slime extends Mob implements Enemy { +@@ -439,7 +439,12 @@ public class Slime extends Mob implements Enemy { } ChunkPos chunkcoordintpair = new ChunkPos(pos); - boolean flag = world.getMinecraftWorld().paperConfig().entities.spawning.allChunksAreSlimeChunks || WorldgenRandom.seedSlimeChunk(chunkcoordintpair.x, chunkcoordintpair.z, ((WorldGenLevel) world).getSeed(), world.getMinecraftWorld().spigotConfig.slimeSeed).nextInt(10) == 0; // Spigot // Paper + // Leaf start - Matter - Feature Secure Seed -+ boolean isSlimeChunk = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled ? world.getChunk(chunkcoordintpair.x, chunkcoordintpair.z).isSlimeChunk() : WorldgenRandom.seedSlimeChunk(chunkcoordintpair.x, chunkcoordintpair.z, ((WorldGenLevel) world).getSeed(), world.getMinecraftWorld().spigotConfig.slimeSeed).nextInt(10) == 0; // Spigot // Paper ++ boolean isSlimeChunk = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled ++ ? world.getChunk(chunkcoordintpair.x, chunkcoordintpair.z).isSlimeChunk() ++ : WorldgenRandom.seedSlimeChunk(chunkcoordintpair.x, chunkcoordintpair.z, ((WorldGenLevel) world).getSeed(), world.getMinecraftWorld().spigotConfig.slimeSeed).nextInt(10) == 0; // Spigot // Paper + boolean flag = world.getMinecraftWorld().paperConfig().entities.spawning.allChunksAreSlimeChunks || isSlimeChunk; -+ // Leaf end - Matter ++ // Leaf end - Matter - Feature Secure Seed // Paper start - Replace rules for Height in Slime Chunks final double maxHeightSlimeChunk = world.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.slimeChunk.maximum; diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java -index 1ac1af72a71bbf402f0d1633a4b8c9a408917d73..ad7c58c9289f4cefce9c3b628970e2bfc08c2bfa 100644 +index 75c8125e20b70433fe9d143a3193d821043327c3..5bb8fe022f580a626a99324f53515890a99b798d 100644 --- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java -@@ -57,6 +57,10 @@ import net.minecraft.world.ticks.SerializableTickContainer; - import net.minecraft.world.ticks.TickContainerAccess; - import org.slf4j.Logger; - -+// Leaf start - Matter - Feature Secure Seed -+import su.plo.matter.WorldgenCryptoRandom; -+// Leaf end - Matter -+ - public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiomeSource, LightChunk, StructureAccess { - - public static final int NO_FILLED_SECTION = -1; -@@ -85,6 +89,11 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom +@@ -85,6 +85,11 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom protected final LevelHeightAccessor levelHeightAccessor; protected final LevelChunkSection[] sections; + // Leaf start - Matter - Feature Secure Seed + private boolean slimeChunk; + private boolean hasComputedSlimeChunk; -+ // Leaf end - Matter ++ // Leaf end - Matter - Feature Secure Seed + // CraftBukkit start - SPIGOT-6814: move to IChunkAccess to account for 1.17 to 1.18 chunk upgrading. private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry(); public org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer(ChunkAccess.DATA_TYPE_REGISTRY); -@@ -175,6 +184,17 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom +@@ -189,6 +194,17 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom return GameEventListenerRegistry.NOOP; } @@ -146,46 +99,34 @@ index 1ac1af72a71bbf402f0d1633a4b8c9a408917d73..ad7c58c9289f4cefce9c3b628970e2bf + public boolean isSlimeChunk() { + if (!hasComputedSlimeChunk) { + hasComputedSlimeChunk = true; -+ slimeChunk = WorldgenCryptoRandom.seedSlimeChunk(chunkPos.x, chunkPos.z).nextInt(10) == 0; ++ slimeChunk = su.plo.matter.WorldgenCryptoRandom.seedSlimeChunk(chunkPos.x, chunkPos.z).nextInt(10) == 0; + } + + return slimeChunk; + } -+ // Leaf end - Matter ++ // Leaf end - Matter - Feature Secure Seed + public abstract BlockState getBlockState(final int x, final int y, final int z); // Paper @Nullable public abstract BlockState setBlockState(BlockPos pos, BlockState state, boolean moved); diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java -index 927bdebdb8ae01613f0cea074b3367bd7ffe9ab1..652e471c85cc12e934958103f7ce203aa88d2e4f 100644 +index 488938c32a48437721a71d294c77468f00c035b9..00ed0d5ad535faa36111ab28bb0cf1317eb067ec 100644 --- a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java +++ b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java -@@ -79,6 +79,11 @@ import net.minecraft.world.level.levelgen.structure.placement.StructurePlacement - import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager; - import org.apache.commons.lang3.mutable.MutableBoolean; - -+// Leaf start - Matter - Feature Secure Seed -+import su.plo.matter.Globals; -+import su.plo.matter.WorldgenCryptoRandom; -+// Leaf end - Matter -+ - public abstract class ChunkGenerator { - - public static final Codec CODEC = BuiltInRegistries.CHUNK_GENERATOR.byNameCodec().dispatchStable(ChunkGenerator::codec, Function.identity()); -@@ -345,7 +350,11 @@ public abstract class ChunkGenerator { +@@ -344,7 +344,11 @@ public abstract class ChunkGenerator { return structure.step().ordinal(); })); List list = (List) this.featuresPerStep.get(); - WorldgenRandom seededrandom = new WorldgenRandom(new XoroshiroRandomSource(RandomSupport.generateUniqueSeed())); + // Leaf start - Matter - Feature Secure Seed -+ WorldgenRandom seededrandom = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled ? new WorldgenCryptoRandom( -+ blockposition.getX(), blockposition.getZ(), Globals.Salt.UNDEFINED, 0 -+ ) : new WorldgenRandom(new XoroshiroRandomSource(RandomSupport.generateUniqueSeed())); -+ // Leaf end - Matter ++ WorldgenRandom seededrandom = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled ++ ? new su.plo.matter.WorldgenCryptoRandom(blockposition.getX(), blockposition.getZ(), su.plo.matter.Globals.Salt.UNDEFINED, 0) ++ : new WorldgenRandom(new XoroshiroRandomSource(RandomSupport.generateUniqueSeed())); ++ // Leaf end - Matter - Feature Secure Seed long i = seededrandom.setDecorationSeed(generatoraccessseed.getSeed(), blockposition.getX(), blockposition.getZ()); Set> set = new ObjectArraySet(); -@@ -584,9 +593,18 @@ public abstract class ChunkGenerator { +@@ -583,9 +587,18 @@ public abstract class ChunkGenerator { ArrayList arraylist = new ArrayList(list.size()); arraylist.addAll(list); @@ -195,87 +136,63 @@ index 927bdebdb8ae01613f0cea074b3367bd7ffe9ab1..652e471c85cc12e934958103f7ce203a + // Leaf start - Matter - Feature Secure Seed + WorldgenRandom seededrandom; + if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) { -+ seededrandom = new WorldgenCryptoRandom( -+ chunkcoordintpair.x, chunkcoordintpair.z, Globals.Salt.GENERATE_FEATURE, 0 ++ seededrandom = new su.plo.matter.WorldgenCryptoRandom( ++ chunkcoordintpair.x, chunkcoordintpair.z, su.plo.matter.Globals.Salt.GENERATE_FEATURE, 0 + ); + } else { + seededrandom = new WorldgenRandom(new LegacyRandomSource(0L)); + + seededrandom.setLargeFeatureSeed(placementCalculator.getLevelSeed(), chunkcoordintpair.x, chunkcoordintpair.z); + } -+ // Leaf end - Matter ++ // Leaf end - Matter - Feature Secure Seed int i = 0; StructureSet.StructureSelectionEntry structureset_a1; diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java b/src/main/java/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java -index 713fced29fbd819ee6f151c7f3e462f58a21d5e6..46bb51933ca8977a263872058e4bed071f622235 100644 +index 713fced29fbd819ee6f151c7f3e462f58a21d5e6..49229294eb3b562fba3b48baf5fca9c18ad2be8f 100644 --- a/src/main/java/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java +++ b/src/main/java/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java -@@ -39,6 +39,11 @@ import net.minecraft.world.level.levelgen.structure.placement.RandomSpreadStruct - import org.spigotmc.SpigotWorldConfig; - // Spigot end - -+// Leaf start - Matter - Feature Secure Seed -+import su.plo.matter.Globals; -+import su.plo.matter.WorldgenCryptoRandom; -+// Leaf end - Matter -+ - public class ChunkGeneratorStructureState { - - private static final Logger LOGGER = LogUtils.getLogger(); -@@ -224,8 +229,10 @@ public class ChunkGeneratorStructureState { +@@ -224,8 +224,12 @@ public class ChunkGeneratorStructureState { List> list = new ArrayList(j); int k = placement.spread(); HolderSet holderset = placement.preferredBiomes(); - RandomSource randomsource = RandomSource.create(); + // Leaf start - Matter - Feature Secure Seed -+ RandomSource randomsource = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled ? new WorldgenCryptoRandom(0, 0, Globals.Salt.STRONGHOLDS, 0) : RandomSource.create(); ++ RandomSource randomsource = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled ++ ? new su.plo.matter.WorldgenCryptoRandom(0, 0, su.plo.matter.Globals.Salt.STRONGHOLDS, 0) ++ : RandomSource.create(); + if (!org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) { // Paper start - Add missing structure set seed configs if (this.conf.strongholdSeed != null && structureSetEntry.is(net.minecraft.world.level.levelgen.structure.BuiltinStructureSets.STRONGHOLDS)) { randomsource.setSeed(this.conf.strongholdSeed); -@@ -233,6 +240,7 @@ public class ChunkGeneratorStructureState { +@@ -233,6 +237,7 @@ public class ChunkGeneratorStructureState { // Paper end - Add missing structure set seed configs randomsource.setSeed(this.concentricRingsSeed); } // Paper - Add missing structure set seed configs -+ }// Leaf end - Matter ++ }// Leaf end - Matter - Feature Secure Seed double d0 = randomsource.nextDouble() * Math.PI * 2.0D; int l = 0; int i1 = 0; -diff --git a/src/main/java/net/minecraft/world/level/chunk/status/ChunkStatus.java b/src/main/java/net/minecraft/world/level/chunk/status/ChunkStatus.java -index b81c548c0e1ac53784e9c94b34b65db5f123309c..4d540de21cb35343ef816a6e31cc821d7b121833 100644 ---- a/src/main/java/net/minecraft/world/level/chunk/status/ChunkStatus.java -+++ b/src/main/java/net/minecraft/world/level/chunk/status/ChunkStatus.java -@@ -231,6 +231,7 @@ public class ChunkStatus { +diff --git a/src/main/java/net/minecraft/world/level/chunk/status/ChunkStep.java b/src/main/java/net/minecraft/world/level/chunk/status/ChunkStep.java +index 4e56398a6fb8b97199f4c74ebebc1055fb718dcf..505f0ab967b53c100c91971afbf67bdcafcbee64 100644 +--- a/src/main/java/net/minecraft/world/level/chunk/status/ChunkStep.java ++++ b/src/main/java/net/minecraft/world/level/chunk/status/ChunkStep.java +@@ -60,6 +60,7 @@ public final class ChunkStep implements ca.spottedleaf.moonrise.patches.chunk_sy } - public CompletableFuture generate(WorldGenContext context, Executor executor, ToFullChunk fullChunkConverter, List chunks) { + public CompletableFuture apply(WorldGenContext context, StaticCache2D staticCache2D, ChunkAccess chunk) { + su.plo.matter.Globals.setupGlobals(context.level()); // Leaf - Matter - Feature Secure Seed - ChunkAccess chunkAccess = chunks.get(chunks.size() / 2); - ProfiledDuration profiledDuration = JvmProfiler.INSTANCE.onChunkGenerate(chunkAccess.getPos(), context.level().dimension(), this.toString()); - return this.generationTask.doWork(context, this, executor, fullChunkConverter, chunks, chunkAccess).thenApply(chunk -> { + if (chunk.getPersistedStatus().isBefore(this.targetStatus)) { + ProfiledDuration profiledDuration = JvmProfiler.INSTANCE.onChunkGenerate(chunk.getPos(), context.level().dimension(), this.targetStatus.getName()); + return this.task.doWork(context, this, staticCache2D, chunk).thenApply(generated -> this.completeChunkGeneration(generated, profiledDuration)); diff --git a/src/main/java/net/minecraft/world/level/levelgen/WorldOptions.java b/src/main/java/net/minecraft/world/level/levelgen/WorldOptions.java -index 5ae04ec610a885e2ed73e942879a27fe8640471c..655627e2a305435cafb3dbcafd237a6bf4199ece 100644 +index 5ae04ec610a885e2ed73e942879a27fe8640471c..2d11d72d9c5b1674350a3d7f187e3f1209f37902 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/WorldOptions.java +++ b/src/main/java/net/minecraft/world/level/levelgen/WorldOptions.java -@@ -3,14 +3,33 @@ package net.minecraft.world.level.levelgen; - import com.mojang.serialization.Codec; - import com.mojang.serialization.MapCodec; - import com.mojang.serialization.codecs.RecordCodecBuilder; -+ - import java.util.Optional; - import java.util.OptionalLong; -+ - import net.minecraft.util.RandomSource; +@@ -9,8 +9,19 @@ import net.minecraft.util.RandomSource; import org.apache.commons.lang3.StringUtils; -+// Leaf start - Matter - Feature Secure Seed -+import java.util.stream.LongStream; -+ -+import su.plo.matter.Globals; -+// Leaf end - Matter -+ public class WorldOptions { + // Leaf start - Matter - Feature Secure Seed + private static final boolean isSecureSeedEnabled = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled; @@ -294,15 +211,19 @@ index 5ae04ec610a885e2ed73e942879a27fe8640471c..655627e2a305435cafb3dbcafd237a6b Codec.LONG.fieldOf("seed").stable().forGetter(WorldOptions::seed), Codec.BOOL.fieldOf("generate_features").orElse(true).stable().forGetter(WorldOptions::generateStructures), Codec.BOOL.fieldOf("bonus_chest").orElse(false).stable().forGetter(WorldOptions::generateBonusChest), -@@ -18,18 +37,29 @@ public class WorldOptions { +@@ -18,18 +29,35 @@ public class WorldOptions { ) .apply(instance, instance.stable(WorldOptions::new)) ); - public static final WorldOptions DEMO_OPTIONS = new WorldOptions((long)"North Carolina".hashCode(), true, true); -+ // Leaf end - Matter -+ public static final WorldOptions DEMO_OPTIONS = isSecureSeedEnabled ? new WorldOptions((long) "North Carolina".hashCode(), Globals.createRandomWorldSeed(), true, true) : new WorldOptions("North Carolina".hashCode(), true, true); // Leaf - Matter - Feature Secure Seed ++ // Leaf end - Matter - Feature Secure Seed ++ // Leaf start - Matter - Feature Secure Seed ++ public static final WorldOptions DEMO_OPTIONS = isSecureSeedEnabled ++ ? new WorldOptions((long) "North Carolina".hashCode(), su.plo.matter.Globals.createRandomWorldSeed(), true, true) ++ : new WorldOptions("North Carolina".hashCode(), true, true); ++ // Leaf end - Matter - Feature Secure Seed private final long seed; -+ private long[] featureSeed = Globals.createRandomWorldSeed(); // Leaf - Matter - Feature Secure Seed ++ private long[] featureSeed = su.plo.matter.Globals.createRandomWorldSeed(); // Leaf - Matter - Feature Secure Seed private final boolean generateStructures; private final boolean generateBonusChest; private final Optional legacyCustomOptions; @@ -318,22 +239,24 @@ index 5ae04ec610a885e2ed73e942879a27fe8640471c..655627e2a305435cafb3dbcafd237a6b + public static WorldOptions defaultWithRandomSeed() { - return new WorldOptions(randomSeed(), true, false); -+ return isSecureSeedEnabled ? new WorldOptions(randomSeed(), Globals.createRandomWorldSeed(), true, false) : new WorldOptions(randomSeed(), true, false); ++ return isSecureSeedEnabled ++ ? new WorldOptions(randomSeed(), su.plo.matter.Globals.createRandomWorldSeed(), true, false) ++ : new WorldOptions(randomSeed(), true, false); + } + -+ private WorldOptions(long seed, LongStream featureSeed, boolean generateStructures, boolean bonusChest, Optional legacyCustomOptions) { ++ private WorldOptions(long seed, java.util.stream.LongStream featureSeed, boolean generateStructures, boolean bonusChest, Optional legacyCustomOptions) { + this(seed, featureSeed.toArray(), generateStructures, bonusChest, legacyCustomOptions); } private WorldOptions(long seed, boolean generateStructures, boolean bonusChest, Optional legacyCustomOptions) { -@@ -39,10 +69,26 @@ public class WorldOptions { +@@ -39,10 +67,26 @@ public class WorldOptions { this.legacyCustomOptions = legacyCustomOptions; } + private WorldOptions(long seed, long[] featureSeed, boolean generateStructures, boolean bonusChest, Optional legacyCustomOptions) { + this(seed, generateStructures, bonusChest, legacyCustomOptions); + this.featureSeed = featureSeed; -+ // Leaf end - Matter ++ // Leaf end - Matter - Feature Secure Seed + } + public long seed() { @@ -345,119 +268,84 @@ index 5ae04ec610a885e2ed73e942879a27fe8640471c..655627e2a305435cafb3dbcafd237a6b + return this.featureSeed; + } + -+ public LongStream featureSeedStream() { -+ return LongStream.of(this.featureSeed); ++ public java.util.stream.LongStream featureSeedStream() { ++ return java.util.stream.LongStream.of(this.featureSeed); + } -+ // Leaf end - Matter ++ // Leaf end - Matter - Feature Secure Seed + public boolean generateStructures() { return this.generateStructures; } -@@ -55,17 +101,19 @@ public class WorldOptions { +@@ -55,17 +99,25 @@ public class WorldOptions { return this.legacyCustomOptions.isPresent(); } + // Leaf start - Matter - Feature Secure Seed public WorldOptions withBonusChest(boolean bonusChest) { - return new WorldOptions(this.seed, this.generateStructures, bonusChest, this.legacyCustomOptions); -+ return isSecureSeedEnabled ? new WorldOptions(this.seed, this.featureSeed, this.generateStructures, bonusChest, this.legacyCustomOptions) : new WorldOptions(this.seed, this.generateStructures, bonusChest, this.legacyCustomOptions); ++ return isSecureSeedEnabled ++ ? new WorldOptions(this.seed, this.featureSeed, this.generateStructures, bonusChest, this.legacyCustomOptions) ++ : new WorldOptions(this.seed, this.generateStructures, bonusChest, this.legacyCustomOptions); } public WorldOptions withStructures(boolean structures) { - return new WorldOptions(this.seed, structures, this.generateBonusChest, this.legacyCustomOptions); -+ return isSecureSeedEnabled ? new WorldOptions(this.seed, this.featureSeed, structures, this.generateBonusChest, this.legacyCustomOptions) : new WorldOptions(this.seed, structures, this.generateBonusChest, this.legacyCustomOptions); ++ return isSecureSeedEnabled ++ ? new WorldOptions(this.seed, this.featureSeed, structures, this.generateBonusChest, this.legacyCustomOptions) ++ : new WorldOptions(this.seed, structures, this.generateBonusChest, this.legacyCustomOptions); } public WorldOptions withSeed(OptionalLong seed) { - return new WorldOptions(seed.orElse(randomSeed()), this.generateStructures, this.generateBonusChest, this.legacyCustomOptions); -+ return isSecureSeedEnabled ? new WorldOptions(seed.orElse(randomSeed()), Globals.createRandomWorldSeed(), this.generateStructures, this.generateBonusChest, this.legacyCustomOptions) : new WorldOptions(seed.orElse(randomSeed()), this.generateStructures, this.generateBonusChest, this.legacyCustomOptions); ++ return isSecureSeedEnabled ++ ? new WorldOptions(seed.orElse(randomSeed()), su.plo.matter.Globals.createRandomWorldSeed(), this.generateStructures, this.generateBonusChest, this.legacyCustomOptions) ++ : new WorldOptions(seed.orElse(randomSeed()), this.generateStructures, this.generateBonusChest, this.legacyCustomOptions); } -+ // Leaf end - Matter ++ // Leaf end - Matter - Feature Secure Seed public static OptionalLong parseSeed(String seed) { seed = seed.trim(); -@@ -75,7 +123,7 @@ public class WorldOptions { - try { - return OptionalLong.of(Long.parseLong(seed)); - } catch (NumberFormatException var2) { -- return OptionalLong.of((long)seed.hashCode()); -+ return OptionalLong.of((long) seed.hashCode()); - } - } - } diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/GeodeFeature.java b/src/main/java/net/minecraft/world/level/levelgen/feature/GeodeFeature.java -index 17d2bb3f7d158ec1230a1ad7c52b9feeda586630..2a30f2d4beaa6077a283565211f5c632dfac4fcb 100644 +index 17d2bb3f7d158ec1230a1ad7c52b9feeda586630..fecbce25736dab20e8459cb3b1c636fa7f7eab6b 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/feature/GeodeFeature.java +++ b/src/main/java/net/minecraft/world/level/levelgen/feature/GeodeFeature.java -@@ -25,6 +25,11 @@ import net.minecraft.world.level.levelgen.feature.configurations.GeodeConfigurat - import net.minecraft.world.level.levelgen.synth.NormalNoise; - import net.minecraft.world.level.material.FluidState; - -+// Leaf start - Matter - Feature Secure Seed -+import su.plo.matter.Globals; -+import su.plo.matter.WorldgenCryptoRandom; -+// Leaf end - Matter -+ - public class GeodeFeature extends Feature { - private static final Direction[] DIRECTIONS = Direction.values(); - -@@ -42,7 +47,7 @@ public class GeodeFeature extends Feature { +@@ -42,7 +42,11 @@ public class GeodeFeature extends Feature { int j = geodeConfiguration.maxGenOffset; List> list = Lists.newLinkedList(); int k = geodeConfiguration.distributionPoints.sample(randomSource); - WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(worldGenLevel.getSeed())); -+ WorldgenRandom worldgenRandom = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled ? new WorldgenCryptoRandom(0, 0, Globals.Salt.GEODE_FEATURE, 0) : new WorldgenRandom(new LegacyRandomSource(worldGenLevel.getSeed())); // Leaf - Matter - Feature Secure Seed ++ // Leaf start - Matter - Feature Secure Seed ++ WorldgenRandom worldgenRandom = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled ++ ? new su.plo.matter.WorldgenCryptoRandom(0, 0, su.plo.matter.Globals.Salt.GEODE_FEATURE, 0) ++ : new WorldgenRandom(new LegacyRandomSource(worldGenLevel.getSeed())); ++ // Leaf end - Matter - Feature Secure Seed NormalNoise normalNoise = NormalNoise.create(worldgenRandom, -4, 1.0); List list2 = Lists.newLinkedList(); double d = (double)k / (double)geodeConfiguration.outerWallDistance.getMaxValue(); diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/Structure.java b/src/main/java/net/minecraft/world/level/levelgen/structure/Structure.java -index 4d7398cbe2c400791e6598c9924202a454cb56ce..171118ccf3933aff7765687e5e6d5f6bac7f82e8 100644 +index 3fbd6e8d23f2e6020532530ef8ad7e64b8047d4b..10e39fcdce7c205a695b9c1b8c3551b07a64cfa0 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/structure/Structure.java +++ b/src/main/java/net/minecraft/world/level/levelgen/structure/Structure.java -@@ -39,6 +39,11 @@ import net.minecraft.world.level.levelgen.structure.pieces.PiecesContainer; - import net.minecraft.world.level.levelgen.structure.pieces.StructurePiecesBuilder; - import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager; - -+// Leaf start - Matter - Feature Secure Seed -+import su.plo.matter.Globals; -+import su.plo.matter.WorldgenCryptoRandom; -+// Leaf end - Matter -+ - public abstract class Structure { - public static final Codec DIRECT_CODEC = BuiltInRegistries.STRUCTURE_TYPE.byNameCodec().dispatch(Structure::type, StructureType::codec); - public static final Codec> CODEC = RegistryFileCodec.create(Registries.STRUCTURE, DIRECT_CODEC); -@@ -233,6 +238,14 @@ public abstract class Structure { +@@ -233,6 +233,14 @@ public abstract class Structure { } private static WorldgenRandom makeRandom(long seed, ChunkPos chunkPos) { + // Leaf start - Matter - Feature Secure Seed + if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) { -+ return new WorldgenCryptoRandom( -+ chunkPos.x, chunkPos.z, Globals.Salt.GENERATE_FEATURE, seed ++ return new su.plo.matter.WorldgenCryptoRandom( ++ chunkPos.x, chunkPos.z, su.plo.matter.Globals.Salt.GENERATE_FEATURE, seed + ); + } -+ // Leaf end - Matter ++ // Leaf end - Matter - Feature Secure Seed + WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L)); worldgenRandom.setLargeFeatureSeed(seed, chunkPos.x, chunkPos.z); return worldgenRandom; diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java b/src/main/java/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java -index f873a0a0734b4fe74ba5b5f8ae0cc3c78fa76b9f..3a24937a6e6f47e372a05ebb359312591e3d85aa 100644 +index f873a0a0734b4fe74ba5b5f8ae0cc3c78fa76b9f..5ae511a5a178b0202e6a60cb882fca37a2a92fd4 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java +++ b/src/main/java/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java -@@ -11,6 +11,11 @@ import net.minecraft.world.level.chunk.ChunkGeneratorStructureState; - import net.minecraft.world.level.levelgen.LegacyRandomSource; - import net.minecraft.world.level.levelgen.WorldgenRandom; - -+// Leaf start - Matter - Feature Secure Seed -+import su.plo.matter.Globals; -+import su.plo.matter.WorldgenCryptoRandom; -+// Leaf end - Matter -+ - public class RandomSpreadStructurePlacement extends StructurePlacement { - public static final MapCodec CODEC = RecordCodecBuilder.mapCodec( - instance -> placementCodec(instance) -@@ -71,8 +76,17 @@ public class RandomSpreadStructurePlacement extends StructurePlacement { +@@ -71,8 +71,17 @@ public class RandomSpreadStructurePlacement extends StructurePlacement { public ChunkPos getPotentialStructureChunk(long seed, int chunkX, int chunkZ) { int i = Math.floorDiv(chunkX, this.spacing); int j = Math.floorDiv(chunkZ, this.spacing); @@ -466,34 +354,22 @@ index f873a0a0734b4fe74ba5b5f8ae0cc3c78fa76b9f..3a24937a6e6f47e372a05ebb35931259 + // Leaf start - Matter - Feature Secure Seed + WorldgenRandom worldgenRandom; + if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) { -+ worldgenRandom = new WorldgenCryptoRandom( -+ i, j, Globals.Salt.POTENTIONAL_FEATURE, this.salt ++ worldgenRandom = new su.plo.matter.WorldgenCryptoRandom( ++ i, j, su.plo.matter.Globals.Salt.POTENTIONAL_FEATURE, this.salt + ); + } else { + worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L)); + worldgenRandom.setLargeFeatureWithSalt(seed, i, j, this.salt()); + } -+ // Leaf end - Matter ++ // Leaf end - Matter - Feature Secure Seed int k = this.spacing - this.separation; int l = this.spreadType.evaluate(worldgenRandom, k); int m = this.spreadType.evaluate(worldgenRandom, k); diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java b/src/main/java/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java -index cbf13e4f2da6a27619e9bc9a7cd73bb6e69cad2a..7bbb31678b889ee210a396635d644bbfb6a269dc 100644 +index cbf13e4f2da6a27619e9bc9a7cd73bb6e69cad2a..d97bb945f59dc7d8da1374fda5beee0d6d0f0f5d 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java +++ b/src/main/java/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java -@@ -20,6 +20,11 @@ import net.minecraft.world.level.levelgen.LegacyRandomSource; - import net.minecraft.world.level.levelgen.WorldgenRandom; - import net.minecraft.world.level.levelgen.structure.StructureSet; - -+// Leaf start - Matter - Feature Secure Seed -+import su.plo.matter.Globals; -+import su.plo.matter.WorldgenCryptoRandom; -+// Leaf end - Matter -+ - public abstract class StructurePlacement { - public static final Codec CODEC = BuiltInRegistries.STRUCTURE_PLACEMENT - .byNameCodec() -@@ -118,8 +123,18 @@ public abstract class StructurePlacement { +@@ -118,8 +118,18 @@ public abstract class StructurePlacement { public abstract StructurePlacementType type(); private static boolean probabilityReducer(long seed, int salt, int chunkX, int chunkZ, float frequency, @org.jetbrains.annotations.Nullable Integer saltOverride) { // Paper - Add missing structure set seed configs; ignore here @@ -502,44 +378,32 @@ index cbf13e4f2da6a27619e9bc9a7cd73bb6e69cad2a..7bbb31678b889ee210a396635d644bbf + // Leaf start - Matter - Feature Secure Seed + WorldgenRandom worldgenRandom; + if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) { -+ worldgenRandom = new WorldgenCryptoRandom( -+ chunkX, chunkZ, Globals.Salt.UNDEFINED, salt ++ worldgenRandom = new su.plo.matter.WorldgenCryptoRandom( ++ chunkX, chunkZ, su.plo.matter.Globals.Salt.UNDEFINED, salt + ); + } else { + worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L)); + worldgenRandom.setLargeFeatureWithSalt(seed, salt, chunkX, chunkZ); + } -+ // Leaf end - Matter ++ // Leaf end - Matter - Feature Secure Seed + return worldgenRandom.nextFloat() < frequency; } diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/pools/JigsawPlacement.java b/src/main/java/net/minecraft/world/level/levelgen/structure/pools/JigsawPlacement.java -index 70dbf7267b43357578c07fcd46618f656410a8e2..c7d9359af6be9efa19dd1e27e36f3074d2b89c78 100644 +index 139c6d974e4d68c75406760f7d79034abefd7c28..b9eb60d9b56a1d8e7869fbb5694f7c8a4c1799db 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/structure/pools/JigsawPlacement.java +++ b/src/main/java/net/minecraft/world/level/levelgen/structure/pools/JigsawPlacement.java -@@ -43,6 +43,11 @@ import net.minecraft.world.phys.shapes.VoxelShape; - import org.apache.commons.lang3.mutable.MutableObject; - import org.slf4j.Logger; - -+// Leaf start - Matter - Feature Secure Seed -+import su.plo.matter.Globals; -+import su.plo.matter.WorldgenCryptoRandom; -+// Leaf end - Matter -+ - public class JigsawPlacement { - static final Logger LOGGER = LogUtils.getLogger(); - -@@ -61,7 +66,11 @@ public class JigsawPlacement { +@@ -65,7 +65,11 @@ public class JigsawPlacement { ChunkGenerator chunkGenerator = context.chunkGenerator(); StructureTemplateManager structureTemplateManager = context.structureTemplateManager(); LevelHeightAccessor levelHeightAccessor = context.heightAccessor(); - WorldgenRandom worldgenRandom = context.random(); + // Leaf start - Matter - Feature Secure Seed -+ WorldgenRandom worldgenRandom = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled ? new WorldgenCryptoRandom( -+ context.chunkPos().x, context.chunkPos().z, Globals.Salt.JIGSAW_PLACEMENT, 0 -+ ) : context.random(); -+ // Leaf end - Matter ++ WorldgenRandom worldgenRandom = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled ++ ? new su.plo.matter.WorldgenCryptoRandom(context.chunkPos().x, context.chunkPos().z, su.plo.matter.Globals.Salt.JIGSAW_PLACEMENT, 0) ++ : context.random(); ++ // Leaf end - Matter - Feature Secure Seed Registry registry = registryAccess.registryOrThrow(Registries.TEMPLATE_POOL); Rotation rotation = Rotation.getRandom(worldgenRandom); StructureTemplatePool structureTemplatePool = structurePool.unwrapKey() @@ -568,81 +432,76 @@ index 7f4c5e9355a6f562f668e9b8134bfe65dde35f90..7a1c21696f6531c7dded774f45073df1 public class MineshaftStructure extends Structure { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec( diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java -index 92f1ea81b5e90529905d9c508aca18c31443ff6a..71aeb3f5feb813ef02d07c7952c67817f8a6866e 100644 +index 45e262308aebafa377a2353661acdd122933b99e..96b9e91997bba777ebe868ca5ab5e5e917b58f08 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java -@@ -203,7 +203,10 @@ public class CraftChunk implements Chunk { +@@ -205,7 +205,12 @@ public class CraftChunk implements Chunk { @Override public boolean isSlimeChunk() { // 987234911L is deterimined in EntitySlime when seeing if a slime can spawn in a chunk - return this.worldServer.paperConfig().entities.spawning.allChunksAreSlimeChunks || WorldgenRandom.seedSlimeChunk(this.getX(), this.getZ(), this.getWorld().getSeed(), worldServer.spigotConfig.slimeSeed).nextInt(10) == 0; // Paper + // Leaf start - Matter - Feature Secure Seed -+ boolean isSlimeChunk = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled ? worldServer.getChunk(this.getX(), this.getZ()).isSlimeChunk() : WorldgenRandom.seedSlimeChunk(this.getX(), this.getZ(), this.getWorld().getSeed(), worldServer.spigotConfig.slimeSeed).nextInt(10) == 0; // Paper ++ boolean isSlimeChunk = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled ++ ? worldServer.getChunk(this.getX(), this.getZ()).isSlimeChunk() ++ : WorldgenRandom.seedSlimeChunk(this.getX(), this.getZ(), this.getWorld().getSeed(), worldServer.spigotConfig.slimeSeed).nextInt(10) == 0; // Paper + return this.worldServer.paperConfig().entities.spawning.allChunksAreSlimeChunks || isSlimeChunk; -+ // Leaf end - Matter ++ // Leaf end - Matter - Feature Secure Seed } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index f4b9a74ee268273098e4286354e436bbd3fc07f2..80bb1c1b49d80cc8d98ddb3c2c29a0e597b797e8 100644 +index a3af7fa8d85bf09ae1a35e1fbc4fc9a1774aaff5..86e5a54d7b8bd66b1b8ab6391cce37f04598f7e1 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -267,6 +267,10 @@ import net.md_5.bungee.api.chat.BaseComponent; // Spigot - import javax.annotation.Nullable; // Paper - import javax.annotation.Nonnull; // Paper - -+// Leaf start - Matter - Feature Secure Seed -+import su.plo.matter.Globals; -+// Leaf end - Matter -+ - public final class CraftServer implements Server { - private final String serverName = io.papermc.paper.ServerBuildInfo.buildInfo().brandName(); // Paper - private final String serverVersion; -@@ -1386,7 +1390,7 @@ public final class CraftServer implements Server { +@@ -1387,7 +1387,11 @@ public final class CraftServer implements Server { iregistrycustom_dimension = leveldataanddimensions.dimensions().dimensionsRegistryAccess(); } else { LevelSettings worldsettings; - WorldOptions worldoptions = new WorldOptions(creator.seed(), creator.generateStructures(), false); -+ WorldOptions worldoptions = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled ? new WorldOptions(creator.seed(), Globals.createRandomWorldSeed(), creator.generateStructures(), false) : new WorldOptions(creator.seed(), creator.generateStructures(), false) ;// Leaf - Matter - Feature Secure Seed ++ // Leaf start - Matter - Feature Secure Seed ++ WorldOptions worldoptions = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled ++ ? new WorldOptions(creator.seed(), su.plo.matter.Globals.createRandomWorldSeed(), creator.generateStructures(), false) ++ : new WorldOptions(creator.seed(), creator.generateStructures(), false); ++ // Leaf end - Matter - Feature Secure Seed WorldDimensions worlddimensions; DedicatedServerProperties.WorldDimensionData properties = new DedicatedServerProperties.WorldDimensionData(GsonHelper.parse((creator.generatorSettings().isEmpty()) ? "{}" : creator.generatorSettings()), creator.type().name().toLowerCase(Locale.ROOT)); diff --git a/src/main/java/org/dreeam/leaf/config/modules/misc/SecureSeed.java b/src/main/java/org/dreeam/leaf/config/modules/misc/SecureSeed.java new file mode 100644 -index 0000000000000000000000000000000000000000..47bbf9b3728623d73043c3f4df188486959e7b59 +index 0000000000000000000000000000000000000000..e2eb46cdec10fb3c563eede6f8540768bb6da544 --- /dev/null +++ b/src/main/java/org/dreeam/leaf/config/modules/misc/SecureSeed.java @@ -0,0 +1,24 @@ +package org.dreeam.leaf.config.modules.misc; + -+import org.dreeam.leaf.config.ConfigInfo; ++import org.dreeam.leaf.config.ConfigModules; +import org.dreeam.leaf.config.EnumConfigCategory; -+import org.dreeam.leaf.config.IConfigModule; + -+public class SecureSeed implements IConfigModule { ++public class SecureSeed extends ConfigModules { + -+ @Override -+ public EnumConfigCategory getCategory() { -+ return EnumConfigCategory.MISC; ++ public String getBasePath() { ++ return EnumConfigCategory.MISC.getBaseKeyName() + ".secure-seed"; + } + -+ @Override -+ public String getBaseName() { -+ return "use_secure_seed"; -+ } -+ -+ @ConfigInfo(baseName = "enabled", comments = """ -+ WARNING! Secure seed is unavailable right now, -+ you should not enable it. -+ """) + public static boolean enabled = false; ++ ++ @Override ++ public void onLoaded() { ++ config.addComment(getBasePath(), """ ++ Once you enable secure seed, all ores and structures are generated with 1024-bit seed ++ instead of using 64-bit seed in vanilla, made seed cracker become impossible. ++ WARNING! You need to backup your server and prepare a new world if you want to enable it, ++ at least for now."""); ++ ++ enabled = config.getBoolean(getBasePath() + ".enabled", enabled); ++ } +} diff --git a/src/main/java/su/plo/matter/Globals.java b/src/main/java/su/plo/matter/Globals.java new file mode 100644 -index 0000000000000000000000000000000000000000..9d544b302812c691f9046a48b51c8f7b3b30b149 +index 0000000000000000000000000000000000000000..d325d1617094e12ca011f5ef0e259cd806e35dcc --- /dev/null +++ b/src/main/java/su/plo/matter/Globals.java -@@ -0,0 +1,96 @@ +@@ -0,0 +1,94 @@ +package su.plo.matter; + +import com.google.common.collect.Iterables; @@ -700,43 +559,41 @@ index 0000000000000000000000000000000000000000..9d544b302812c691f9046a48b51c8f7b + return seed; + } + ++ // 1024-bit string -> 16 * 64 long[] + public static Optional parseSeed(String seedStr) { + if (seedStr.isEmpty()) return Optional.empty(); + -+ try { -+ long[] seed = new long[WORLD_SEED_LONGS]; -+ BigInteger seedBigInt = new BigInteger(seedStr); -+ if (seedBigInt.signum() < 0) { -+ seedBigInt = seedBigInt.and(BigInteger.ONE.shiftLeft(WORLD_SEED_BITS).subtract(BigInteger.ONE)); -+ } -+ for (int i = 0; i < WORLD_SEED_LONGS; i++) { -+ BigInteger[] divRem = seedBigInt.divideAndRemainder(BigInteger.ONE.shiftLeft(64)); -+ seed[i] = divRem[1].longValue(); -+ seedBigInt = divRem[0]; -+ } -+ return Optional.of(seed); -+ } catch (NumberFormatException ignored) { -+ return Optional.empty(); ++ if (seedStr.length() != WORLD_SEED_BITS) { ++ throw new IllegalArgumentException("Secure seed length must be " + WORLD_SEED_BITS + "-bit but found " + seedStr.length() + "-bit."); + } ++ ++ long[] seed = new long[WORLD_SEED_LONGS]; ++ ++ for (int i = 0; i < WORLD_SEED_LONGS; i++) { ++ int start = i * 64; ++ int end = start + 64; ++ String seedSection = seedStr.substring(start, end); ++ ++ BigInteger seedInDecimal = new BigInteger(seedSection, 2); ++ seed[i] = seedInDecimal.longValue(); ++ } ++ ++ return Optional.of(seed); + } + ++ // 16 * 64 long[] -> 1024-bit string + public static String seedToString(long[] seed) { -+ BigInteger seedBigInt = BigInteger.ZERO; -+ for (int i = WORLD_SEED_LONGS - 1; i >= 0; i--) { -+ BigInteger val = BigInteger.valueOf(seed[i]); -+ if (val.signum() < 0) { -+ val = val.add(BigInteger.ONE.shiftLeft(64)); -+ } -+ seedBigInt = seedBigInt.shiftLeft(64).add(val); ++ StringBuilder sb = new StringBuilder(); ++ ++ for (long longV : seed) { ++ // Convert to 64-bit binary string per long ++ // Use format to keep 64-bit length, and use 0 to complete space ++ String binaryStr = String.format("%64s", Long.toBinaryString(longV)).replace(' ', '0'); ++ ++ sb.append(binaryStr); + } + -+ // Ensure the output is 1024-bit length -+ int seedLength = seedBigInt.bitLength(); -+ if (seedLength < 1024) { -+ seedBigInt = seedBigInt.add(BigInteger.ONE.shiftLeft(1025 - seedLength)); // Use 1025 since the first sign bit -+ } -+ -+ return seedBigInt.toString(); ++ return sb.toString(); + } +} diff --git a/src/main/java/su/plo/matter/Hashing.java b/src/main/java/su/plo/matter/Hashing.java diff --git a/patches/work/server/0074-Matter-Seed-Command.patch b/patches/server/0069-Matter-Seed-Command.patch similarity index 60% rename from patches/work/server/0074-Matter-Seed-Command.patch rename to patches/server/0069-Matter-Seed-Command.patch index 626f54c2..874048ac 100644 --- a/patches/work/server/0074-Matter-Seed-Command.patch +++ b/patches/server/0069-Matter-Seed-Command.patch @@ -7,33 +7,23 @@ Original license: GPLv3 Original project: https://github.com/plasmoapp/matter diff --git a/src/main/java/net/minecraft/server/commands/SeedCommand.java b/src/main/java/net/minecraft/server/commands/SeedCommand.java -index 0b500b19a99fa6c2740c0db350a166462668df9c..e0516ed524fe55277adb3e2c4571ca40c334c5ef 100644 +index 0b500b19a99fa6c2740c0db350a166462668df9c..a34f06460ac8eb2ee05cd0e6facc3f08418aff70 100644 --- a/src/main/java/net/minecraft/server/commands/SeedCommand.java +++ b/src/main/java/net/minecraft/server/commands/SeedCommand.java -@@ -6,12 +6,27 @@ import net.minecraft.commands.Commands; - import net.minecraft.network.chat.Component; - import net.minecraft.network.chat.ComponentUtils; - -+// Leaf start - Matter - Feature Secure Seed -+import su.plo.matter.Globals; -+// Leaf end - Matter -+ - public class SeedCommand { - public static void register(CommandDispatcher dispatcher, boolean dedicated) { - dispatcher.register(Commands.literal("seed").requires(source -> !dedicated || source.hasPermission(2)).executes(context -> { +@@ -12,6 +12,17 @@ public class SeedCommand { long l = context.getSource().getLevel().getSeed(); Component component = ComponentUtils.copyOnClickText(String.valueOf(l)); context.getSource().sendSuccess(() -> Component.translatable("commands.seed.success", component), false); + + // Leaf start - Matter - SecureSeed Command + if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) { -+ Globals.setupGlobals(context.getSource().getLevel()); -+ String seedStr = Globals.seedToString(Globals.worldSeed); ++ su.plo.matter.Globals.setupGlobals(context.getSource().getLevel()); ++ String seedStr = su.plo.matter.Globals.seedToString(su.plo.matter.Globals.worldSeed); + Component featureSeedComponent = ComponentUtils.copyOnClickText(seedStr); + + context.getSource().sendSuccess(() -> Component.translatable(("Feature seed: %s"), featureSeedComponent), false); + } -+ // Leaf end - Matter ++ // Leaf end - Matter - SecureSeed Command + return (int)l; })); diff --git a/patches/server/0068-Ignore-terminal-provider-warning.patch b/patches/server/0070-Ignore-terminal-provider-warning.patch similarity index 100% rename from patches/server/0068-Ignore-terminal-provider-warning.patch rename to patches/server/0070-Ignore-terminal-provider-warning.patch diff --git a/patches/server/0069-Fix-console-freeze-above-JAVA-22.patch b/patches/server/0071-Fix-console-freeze-above-JAVA-22.patch similarity index 100% rename from patches/server/0069-Fix-console-freeze-above-JAVA-22.patch rename to patches/server/0071-Fix-console-freeze-above-JAVA-22.patch diff --git a/patches/server/0070-Fix-console-output-display-on-Pterodactyl-panel.patch b/patches/server/0072-Fix-console-output-display-on-Pterodactyl-panel.patch similarity index 100% rename from patches/server/0070-Fix-console-output-display-on-Pterodactyl-panel.patch rename to patches/server/0072-Fix-console-output-display-on-Pterodactyl-panel.patch diff --git a/patches/server/0071-Faster-Random-Generator.patch b/patches/server/0073-Faster-Random-Generator.patch similarity index 100% rename from patches/server/0071-Faster-Random-Generator.patch rename to patches/server/0073-Faster-Random-Generator.patch diff --git a/patches/server/0072-Don-t-save-primed-tnt-entity.patch b/patches/server/0074-Don-t-save-primed-tnt-entity.patch similarity index 100% rename from patches/server/0072-Don-t-save-primed-tnt-entity.patch rename to patches/server/0074-Don-t-save-primed-tnt-entity.patch diff --git a/patches/server/0073-Don-t-save-falling-block-entity.patch b/patches/server/0075-Don-t-save-falling-block-entity.patch similarity index 100% rename from patches/server/0073-Don-t-save-falling-block-entity.patch rename to patches/server/0075-Don-t-save-falling-block-entity.patch diff --git a/patches/server/0074-Configurable-connection-message.patch b/patches/server/0076-Configurable-connection-message.patch similarity index 100% rename from patches/server/0074-Configurable-connection-message.patch rename to patches/server/0076-Configurable-connection-message.patch diff --git a/patches/server/0075-Remove-stream-in-BlockBehaviour-cache-blockstate.patch b/patches/server/0077-Remove-stream-in-BlockBehaviour-cache-blockstate.patch similarity index 100% rename from patches/server/0075-Remove-stream-in-BlockBehaviour-cache-blockstate.patch rename to patches/server/0077-Remove-stream-in-BlockBehaviour-cache-blockstate.patch diff --git a/patches/server/0076-Reduce-worldgen-allocations.patch b/patches/server/0078-Reduce-worldgen-allocations.patch similarity index 100% rename from patches/server/0076-Reduce-worldgen-allocations.patch rename to patches/server/0078-Reduce-worldgen-allocations.patch diff --git a/patches/server/0077-Fix-MC-183518.patch b/patches/server/0079-Fix-MC-183518.patch similarity index 100% rename from patches/server/0077-Fix-MC-183518.patch rename to patches/server/0079-Fix-MC-183518.patch diff --git a/patches/server/0078-Use-caffeine-cache-kickPermission-instead-of-using-g.patch b/patches/server/0080-Use-caffeine-cache-kickPermission-instead-of-using-g.patch similarity index 100% rename from patches/server/0078-Use-caffeine-cache-kickPermission-instead-of-using-g.patch rename to patches/server/0080-Use-caffeine-cache-kickPermission-instead-of-using-g.patch diff --git a/patches/server/0079-Do-not-place-player-if-the-server-is-full.patch b/patches/server/0081-Do-not-place-player-if-the-server-is-full.patch similarity index 100% rename from patches/server/0079-Do-not-place-player-if-the-server-is-full.patch rename to patches/server/0081-Do-not-place-player-if-the-server-is-full.patch diff --git a/patches/server/0080-Fix-MC-200418.patch b/patches/server/0082-Fix-MC-200418.patch similarity index 100% rename from patches/server/0080-Fix-MC-200418.patch rename to patches/server/0082-Fix-MC-200418.patch diff --git a/patches/server/0081-Fix-MC-119417.patch b/patches/server/0083-Fix-MC-119417.patch similarity index 100% rename from patches/server/0081-Fix-MC-119417.patch rename to patches/server/0083-Fix-MC-119417.patch diff --git a/patches/server/0082-Fix-MC-223153.patch b/patches/server/0084-Fix-MC-223153.patch similarity index 100% rename from patches/server/0082-Fix-MC-223153.patch rename to patches/server/0084-Fix-MC-223153.patch diff --git a/patches/server/0083-Optimize-LeavesProtocolManager-init-protocol.patch b/patches/server/0085-Optimize-LeavesProtocolManager-init-protocol.patch similarity index 100% rename from patches/server/0083-Optimize-LeavesProtocolManager-init-protocol.patch rename to patches/server/0085-Optimize-LeavesProtocolManager-init-protocol.patch diff --git a/patches/server/0084-Optimize-check-nearby-fire-or-lava-on-entity-move.patch b/patches/server/0086-Optimize-check-nearby-fire-or-lava-on-entity-move.patch similarity index 100% rename from patches/server/0084-Optimize-check-nearby-fire-or-lava-on-entity-move.patch rename to patches/server/0086-Optimize-check-nearby-fire-or-lava-on-entity-move.patch