mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-22 08:29:28 +00:00
Add back Secure Seed
This commit is contained in:
@@ -5,140 +5,93 @@ Subject: [PATCH] Matter: Secure Seed
|
|||||||
|
|
||||||
TODO - Dreeam:
|
TODO - Dreeam:
|
||||||
Able to write feature seed in existed level.dat
|
Able to write feature seed in existed level.dat
|
||||||
Fix convert between long[] <-> 1024-bit string
|
|
||||||
Update to BLAKE3
|
Update to BLAKE3
|
||||||
|
|
||||||
Original license: GPLv3
|
Original license: GPLv3
|
||||||
Original project: https://github.com/plasmoapp/matter
|
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
|
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
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||||
+++ b/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;
|
@@ -168,7 +168,17 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
|
||||||
import joptsimple.OptionSet;
|
|
||||||
// CraftBukkit end
|
|
||||||
|
|
||||||
+// Leaf start - Matter - Feature Secure Seed
|
|
||||||
+import su.plo.matter.Globals;
|
|
||||||
+// Leaf end - Matter
|
|
||||||
+
|
|
||||||
public class DedicatedServerProperties extends Settings<DedicatedServerProperties> {
|
|
||||||
|
|
||||||
static final Logger LOGGER = LogUtils.getLogger();
|
|
||||||
@@ -167,7 +171,21 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
|
|
||||||
boolean flag = this.get("generate-structures", true);
|
boolean flag = this.get("generate-structures", true);
|
||||||
long i = WorldOptions.parseSeed(s).orElse(WorldOptions.randomSeed());
|
long i = WorldOptions.parseSeed(s).orElse(WorldOptions.randomSeed());
|
||||||
|
|
||||||
- this.worldOptions = new WorldOptions(i, flag, false);
|
- this.worldOptions = new WorldOptions(i, flag, false);
|
||||||
+ // Leaf start - Matter - Feature Secure Seed
|
+ // Leaf start - Matter - Feature Secure Seed
|
||||||
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
||||||
+ String featureSeedString = this.get("feature-level-seed", "");
|
+ String featureSeedStr = this.get("feature-level-seed", "");
|
||||||
+ long[] featureSeed;
|
+ long[] featureSeed = su.plo.matter.Globals.parseSeed(featureSeedStr)
|
||||||
+ if (featureSeedString.isEmpty()) {
|
+ .orElse(su.plo.matter.Globals.createRandomWorldSeed());
|
||||||
+ featureSeed = Globals.createRandomWorldSeed();
|
|
||||||
+ } else {
|
|
||||||
+ featureSeed = Globals.parseSeed(featureSeedString).orElseGet(Globals::createRandomWorldSeed);
|
|
||||||
+ }
|
|
||||||
+
|
+
|
||||||
+ this.worldOptions = new WorldOptions(i, featureSeed, flag, false);
|
+ this.worldOptions = new WorldOptions(i, featureSeed, flag, false);
|
||||||
+ } else {
|
+ } else {
|
||||||
+ this.worldOptions = new WorldOptions(i, flag, false);
|
+ this.worldOptions = new WorldOptions(i, flag, false);
|
||||||
+ }
|
+ }
|
||||||
+ // Leaf end - Matter
|
+ // Leaf end - Matter - Feature Secure Seed
|
||||||
this.worldDimensionData = new DedicatedServerProperties.WorldDimensionData((JsonObject) this.get("generator-settings", (s1) -> {
|
this.worldDimensionData = new DedicatedServerProperties.WorldDimensionData((JsonObject) this.get("generator-settings", (s1) -> {
|
||||||
return GsonHelper.parse(!s1.isEmpty() ? s1 : "{}");
|
return GsonHelper.parse(!s1.isEmpty() ? s1 : "{}");
|
||||||
}, new JsonObject()), (String) this.get("level-type", (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
|
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
|
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||||
+++ b/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
|
@@ -605,6 +605,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||||
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 {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChunkGenerator getGenerator() {
|
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();
|
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
|
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
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
+++ b/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;
|
@@ -601,6 +601,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
|
||||||
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 {
|
|
||||||
chunkgenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, chunkgenerator, gen);
|
chunkgenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, chunkgenerator, gen);
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// 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();
|
boolean flag2 = minecraftserver.forceSynchronousWrites();
|
||||||
DataFixer datafixer = minecraftserver.getFixerUpper();
|
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<Entity> 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
|
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
|
--- a/src/main/java/net/minecraft/world/entity/monster/Slime.java
|
||||||
+++ b/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);
|
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
|
- 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
|
+ // 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;
|
+ 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
|
// Paper start - Replace rules for Height in Slime Chunks
|
||||||
final double maxHeightSlimeChunk = world.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.slimeChunk.maximum;
|
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
|
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
|
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||||
+++ b/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;
|
@@ -85,6 +85,11 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom
|
||||||
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
|
|
||||||
protected final LevelHeightAccessor levelHeightAccessor;
|
protected final LevelHeightAccessor levelHeightAccessor;
|
||||||
protected final LevelChunkSection[] sections;
|
protected final LevelChunkSection[] sections;
|
||||||
|
|
||||||
+ // Leaf start - Matter - Feature Secure Seed
|
+ // Leaf start - Matter - Feature Secure Seed
|
||||||
+ private boolean slimeChunk;
|
+ private boolean slimeChunk;
|
||||||
+ private boolean hasComputedSlimeChunk;
|
+ 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.
|
// 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();
|
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);
|
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;
|
return GameEventListenerRegistry.NOOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,46 +99,34 @@ index 1ac1af72a71bbf402f0d1633a4b8c9a408917d73..ad7c58c9289f4cefce9c3b628970e2bf
|
|||||||
+ public boolean isSlimeChunk() {
|
+ public boolean isSlimeChunk() {
|
||||||
+ if (!hasComputedSlimeChunk) {
|
+ if (!hasComputedSlimeChunk) {
|
||||||
+ hasComputedSlimeChunk = true;
|
+ 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;
|
+ 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
|
public abstract BlockState getBlockState(final int x, final int y, final int z); // Paper
|
||||||
@Nullable
|
@Nullable
|
||||||
public abstract BlockState setBlockState(BlockPos pos, BlockState state, boolean moved);
|
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
|
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
|
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||||
+++ b/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
|
@@ -344,7 +344,11 @@ public abstract class ChunkGenerator {
|
||||||
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<ChunkGenerator> CODEC = BuiltInRegistries.CHUNK_GENERATOR.byNameCodec().dispatchStable(ChunkGenerator::codec, Function.identity());
|
|
||||||
@@ -345,7 +350,11 @@ public abstract class ChunkGenerator {
|
|
||||||
return structure.step().ordinal();
|
return structure.step().ordinal();
|
||||||
}));
|
}));
|
||||||
List<FeatureSorter.StepFeatureData> list = (List) this.featuresPerStep.get();
|
List<FeatureSorter.StepFeatureData> list = (List) this.featuresPerStep.get();
|
||||||
- WorldgenRandom seededrandom = new WorldgenRandom(new XoroshiroRandomSource(RandomSupport.generateUniqueSeed()));
|
- WorldgenRandom seededrandom = new WorldgenRandom(new XoroshiroRandomSource(RandomSupport.generateUniqueSeed()));
|
||||||
+ // Leaf start - Matter - Feature Secure Seed
|
+ // Leaf start - Matter - Feature Secure Seed
|
||||||
+ WorldgenRandom seededrandom = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled ? new WorldgenCryptoRandom(
|
+ WorldgenRandom seededrandom = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled
|
||||||
+ blockposition.getX(), blockposition.getZ(), Globals.Salt.UNDEFINED, 0
|
+ ? new su.plo.matter.WorldgenCryptoRandom(blockposition.getX(), blockposition.getZ(), su.plo.matter.Globals.Salt.UNDEFINED, 0)
|
||||||
+ ) : new WorldgenRandom(new XoroshiroRandomSource(RandomSupport.generateUniqueSeed()));
|
+ : new WorldgenRandom(new XoroshiroRandomSource(RandomSupport.generateUniqueSeed()));
|
||||||
+ // Leaf end - Matter
|
+ // Leaf end - Matter - Feature Secure Seed
|
||||||
long i = seededrandom.setDecorationSeed(generatoraccessseed.getSeed(), blockposition.getX(), blockposition.getZ());
|
long i = seededrandom.setDecorationSeed(generatoraccessseed.getSeed(), blockposition.getX(), blockposition.getZ());
|
||||||
Set<Holder<Biome>> set = new ObjectArraySet();
|
Set<Holder<Biome>> set = new ObjectArraySet();
|
||||||
|
|
||||||
@@ -584,9 +593,18 @@ public abstract class ChunkGenerator {
|
@@ -583,9 +587,18 @@ public abstract class ChunkGenerator {
|
||||||
ArrayList<StructureSet.StructureSelectionEntry> arraylist = new ArrayList(list.size());
|
ArrayList<StructureSet.StructureSelectionEntry> arraylist = new ArrayList(list.size());
|
||||||
|
|
||||||
arraylist.addAll(list);
|
arraylist.addAll(list);
|
||||||
@@ -195,87 +136,63 @@ index 927bdebdb8ae01613f0cea074b3367bd7ffe9ab1..652e471c85cc12e934958103f7ce203a
|
|||||||
+ // Leaf start - Matter - Feature Secure Seed
|
+ // Leaf start - Matter - Feature Secure Seed
|
||||||
+ WorldgenRandom seededrandom;
|
+ WorldgenRandom seededrandom;
|
||||||
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
||||||
+ seededrandom = new WorldgenCryptoRandom(
|
+ seededrandom = new su.plo.matter.WorldgenCryptoRandom(
|
||||||
+ chunkcoordintpair.x, chunkcoordintpair.z, Globals.Salt.GENERATE_FEATURE, 0
|
+ chunkcoordintpair.x, chunkcoordintpair.z, su.plo.matter.Globals.Salt.GENERATE_FEATURE, 0
|
||||||
+ );
|
+ );
|
||||||
+ } else {
|
+ } else {
|
||||||
+ seededrandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
+ seededrandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||||
+
|
+
|
||||||
+ seededrandom.setLargeFeatureSeed(placementCalculator.getLevelSeed(), chunkcoordintpair.x, chunkcoordintpair.z);
|
+ seededrandom.setLargeFeatureSeed(placementCalculator.getLevelSeed(), chunkcoordintpair.x, chunkcoordintpair.z);
|
||||||
+ }
|
+ }
|
||||||
+ // Leaf end - Matter
|
+ // Leaf end - Matter - Feature Secure Seed
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
StructureSet.StructureSelectionEntry structureset_a1;
|
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
|
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
|
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
||||||
+++ b/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
|
@@ -224,8 +224,12 @@ public class ChunkGeneratorStructureState {
|
||||||
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 {
|
|
||||||
List<CompletableFuture<ChunkPos>> list = new ArrayList(j);
|
List<CompletableFuture<ChunkPos>> list = new ArrayList(j);
|
||||||
int k = placement.spread();
|
int k = placement.spread();
|
||||||
HolderSet<Biome> holderset = placement.preferredBiomes();
|
HolderSet<Biome> holderset = placement.preferredBiomes();
|
||||||
- RandomSource randomsource = RandomSource.create();
|
- RandomSource randomsource = RandomSource.create();
|
||||||
+ // Leaf start - Matter - Feature Secure Seed
|
+ // 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) {
|
+ if (!org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
||||||
// Paper start - Add missing structure set seed configs
|
// Paper start - Add missing structure set seed configs
|
||||||
if (this.conf.strongholdSeed != null && structureSetEntry.is(net.minecraft.world.level.levelgen.structure.BuiltinStructureSets.STRONGHOLDS)) {
|
if (this.conf.strongholdSeed != null && structureSetEntry.is(net.minecraft.world.level.levelgen.structure.BuiltinStructureSets.STRONGHOLDS)) {
|
||||||
randomsource.setSeed(this.conf.strongholdSeed);
|
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
|
// Paper end - Add missing structure set seed configs
|
||||||
randomsource.setSeed(this.concentricRingsSeed);
|
randomsource.setSeed(this.concentricRingsSeed);
|
||||||
} // Paper - Add missing structure set seed configs
|
} // Paper - Add missing structure set seed configs
|
||||||
+ }// Leaf end - Matter
|
+ }// Leaf end - Matter - Feature Secure Seed
|
||||||
double d0 = randomsource.nextDouble() * Math.PI * 2.0D;
|
double d0 = randomsource.nextDouble() * Math.PI * 2.0D;
|
||||||
int l = 0;
|
int l = 0;
|
||||||
int i1 = 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
|
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 b81c548c0e1ac53784e9c94b34b65db5f123309c..4d540de21cb35343ef816a6e31cc821d7b121833 100644
|
index 4e56398a6fb8b97199f4c74ebebc1055fb718dcf..505f0ab967b53c100c91971afbf67bdcafcbee64 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/status/ChunkStatus.java
|
--- a/src/main/java/net/minecraft/world/level/chunk/status/ChunkStep.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/chunk/status/ChunkStatus.java
|
+++ b/src/main/java/net/minecraft/world/level/chunk/status/ChunkStep.java
|
||||||
@@ -231,6 +231,7 @@ public class ChunkStatus {
|
@@ -60,6 +60,7 @@ public final class ChunkStep implements ca.spottedleaf.moonrise.patches.chunk_sy
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<ChunkAccess> generate(WorldGenContext context, Executor executor, ToFullChunk fullChunkConverter, List<ChunkAccess> chunks) {
|
public CompletableFuture<ChunkAccess> apply(WorldGenContext context, StaticCache2D<GenerationChunkHolder> staticCache2D, ChunkAccess chunk) {
|
||||||
+ su.plo.matter.Globals.setupGlobals(context.level()); // Leaf - Matter - Feature Secure Seed
|
+ su.plo.matter.Globals.setupGlobals(context.level()); // Leaf - Matter - Feature Secure Seed
|
||||||
ChunkAccess chunkAccess = chunks.get(chunks.size() / 2);
|
if (chunk.getPersistedStatus().isBefore(this.targetStatus)) {
|
||||||
ProfiledDuration profiledDuration = JvmProfiler.INSTANCE.onChunkGenerate(chunkAccess.getPos(), context.level().dimension(), this.toString());
|
ProfiledDuration profiledDuration = JvmProfiler.INSTANCE.onChunkGenerate(chunk.getPos(), context.level().dimension(), this.targetStatus.getName());
|
||||||
return this.generationTask.doWork(context, this, executor, fullChunkConverter, chunks, chunkAccess).thenApply(chunk -> {
|
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
|
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
|
--- a/src/main/java/net/minecraft/world/level/levelgen/WorldOptions.java
|
||||||
+++ b/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;
|
@@ -9,8 +9,19 @@ import net.minecraft.util.RandomSource;
|
||||||
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;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
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 {
|
public class WorldOptions {
|
||||||
+ // Leaf start - Matter - Feature Secure Seed
|
+ // Leaf start - Matter - Feature Secure Seed
|
||||||
+ private static final boolean isSecureSeedEnabled = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled;
|
+ 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.LONG.fieldOf("seed").stable().forGetter(WorldOptions::seed),
|
||||||
Codec.BOOL.fieldOf("generate_features").orElse(true).stable().forGetter(WorldOptions::generateStructures),
|
Codec.BOOL.fieldOf("generate_features").orElse(true).stable().forGetter(WorldOptions::generateStructures),
|
||||||
Codec.BOOL.fieldOf("bonus_chest").orElse(false).stable().forGetter(WorldOptions::generateBonusChest),
|
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))
|
.apply(instance, instance.stable(WorldOptions::new))
|
||||||
);
|
);
|
||||||
- public static final WorldOptions DEMO_OPTIONS = new WorldOptions((long)"North Carolina".hashCode(), true, true);
|
- public static final WorldOptions DEMO_OPTIONS = new WorldOptions((long)"North Carolina".hashCode(), true, true);
|
||||||
+ // Leaf end - Matter
|
+ // Leaf end - Matter - Feature Secure Seed
|
||||||
+ 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 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 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 generateStructures;
|
||||||
private final boolean generateBonusChest;
|
private final boolean generateBonusChest;
|
||||||
private final Optional<String> legacyCustomOptions;
|
private final Optional<String> legacyCustomOptions;
|
||||||
@@ -318,22 +239,24 @@ index 5ae04ec610a885e2ed73e942879a27fe8640471c..655627e2a305435cafb3dbcafd237a6b
|
|||||||
+
|
+
|
||||||
public static WorldOptions defaultWithRandomSeed() {
|
public static WorldOptions defaultWithRandomSeed() {
|
||||||
- return new WorldOptions(randomSeed(), true, false);
|
- 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<String> legacyCustomOptions) {
|
+ private WorldOptions(long seed, java.util.stream.LongStream featureSeed, boolean generateStructures, boolean bonusChest, Optional<String> legacyCustomOptions) {
|
||||||
+ this(seed, featureSeed.toArray(), generateStructures, bonusChest, legacyCustomOptions);
|
+ this(seed, featureSeed.toArray(), generateStructures, bonusChest, legacyCustomOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
private WorldOptions(long seed, boolean generateStructures, boolean bonusChest, Optional<String> legacyCustomOptions) {
|
private WorldOptions(long seed, boolean generateStructures, boolean bonusChest, Optional<String> legacyCustomOptions) {
|
||||||
@@ -39,10 +69,26 @@ public class WorldOptions {
|
@@ -39,10 +67,26 @@ public class WorldOptions {
|
||||||
this.legacyCustomOptions = legacyCustomOptions;
|
this.legacyCustomOptions = legacyCustomOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ private WorldOptions(long seed, long[] featureSeed, boolean generateStructures, boolean bonusChest, Optional<String> legacyCustomOptions) {
|
+ private WorldOptions(long seed, long[] featureSeed, boolean generateStructures, boolean bonusChest, Optional<String> legacyCustomOptions) {
|
||||||
+ this(seed, generateStructures, bonusChest, legacyCustomOptions);
|
+ this(seed, generateStructures, bonusChest, legacyCustomOptions);
|
||||||
+ this.featureSeed = featureSeed;
|
+ this.featureSeed = featureSeed;
|
||||||
+ // Leaf end - Matter
|
+ // Leaf end - Matter - Feature Secure Seed
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
public long seed() {
|
public long seed() {
|
||||||
@@ -345,119 +268,84 @@ index 5ae04ec610a885e2ed73e942879a27fe8640471c..655627e2a305435cafb3dbcafd237a6b
|
|||||||
+ return this.featureSeed;
|
+ return this.featureSeed;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public LongStream featureSeedStream() {
|
+ public java.util.stream.LongStream featureSeedStream() {
|
||||||
+ return LongStream.of(this.featureSeed);
|
+ return java.util.stream.LongStream.of(this.featureSeed);
|
||||||
+ }
|
+ }
|
||||||
+ // Leaf end - Matter
|
+ // Leaf end - Matter - Feature Secure Seed
|
||||||
+
|
+
|
||||||
public boolean generateStructures() {
|
public boolean generateStructures() {
|
||||||
return this.generateStructures;
|
return this.generateStructures;
|
||||||
}
|
}
|
||||||
@@ -55,17 +101,19 @@ public class WorldOptions {
|
@@ -55,17 +99,25 @@ public class WorldOptions {
|
||||||
return this.legacyCustomOptions.isPresent();
|
return this.legacyCustomOptions.isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
+ // Leaf start - Matter - Feature Secure Seed
|
+ // Leaf start - Matter - Feature Secure Seed
|
||||||
public WorldOptions withBonusChest(boolean bonusChest) {
|
public WorldOptions withBonusChest(boolean bonusChest) {
|
||||||
- return new WorldOptions(this.seed, this.generateStructures, bonusChest, this.legacyCustomOptions);
|
- 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) {
|
public WorldOptions withStructures(boolean structures) {
|
||||||
- return new WorldOptions(this.seed, structures, this.generateBonusChest, this.legacyCustomOptions);
|
- 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) {
|
public WorldOptions withSeed(OptionalLong seed) {
|
||||||
- return new WorldOptions(seed.orElse(randomSeed()), this.generateStructures, this.generateBonusChest, this.legacyCustomOptions);
|
- 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) {
|
public static OptionalLong parseSeed(String seed) {
|
||||||
seed = seed.trim();
|
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
|
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
|
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/GeodeFeature.java
|
||||||
+++ b/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
|
@@ -42,7 +42,11 @@ public class GeodeFeature extends Feature<GeodeConfiguration> {
|
||||||
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<GeodeConfiguration> {
|
|
||||||
private static final Direction[] DIRECTIONS = Direction.values();
|
|
||||||
|
|
||||||
@@ -42,7 +47,7 @@ public class GeodeFeature extends Feature<GeodeConfiguration> {
|
|
||||||
int j = geodeConfiguration.maxGenOffset;
|
int j = geodeConfiguration.maxGenOffset;
|
||||||
List<Pair<BlockPos, Integer>> list = Lists.newLinkedList();
|
List<Pair<BlockPos, Integer>> list = Lists.newLinkedList();
|
||||||
int k = geodeConfiguration.distributionPoints.sample(randomSource);
|
int k = geodeConfiguration.distributionPoints.sample(randomSource);
|
||||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(worldGenLevel.getSeed()));
|
- 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);
|
NormalNoise normalNoise = NormalNoise.create(worldgenRandom, -4, 1.0);
|
||||||
List<BlockPos> list2 = Lists.newLinkedList();
|
List<BlockPos> list2 = Lists.newLinkedList();
|
||||||
double d = (double)k / (double)geodeConfiguration.outerWallDistance.getMaxValue();
|
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
|
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
|
--- a/src/main/java/net/minecraft/world/level/levelgen/structure/Structure.java
|
||||||
+++ b/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;
|
@@ -233,6 +233,14 @@ public abstract class Structure {
|
||||||
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<Structure> DIRECT_CODEC = BuiltInRegistries.STRUCTURE_TYPE.byNameCodec().dispatch(Structure::type, StructureType::codec);
|
|
||||||
public static final Codec<Holder<Structure>> CODEC = RegistryFileCodec.create(Registries.STRUCTURE, DIRECT_CODEC);
|
|
||||||
@@ -233,6 +238,14 @@ public abstract class Structure {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static WorldgenRandom makeRandom(long seed, ChunkPos chunkPos) {
|
private static WorldgenRandom makeRandom(long seed, ChunkPos chunkPos) {
|
||||||
+ // Leaf start - Matter - Feature Secure Seed
|
+ // Leaf start - Matter - Feature Secure Seed
|
||||||
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
||||||
+ return new WorldgenCryptoRandom(
|
+ return new su.plo.matter.WorldgenCryptoRandom(
|
||||||
+ chunkPos.x, chunkPos.z, Globals.Salt.GENERATE_FEATURE, seed
|
+ 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 worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||||
worldgenRandom.setLargeFeatureSeed(seed, chunkPos.x, chunkPos.z);
|
worldgenRandom.setLargeFeatureSeed(seed, chunkPos.x, chunkPos.z);
|
||||||
return worldgenRandom;
|
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
|
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
|
--- 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
|
+++ b/src/main/java/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java
|
||||||
@@ -11,6 +11,11 @@ import net.minecraft.world.level.chunk.ChunkGeneratorStructureState;
|
@@ -71,8 +71,17 @@ public class RandomSpreadStructurePlacement extends StructurePlacement {
|
||||||
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<RandomSpreadStructurePlacement> CODEC = RecordCodecBuilder.<RandomSpreadStructurePlacement>mapCodec(
|
|
||||||
instance -> placementCodec(instance)
|
|
||||||
@@ -71,8 +76,17 @@ public class RandomSpreadStructurePlacement extends StructurePlacement {
|
|
||||||
public ChunkPos getPotentialStructureChunk(long seed, int chunkX, int chunkZ) {
|
public ChunkPos getPotentialStructureChunk(long seed, int chunkX, int chunkZ) {
|
||||||
int i = Math.floorDiv(chunkX, this.spacing);
|
int i = Math.floorDiv(chunkX, this.spacing);
|
||||||
int j = Math.floorDiv(chunkZ, this.spacing);
|
int j = Math.floorDiv(chunkZ, this.spacing);
|
||||||
@@ -466,34 +354,22 @@ index f873a0a0734b4fe74ba5b5f8ae0cc3c78fa76b9f..3a24937a6e6f47e372a05ebb35931259
|
|||||||
+ // Leaf start - Matter - Feature Secure Seed
|
+ // Leaf start - Matter - Feature Secure Seed
|
||||||
+ WorldgenRandom worldgenRandom;
|
+ WorldgenRandom worldgenRandom;
|
||||||
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
||||||
+ worldgenRandom = new WorldgenCryptoRandom(
|
+ worldgenRandom = new su.plo.matter.WorldgenCryptoRandom(
|
||||||
+ i, j, Globals.Salt.POTENTIONAL_FEATURE, this.salt
|
+ i, j, su.plo.matter.Globals.Salt.POTENTIONAL_FEATURE, this.salt
|
||||||
+ );
|
+ );
|
||||||
+ } else {
|
+ } else {
|
||||||
+ worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
+ worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||||
+ worldgenRandom.setLargeFeatureWithSalt(seed, i, j, this.salt());
|
+ worldgenRandom.setLargeFeatureWithSalt(seed, i, j, this.salt());
|
||||||
+ }
|
+ }
|
||||||
+ // Leaf end - Matter
|
+ // Leaf end - Matter - Feature Secure Seed
|
||||||
int k = this.spacing - this.separation;
|
int k = this.spacing - this.separation;
|
||||||
int l = this.spreadType.evaluate(worldgenRandom, k);
|
int l = this.spreadType.evaluate(worldgenRandom, k);
|
||||||
int m = 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
|
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
|
--- 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
|
+++ b/src/main/java/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java
|
||||||
@@ -20,6 +20,11 @@ import net.minecraft.world.level.levelgen.LegacyRandomSource;
|
@@ -118,8 +118,18 @@ public abstract class StructurePlacement {
|
||||||
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<StructurePlacement> CODEC = BuiltInRegistries.STRUCTURE_PLACEMENT
|
|
||||||
.byNameCodec()
|
|
||||||
@@ -118,8 +123,18 @@ public abstract class StructurePlacement {
|
|
||||||
public abstract StructurePlacementType<?> type();
|
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
|
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
|
+ // Leaf start - Matter - Feature Secure Seed
|
||||||
+ WorldgenRandom worldgenRandom;
|
+ WorldgenRandom worldgenRandom;
|
||||||
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
||||||
+ worldgenRandom = new WorldgenCryptoRandom(
|
+ worldgenRandom = new su.plo.matter.WorldgenCryptoRandom(
|
||||||
+ chunkX, chunkZ, Globals.Salt.UNDEFINED, salt
|
+ chunkX, chunkZ, su.plo.matter.Globals.Salt.UNDEFINED, salt
|
||||||
+ );
|
+ );
|
||||||
+ } else {
|
+ } else {
|
||||||
+ worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
+ worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||||
+ worldgenRandom.setLargeFeatureWithSalt(seed, salt, chunkX, chunkZ);
|
+ worldgenRandom.setLargeFeatureWithSalt(seed, salt, chunkX, chunkZ);
|
||||||
+ }
|
+ }
|
||||||
+ // Leaf end - Matter
|
+ // Leaf end - Matter - Feature Secure Seed
|
||||||
+
|
+
|
||||||
return worldgenRandom.nextFloat() < frequency;
|
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
|
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
|
--- 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
|
+++ b/src/main/java/net/minecraft/world/level/levelgen/structure/pools/JigsawPlacement.java
|
||||||
@@ -43,6 +43,11 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
@@ -65,7 +65,11 @@ public class JigsawPlacement {
|
||||||
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 {
|
|
||||||
ChunkGenerator chunkGenerator = context.chunkGenerator();
|
ChunkGenerator chunkGenerator = context.chunkGenerator();
|
||||||
StructureTemplateManager structureTemplateManager = context.structureTemplateManager();
|
StructureTemplateManager structureTemplateManager = context.structureTemplateManager();
|
||||||
LevelHeightAccessor levelHeightAccessor = context.heightAccessor();
|
LevelHeightAccessor levelHeightAccessor = context.heightAccessor();
|
||||||
- WorldgenRandom worldgenRandom = context.random();
|
- WorldgenRandom worldgenRandom = context.random();
|
||||||
+ // Leaf start - Matter - Feature Secure Seed
|
+ // Leaf start - Matter - Feature Secure Seed
|
||||||
+ WorldgenRandom worldgenRandom = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled ? new WorldgenCryptoRandom(
|
+ WorldgenRandom worldgenRandom = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled
|
||||||
+ context.chunkPos().x, context.chunkPos().z, Globals.Salt.JIGSAW_PLACEMENT, 0
|
+ ? new su.plo.matter.WorldgenCryptoRandom(context.chunkPos().x, context.chunkPos().z, su.plo.matter.Globals.Salt.JIGSAW_PLACEMENT, 0)
|
||||||
+ ) : context.random();
|
+ : context.random();
|
||||||
+ // Leaf end - Matter
|
+ // Leaf end - Matter - Feature Secure Seed
|
||||||
Registry<StructureTemplatePool> registry = registryAccess.registryOrThrow(Registries.TEMPLATE_POOL);
|
Registry<StructureTemplatePool> registry = registryAccess.registryOrThrow(Registries.TEMPLATE_POOL);
|
||||||
Rotation rotation = Rotation.getRandom(worldgenRandom);
|
Rotation rotation = Rotation.getRandom(worldgenRandom);
|
||||||
StructureTemplatePool structureTemplatePool = structurePool.unwrapKey()
|
StructureTemplatePool structureTemplatePool = structurePool.unwrapKey()
|
||||||
@@ -568,81 +432,76 @@ index 7f4c5e9355a6f562f668e9b8134bfe65dde35f90..7a1c21696f6531c7dded774f45073df1
|
|||||||
public class MineshaftStructure extends Structure {
|
public class MineshaftStructure extends Structure {
|
||||||
public static final MapCodec<MineshaftStructure> CODEC = RecordCodecBuilder.mapCodec(
|
public static final MapCodec<MineshaftStructure> CODEC = RecordCodecBuilder.mapCodec(
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
|
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
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
|
||||||
+++ b/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
|
@Override
|
||||||
public boolean isSlimeChunk() {
|
public boolean isSlimeChunk() {
|
||||||
// 987234911L is deterimined in EntitySlime when seeing if a slime can spawn in a chunk
|
// 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
|
- 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
|
+ // 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;
|
+ return this.worldServer.paperConfig().entities.spawning.allChunksAreSlimeChunks || isSlimeChunk;
|
||||||
+ // Leaf end - Matter
|
+ // Leaf end - Matter - Feature Secure Seed
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
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
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
+++ b/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
|
@@ -1387,7 +1387,11 @@ public final class CraftServer implements Server {
|
||||||
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 {
|
|
||||||
iregistrycustom_dimension = leveldataanddimensions.dimensions().dimensionsRegistryAccess();
|
iregistrycustom_dimension = leveldataanddimensions.dimensions().dimensionsRegistryAccess();
|
||||||
} else {
|
} else {
|
||||||
LevelSettings worldsettings;
|
LevelSettings worldsettings;
|
||||||
- WorldOptions worldoptions = new WorldOptions(creator.seed(), creator.generateStructures(), false);
|
- 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;
|
WorldDimensions worlddimensions;
|
||||||
|
|
||||||
DedicatedServerProperties.WorldDimensionData properties = new DedicatedServerProperties.WorldDimensionData(GsonHelper.parse((creator.generatorSettings().isEmpty()) ? "{}" : creator.generatorSettings()), creator.type().name().toLowerCase(Locale.ROOT));
|
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
|
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
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..47bbf9b3728623d73043c3f4df188486959e7b59
|
index 0000000000000000000000000000000000000000..e2eb46cdec10fb3c563eede6f8540768bb6da544
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/org/dreeam/leaf/config/modules/misc/SecureSeed.java
|
+++ b/src/main/java/org/dreeam/leaf/config/modules/misc/SecureSeed.java
|
||||||
@@ -0,0 +1,24 @@
|
@@ -0,0 +1,24 @@
|
||||||
+package org.dreeam.leaf.config.modules.misc;
|
+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.EnumConfigCategory;
|
||||||
+import org.dreeam.leaf.config.IConfigModule;
|
|
||||||
+
|
+
|
||||||
+public class SecureSeed implements IConfigModule {
|
+public class SecureSeed extends ConfigModules {
|
||||||
+
|
+
|
||||||
+ @Override
|
+ public String getBasePath() {
|
||||||
+ public EnumConfigCategory getCategory() {
|
+ return EnumConfigCategory.MISC.getBaseKeyName() + ".secure-seed";
|
||||||
+ return EnumConfigCategory.MISC;
|
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @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;
|
+ 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
|
diff --git a/src/main/java/su/plo/matter/Globals.java b/src/main/java/su/plo/matter/Globals.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..9d544b302812c691f9046a48b51c8f7b3b30b149
|
index 0000000000000000000000000000000000000000..d325d1617094e12ca011f5ef0e259cd806e35dcc
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/su/plo/matter/Globals.java
|
+++ b/src/main/java/su/plo/matter/Globals.java
|
||||||
@@ -0,0 +1,96 @@
|
@@ -0,0 +1,94 @@
|
||||||
+package su.plo.matter;
|
+package su.plo.matter;
|
||||||
+
|
+
|
||||||
+import com.google.common.collect.Iterables;
|
+import com.google.common.collect.Iterables;
|
||||||
@@ -700,43 +559,41 @@ index 0000000000000000000000000000000000000000..9d544b302812c691f9046a48b51c8f7b
|
|||||||
+ return seed;
|
+ return seed;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
+ // 1024-bit string -> 16 * 64 long[]
|
||||||
+ public static Optional<long[]> parseSeed(String seedStr) {
|
+ public static Optional<long[]> parseSeed(String seedStr) {
|
||||||
+ if (seedStr.isEmpty()) return Optional.empty();
|
+ if (seedStr.isEmpty()) return Optional.empty();
|
||||||
+
|
+
|
||||||
+ try {
|
+ if (seedStr.length() != WORLD_SEED_BITS) {
|
||||||
+ long[] seed = new long[WORLD_SEED_LONGS];
|
+ throw new IllegalArgumentException("Secure seed length must be " + WORLD_SEED_BITS + "-bit but found " + seedStr.length() + "-bit.");
|
||||||
+ 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();
|
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
|
+ 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) {
|
+ public static String seedToString(long[] seed) {
|
||||||
+ BigInteger seedBigInt = BigInteger.ZERO;
|
+ StringBuilder sb = new StringBuilder();
|
||||||
+ for (int i = WORLD_SEED_LONGS - 1; i >= 0; i--) {
|
+
|
||||||
+ BigInteger val = BigInteger.valueOf(seed[i]);
|
+ for (long longV : seed) {
|
||||||
+ if (val.signum() < 0) {
|
+ // Convert to 64-bit binary string per long
|
||||||
+ val = val.add(BigInteger.ONE.shiftLeft(64));
|
+ // Use format to keep 64-bit length, and use 0 to complete space
|
||||||
+ }
|
+ String binaryStr = String.format("%64s", Long.toBinaryString(longV)).replace(' ', '0');
|
||||||
+ seedBigInt = seedBigInt.shiftLeft(64).add(val);
|
+
|
||||||
|
+ sb.append(binaryStr);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ // Ensure the output is 1024-bit length
|
+ return sb.toString();
|
||||||
+ 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();
|
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/su/plo/matter/Hashing.java b/src/main/java/su/plo/matter/Hashing.java
|
diff --git a/src/main/java/su/plo/matter/Hashing.java b/src/main/java/su/plo/matter/Hashing.java
|
||||||
@@ -7,33 +7,23 @@ Original license: GPLv3
|
|||||||
Original project: https://github.com/plasmoapp/matter
|
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
|
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
|
--- a/src/main/java/net/minecraft/server/commands/SeedCommand.java
|
||||||
+++ b/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;
|
@@ -12,6 +12,17 @@ public class SeedCommand {
|
||||||
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<CommandSourceStack> dispatcher, boolean dedicated) {
|
|
||||||
dispatcher.register(Commands.literal("seed").requires(source -> !dedicated || source.hasPermission(2)).executes(context -> {
|
|
||||||
long l = context.getSource().getLevel().getSeed();
|
long l = context.getSource().getLevel().getSeed();
|
||||||
Component component = ComponentUtils.copyOnClickText(String.valueOf(l));
|
Component component = ComponentUtils.copyOnClickText(String.valueOf(l));
|
||||||
context.getSource().sendSuccess(() -> Component.translatable("commands.seed.success", component), false);
|
context.getSource().sendSuccess(() -> Component.translatable("commands.seed.success", component), false);
|
||||||
+
|
+
|
||||||
+ // Leaf start - Matter - SecureSeed Command
|
+ // Leaf start - Matter - SecureSeed Command
|
||||||
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
||||||
+ Globals.setupGlobals(context.getSource().getLevel());
|
+ su.plo.matter.Globals.setupGlobals(context.getSource().getLevel());
|
||||||
+ String seedStr = Globals.seedToString(Globals.worldSeed);
|
+ String seedStr = su.plo.matter.Globals.seedToString(su.plo.matter.Globals.worldSeed);
|
||||||
+ Component featureSeedComponent = ComponentUtils.copyOnClickText(seedStr);
|
+ Component featureSeedComponent = ComponentUtils.copyOnClickText(seedStr);
|
||||||
+
|
+
|
||||||
+ context.getSource().sendSuccess(() -> Component.translatable(("Feature seed: %s"), featureSeedComponent), false);
|
+ context.getSource().sendSuccess(() -> Component.translatable(("Feature seed: %s"), featureSeedComponent), false);
|
||||||
+ }
|
+ }
|
||||||
+ // Leaf end - Matter
|
+ // Leaf end - Matter - SecureSeed Command
|
||||||
+
|
+
|
||||||
return (int)l;
|
return (int)l;
|
||||||
}));
|
}));
|
||||||
Reference in New Issue
Block a user