mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
370 lines
30 KiB
Diff
370 lines
30 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
|
Date: Tue, 9 Nov 2077 00:00:00 +0800
|
|
Subject: [PATCH] Faster random generator
|
|
|
|
This patch replaces LegacyRandomSource with FasterRandomSource by default,
|
|
which is faster in general.
|
|
|
|
Benchmark results (10,000,000 iterations) (Azul Zulu 23.0.1)
|
|
|
|
FasterRandomSource (Leaf) (Backed by Xoroshiro128PlusPlus): 51,633,700 ns
|
|
LegacyRandomSource (Vanilla): 254,857,500 ns
|
|
ThreadUnsafeRandom (Moonrise): 102,265,100 ns
|
|
SimpleThreadUnsafeRandom (Moonrise): 97,054,600 ns
|
|
|
|
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
|
index 91574985958950dffe0f393d7dfac4818af3b151..eaaa66c4d86d4ebda0acf8f1dbe8ecb55aa28285 100644
|
|
--- a/net/minecraft/server/level/ServerChunkCache.java
|
|
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
|
@@ -154,7 +154,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
|
}
|
|
// Paper end - rewrite chunk system
|
|
// Paper start - chunk tick iteration optimisations
|
|
- private final ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom shuffleRandom = new ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom(0L);
|
|
+ private final net.minecraft.world.level.levelgen.BitRandomSource shuffleRandom = org.dreeam.leaf.config.modules.opt.FastRNG.enabled ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom(0L); // Leaf - Faster random generator
|
|
private void iterateTickingChunksFaster() {
|
|
final ServerLevel world = this.level;
|
|
final int randomTickSpeed = world.getGameRules().getInt(GameRules.RULE_RANDOMTICKING);
|
|
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
|
index d57a3a9b8ebd2f5d381336a0b5e81d71e2de6530..08d12a1acc3a672a77daa15f82392cd603c30283 100644
|
|
--- a/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
|
@@ -895,7 +895,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
private void optimiseRandomTick(final LevelChunk chunk, final int tickSpeed) {
|
|
final LevelChunkSection[] sections = chunk.getSections();
|
|
final int minSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMinSection((ServerLevel)(Object)this);
|
|
- final ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom simpleRandom = this.simpleRandom;
|
|
+ final net.minecraft.world.level.levelgen.BitRandomSource simpleRandom = this.simpleRandom; // Leaf - Faster random generator - upcasting
|
|
final boolean doubleTickFluids = !ca.spottedleaf.moonrise.common.PlatformHooks.get().configFixMC224294();
|
|
|
|
final ChunkPos cpos = chunk.getPos();
|
|
@@ -944,7 +944,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
private int currentIceAndSnowTick = 0; protected void resetIceAndSnowTick() { this.currentIceAndSnowTick = this.simpleRandom.nextInt(16); } // Gale - Airplane - optimize random calls in chunk ticking
|
|
|
|
public void tickChunk(LevelChunk chunk, int randomTickSpeed) {
|
|
- final ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom simpleRandom = this.simpleRandom; // Paper - optimise random ticking
|
|
+ final net.minecraft.world.level.levelgen.BitRandomSource simpleRandom = this.simpleRandom; // Paper - optimise random ticking // Leaf - Faster random generator - upcasting
|
|
ChunkPos pos = chunk.getPos();
|
|
int minBlockX = pos.getMinBlockX();
|
|
int minBlockZ = pos.getMinBlockZ();
|
|
diff --git a/net/minecraft/util/RandomSource.java b/net/minecraft/util/RandomSource.java
|
|
index 8516d47b0ba79d91638837199e7ae0fb6cb44a79..4f4b55dd099dd2c2fea118b18b53588147e59bba 100644
|
|
--- a/net/minecraft/util/RandomSource.java
|
|
+++ b/net/minecraft/util/RandomSource.java
|
|
@@ -15,18 +15,40 @@ public interface RandomSource {
|
|
return create(RandomSupport.generateUniqueSeed());
|
|
}
|
|
|
|
+ // Leaf start - Faster random generator
|
|
@Deprecated
|
|
static RandomSource createThreadSafe() {
|
|
- return new ThreadSafeLegacyRandomSource(RandomSupport.generateUniqueSeed());
|
|
+ return org.dreeam.leaf.config.modules.opt.FastRNG.enabled
|
|
+ ? new org.dreeam.leaf.util.math.random.FasterRandomSource(RandomSupport.generateUniqueSeed())
|
|
+ : new ThreadSafeLegacyRandomSource(RandomSupport.generateUniqueSeed());
|
|
}
|
|
|
|
static RandomSource create(long seed) {
|
|
- return new LegacyRandomSource(seed);
|
|
+ return org.dreeam.leaf.config.modules.opt.FastRNG.enabled
|
|
+ ? new org.dreeam.leaf.util.math.random.FasterRandomSource(seed)
|
|
+ : new LegacyRandomSource(seed);
|
|
+ }
|
|
+
|
|
+ static RandomSource createForSlimeChunk(long seed) {
|
|
+ return org.dreeam.leaf.config.modules.opt.FastRNG.enabled && !org.dreeam.leaf.config.modules.opt.FastRNG.useLegacyForSlimeChunk
|
|
+ ? new org.dreeam.leaf.util.math.random.FasterRandomSource(seed)
|
|
+ : new LegacyRandomSource(seed);
|
|
}
|
|
|
|
static RandomSource createNewThreadLocalInstance() {
|
|
- return new SingleThreadedRandomSource(ThreadLocalRandom.current().nextLong());
|
|
+ return org.dreeam.leaf.config.modules.opt.FastRNG.enabled
|
|
+ ? new org.dreeam.leaf.util.math.random.FasterRandomSource(RandomSupport.generateUniqueSeed())
|
|
+ : new SingleThreadedRandomSource(ThreadLocalRandom.current().nextLong());
|
|
+ }
|
|
+
|
|
+ static RandomSource createLegacy() {
|
|
+ return new LegacyRandomSource(RandomSupport.generateUniqueSeed());
|
|
+ }
|
|
+
|
|
+ static RandomSource createLegacy(long seed) {
|
|
+ return new LegacyRandomSource(seed);
|
|
}
|
|
+ // Leaf end - Faster random generator
|
|
|
|
RandomSource fork();
|
|
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index 305181410e025d857608c866592bcc44e3654f31..f49bfe0bbb8d8373bd7a11fa3c1a828a46da6a4b 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -155,7 +155,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
}
|
|
|
|
// Paper start - Share random for entities to make them more random
|
|
- public static RandomSource SHARED_RANDOM = new RandomRandomSource();
|
|
+ public static RandomSource SHARED_RANDOM = org.dreeam.leaf.config.modules.opt.FastRNG.enabled ? org.dreeam.leaf.util.math.random.FasterRandomSource.SHARED_INSTANCE : new RandomRandomSource(); // Leaf - Faster random generator
|
|
// Paper start - replace random
|
|
private static final class RandomRandomSource extends ca.spottedleaf.moonrise.common.util.ThreadUnsafeRandom {
|
|
public RandomRandomSource() {
|
|
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
|
|
index 3bd42eb81eae3af9323021a5dc6edaa06dfcaead..8ebfb2f5cf439190ea9bd4ad81d737fbcd4514c2 100644
|
|
--- a/net/minecraft/world/level/Level.java
|
|
+++ b/net/minecraft/world/level/Level.java
|
|
@@ -117,7 +117,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
|
|
public float rainLevel;
|
|
protected float oThunderLevel;
|
|
public float thunderLevel;
|
|
- public final RandomSource random = new ca.spottedleaf.moonrise.common.util.ThreadUnsafeRandom(net.minecraft.world.level.levelgen.RandomSupport.generateUniqueSeed()); // Paper - replace random
|
|
+ public final RandomSource random = org.dreeam.leaf.config.modules.opt.FastRNG.enabled ? new org.dreeam.leaf.util.math.random.FasterRandomSource(net.minecraft.world.level.levelgen.RandomSupport.generateUniqueSeed()) : new ca.spottedleaf.moonrise.common.util.ThreadUnsafeRandom(net.minecraft.world.level.levelgen.RandomSupport.generateUniqueSeed()); // Paper - replace random // Leaf - Faster random generator
|
|
@Deprecated
|
|
private final RandomSource threadSafeRandom = RandomSource.createThreadSafe();
|
|
private final Holder<DimensionType> dimensionTypeRegistration;
|
|
@@ -169,7 +169,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
|
|
private int tileTickPosition;
|
|
public final Map<ServerExplosion.CacheKey, Float> explosionDensityCache = new java.util.HashMap<>(); // Paper - Optimize explosions
|
|
public java.util.ArrayDeque<net.minecraft.world.level.block.RedstoneTorchBlock.Toggle> redstoneUpdateInfos; // Paper - Faster redstone torch rapid clock removal; Move from Map in BlockRedstoneTorch to here
|
|
- public final ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom simpleRandom = new ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom(net.minecraft.world.level.levelgen.RandomSupport.generateUniqueSeed()); // Gale - Pufferfish - move random tick random
|
|
+ public final net.minecraft.world.level.levelgen.BitRandomSource simpleRandom = org.dreeam.leaf.config.modules.opt.FastRNG.enabled ? new org.dreeam.leaf.util.math.random.FasterRandomSource(net.minecraft.world.level.levelgen.RandomSupport.generateUniqueSeed()) : new ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom(net.minecraft.world.level.levelgen.RandomSupport.generateUniqueSeed()); // Gale - Pufferfish - move random tick random // Leaf - Faster random generator
|
|
|
|
// Purpur start - Add adjustable breeding cooldown to config
|
|
private com.google.common.cache.Cache<BreedingCooldownPair, Object> playerBreedingCooldowns;
|
|
diff --git a/net/minecraft/world/level/biome/Biome.java b/net/minecraft/world/level/biome/Biome.java
|
|
index bad1a03167f7586e5279592adcb43350c9b528cd..336d42d4e85716843633030ba1aa21b7901ca601 100644
|
|
--- a/net/minecraft/world/level/biome/Biome.java
|
|
+++ b/net/minecraft/world/level/biome/Biome.java
|
|
@@ -55,14 +55,14 @@ public final class Biome {
|
|
);
|
|
public static final Codec<Holder<Biome>> CODEC = RegistryFileCodec.create(Registries.BIOME, DIRECT_CODEC);
|
|
public static final Codec<HolderSet<Biome>> LIST_CODEC = RegistryCodecs.homogeneousList(Registries.BIOME, DIRECT_CODEC);
|
|
- private static final PerlinSimplexNoise TEMPERATURE_NOISE = new PerlinSimplexNoise(new WorldgenRandom(new LegacyRandomSource(1234L)), ImmutableList.of(0));
|
|
+ private static final PerlinSimplexNoise TEMPERATURE_NOISE = new PerlinSimplexNoise(new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(1234L) : new LegacyRandomSource(1234L)), ImmutableList.of(0)); // Leaf - Faster random generator
|
|
static final PerlinSimplexNoise FROZEN_TEMPERATURE_NOISE = new PerlinSimplexNoise(
|
|
- new WorldgenRandom(new LegacyRandomSource(3456L)), ImmutableList.of(-2, -1, 0)
|
|
+ new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(3456L) : new LegacyRandomSource(3456L)), ImmutableList.of(-2, -1, 0) // Leaf - Faster random generator
|
|
);
|
|
@Deprecated(
|
|
forRemoval = true
|
|
)
|
|
- public static final PerlinSimplexNoise BIOME_INFO_NOISE = new PerlinSimplexNoise(new WorldgenRandom(new LegacyRandomSource(2345L)), ImmutableList.of(0));
|
|
+ public static final PerlinSimplexNoise BIOME_INFO_NOISE = new PerlinSimplexNoise(new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(2345L) : new LegacyRandomSource(2345L)), ImmutableList.of(0)); // Leaf - Faster random generator
|
|
private static final int TEMPERATURE_CACHE_SIZE = 1024;
|
|
public final Biome.ClimateSettings climateSettings;
|
|
private final BiomeGenerationSettings generationSettings;
|
|
diff --git a/net/minecraft/world/level/chunk/ChunkGenerator.java b/net/minecraft/world/level/chunk/ChunkGenerator.java
|
|
index 23806f5f0c6c4ec9a86a6ea13b89b4f57372e6f1..e1ebbfab87aed9cc633f2fedb1e6edeca4ddc2ec 100644
|
|
--- a/net/minecraft/world/level/chunk/ChunkGenerator.java
|
|
+++ b/net/minecraft/world/level/chunk/ChunkGenerator.java
|
|
@@ -455,7 +455,7 @@ public abstract class ChunkGenerator {
|
|
int x = chunk.getPos().x;
|
|
int z = chunk.getPos().z;
|
|
for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) {
|
|
- WorldgenRandom seededrandom = new WorldgenRandom(new net.minecraft.world.level.levelgen.LegacyRandomSource(level.getSeed()));
|
|
+ WorldgenRandom seededrandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(level.getSeed()) : new net.minecraft.world.level.levelgen.LegacyRandomSource(level.getSeed())); // Leaf - Faster random generator
|
|
seededrandom.setDecorationSeed(level.getSeed(), x, z);
|
|
populator.populate(world, new org.bukkit.craftbukkit.util.RandomSourceWrapper.RandomWrapper(seededrandom), x, z, limitedRegion);
|
|
}
|
|
@@ -560,7 +560,7 @@ public abstract class ChunkGenerator {
|
|
if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
|
worldgenRandom = new su.plo.matter.WorldgenCryptoRandom(pos.x, pos.z, su.plo.matter.Globals.Salt.GENERATE_FEATURE, 0);
|
|
} else {
|
|
- worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
|
+ worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L)); // Leaf - Faster random generator
|
|
worldgenRandom.setLargeFeatureSeed(structureState.getLevelSeed(), pos.x, pos.z);
|
|
}
|
|
// Leaf end - Matter - Secure Seed
|
|
diff --git a/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java b/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
|
index 426692d9627f46d708f551bd22ce3c52b2a23b37..8a19fd2b816b07a7374cb9dc96896a122f95db20 100644
|
|
--- a/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
|
+++ b/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
|
@@ -208,7 +208,7 @@ public class ChunkGeneratorStructureState {
|
|
// Leaf start - Matter - Secure Seed
|
|
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();
|
|
+ : RandomSource.createLegacy(); // Leaf - Faster random generator
|
|
// Leaf end - Matter - Secure Seed
|
|
if (!org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
|
// Paper start - Add missing structure set seed configs
|
|
diff --git a/net/minecraft/world/level/levelgen/DensityFunctions.java b/net/minecraft/world/level/levelgen/DensityFunctions.java
|
|
index 77731406cb3dc417aa2fe1cb4352f3d2d7d498aa..1420dac658c4b27d25882a6d7dd3efb2c5b7e720 100644
|
|
--- a/net/minecraft/world/level/levelgen/DensityFunctions.java
|
|
+++ b/net/minecraft/world/level/levelgen/DensityFunctions.java
|
|
@@ -518,7 +518,7 @@ public final class DensityFunctions {
|
|
// Paper end - Perf: Optimize end generation
|
|
|
|
public EndIslandDensityFunction(long seed) {
|
|
- RandomSource randomSource = new LegacyRandomSource(seed);
|
|
+ RandomSource randomSource = org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(seed) : new LegacyRandomSource(seed); // Leaf - Faster random generator
|
|
randomSource.consumeCount(17292);
|
|
this.islandNoise = new SimplexNoise(randomSource);
|
|
}
|
|
diff --git a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
|
index 65728ef17e63d71833677fdcbd5bb90794b4822b..57ae4aaf1431021daf77c5638038d4910a358155 100644
|
|
--- a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
|
+++ b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
|
@@ -254,7 +254,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator {
|
|
WorldGenRegion level, long seed, RandomState random, BiomeManager biomeManager, StructureManager structureManager, ChunkAccess chunk
|
|
) {
|
|
BiomeManager biomeManager1 = biomeManager.withDifferentSource((x, y, z) -> this.biomeSource.getNoiseBiome(x, y, z, random.sampler()));
|
|
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(RandomSupport.generateUniqueSeed()));
|
|
+ WorldgenRandom worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(RandomSupport.generateUniqueSeed()) : new LegacyRandomSource(RandomSupport.generateUniqueSeed())); // Leaf - Faster random generator
|
|
int i = 8;
|
|
ChunkPos pos = chunk.getPos();
|
|
NoiseChunk noiseChunk = chunk.getOrCreateNoiseChunk(chunkAccess -> this.createNoiseChunk(chunkAccess, structureManager, Blender.of(level), random));
|
|
@@ -420,7 +420,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator {
|
|
if (!this.settings.value().disableMobGeneration()) {
|
|
ChunkPos center = level.getCenter();
|
|
Holder<Biome> biome = level.getBiome(center.getWorldPosition().atY(level.getMaxY()));
|
|
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(RandomSupport.generateUniqueSeed()));
|
|
+ WorldgenRandom worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(RandomSupport.generateUniqueSeed()) : new LegacyRandomSource(RandomSupport.generateUniqueSeed())); // Leaf - Faster random generator
|
|
worldgenRandom.setDecorationSeed(level.getSeed(), center.getMinBlockX(), center.getMinBlockZ());
|
|
NaturalSpawner.spawnMobsForChunkGeneration(level, biome, center, worldgenRandom);
|
|
}
|
|
diff --git a/net/minecraft/world/level/levelgen/WorldgenRandom.java b/net/minecraft/world/level/levelgen/WorldgenRandom.java
|
|
index c2d7cd788071e25b8ba2503c30ae80c7a9f353ed..a22508c50b34ca48328595cc7b69e008bf17d370 100644
|
|
--- a/net/minecraft/world/level/levelgen/WorldgenRandom.java
|
|
+++ b/net/minecraft/world/level/levelgen/WorldgenRandom.java
|
|
@@ -69,7 +69,7 @@ public class WorldgenRandom extends LegacyRandomSource {
|
|
}
|
|
|
|
public static RandomSource seedSlimeChunk(int chunkX, int chunkZ, long levelSeed, long salt) {
|
|
- return RandomSource.create(levelSeed + chunkX * chunkX * 4987142 + chunkX * 5947611 + chunkZ * chunkZ * 4392871L + chunkZ * 389711 ^ salt);
|
|
+ return RandomSource.createForSlimeChunk(levelSeed + chunkX * chunkX * 4987142 + chunkX * 5947611 + chunkZ * chunkZ * 4392871L + chunkZ * 389711 ^ salt); // Leaf - Faster random generator
|
|
}
|
|
|
|
public static enum Algorithm {
|
|
diff --git a/net/minecraft/world/level/levelgen/feature/GeodeFeature.java b/net/minecraft/world/level/levelgen/feature/GeodeFeature.java
|
|
index 8df6dadfeb2c282bc3c3f521d31f7277caa77790..e30dc383695727c31bee46f7dbaf82619bb8a6fa 100644
|
|
--- a/net/minecraft/world/level/levelgen/feature/GeodeFeature.java
|
|
+++ b/net/minecraft/world/level/levelgen/feature/GeodeFeature.java
|
|
@@ -44,7 +44,7 @@ public class GeodeFeature extends Feature<GeodeConfiguration> {
|
|
// Leaf start - Matter - 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()));
|
|
+ : new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(worldGenLevel.getSeed()) : new LegacyRandomSource(worldGenLevel.getSeed())); // Leaf - Faster random generator
|
|
// Leaf end - Matter - Secure Seed
|
|
NormalNoise normalNoise = NormalNoise.create(worldgenRandom, -4, 1.0);
|
|
List<BlockPos> list1 = Lists.newLinkedList();
|
|
diff --git a/net/minecraft/world/level/levelgen/feature/stateproviders/DualNoiseProvider.java b/net/minecraft/world/level/levelgen/feature/stateproviders/DualNoiseProvider.java
|
|
index 48ab8a568d97052fe205e6a1f89862ee23d65abb..a190b5e890cf34dd1aa46cb9e283f05154fbe3e5 100644
|
|
--- a/net/minecraft/world/level/levelgen/feature/stateproviders/DualNoiseProvider.java
|
|
+++ b/net/minecraft/world/level/levelgen/feature/stateproviders/DualNoiseProvider.java
|
|
@@ -43,7 +43,7 @@ public class DualNoiseProvider extends NoiseProvider {
|
|
this.variety = variety;
|
|
this.slowNoiseParameters = slowNoiseParameters;
|
|
this.slowScale = slowScale;
|
|
- this.slowNoise = NormalNoise.create(new WorldgenRandom(new LegacyRandomSource(seed)), slowNoiseParameters);
|
|
+ this.slowNoise = NormalNoise.create(new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(seed) : new LegacyRandomSource(seed)), slowNoiseParameters); // Leaf - Faster random generator
|
|
}
|
|
|
|
@Override
|
|
diff --git a/net/minecraft/world/level/levelgen/feature/stateproviders/NoiseBasedStateProvider.java b/net/minecraft/world/level/levelgen/feature/stateproviders/NoiseBasedStateProvider.java
|
|
index f685372a39976f823202f2d9015c14f835b94a0c..bdd1b4ab758fc653df4adad7633ef430ebb89dbe 100644
|
|
--- a/net/minecraft/world/level/levelgen/feature/stateproviders/NoiseBasedStateProvider.java
|
|
+++ b/net/minecraft/world/level/levelgen/feature/stateproviders/NoiseBasedStateProvider.java
|
|
@@ -28,7 +28,7 @@ public abstract class NoiseBasedStateProvider extends BlockStateProvider {
|
|
this.seed = seed;
|
|
this.parameters = parameters;
|
|
this.scale = scale;
|
|
- this.noise = NormalNoise.create(new WorldgenRandom(new LegacyRandomSource(seed)), parameters);
|
|
+ this.noise = NormalNoise.create(new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(seed) : new LegacyRandomSource(seed)), parameters); // Leaf - Faster random generator
|
|
}
|
|
|
|
protected double getNoiseValue(BlockPos pos, double delta) {
|
|
diff --git a/net/minecraft/world/level/levelgen/structure/Structure.java b/net/minecraft/world/level/levelgen/structure/Structure.java
|
|
index 28281491be6b54de18c49ff0d52e302575d3ad38..3aa35d67df8f9118c944cebfcb675cccd9d99be2 100644
|
|
--- a/net/minecraft/world/level/levelgen/structure/Structure.java
|
|
+++ b/net/minecraft/world/level/levelgen/structure/Structure.java
|
|
@@ -254,7 +254,7 @@ public abstract class Structure {
|
|
return new su.plo.matter.WorldgenCryptoRandom(chunkPos.x, chunkPos.z, su.plo.matter.Globals.Salt.GENERATE_FEATURE, seed);
|
|
}
|
|
// Leaf end - Matter - Secure Seed
|
|
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
|
+ WorldgenRandom worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L)); // Leaf - Faster random generator
|
|
worldgenRandom.setLargeFeatureSeed(seed, chunkPos.x, chunkPos.z);
|
|
return worldgenRandom;
|
|
}
|
|
diff --git a/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java b/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java
|
|
index 6584c9320361dbbdea1899ab9e43b444de5006a6..06083cc7612ef28bcd9264bb21ab0bbbe0837589 100644
|
|
--- a/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java
|
|
+++ b/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java
|
|
@@ -72,7 +72,7 @@ public class RandomSpreadStructurePlacement extends StructurePlacement {
|
|
if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
|
worldgenRandom = new su.plo.matter.WorldgenCryptoRandom(i, i1, su.plo.matter.Globals.Salt.POTENTIONAL_FEATURE, this.salt);
|
|
} else {
|
|
- worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
|
+ worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L)); // Leaf - Faster random generator
|
|
worldgenRandom.setLargeFeatureWithSalt(seed, i, i1, this.salt());
|
|
}
|
|
// Leaf end - Matter - Secure Seed
|
|
diff --git a/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java b/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java
|
|
index ee60717e39928a9f89ad6c7a9b3b52ac156871e6..daed7cc619d5a0b7d7a75e013cb72ed88d57de6c 100644
|
|
--- a/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java
|
|
+++ b/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java
|
|
@@ -124,7 +124,7 @@ public abstract class StructurePlacement {
|
|
if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
|
worldgenRandom = new su.plo.matter.WorldgenCryptoRandom(regionX, regionZ, su.plo.matter.Globals.Salt.UNDEFINED, salt);
|
|
} else {
|
|
- worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
|
+ worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L)); // Leaf - Faster random generator
|
|
worldgenRandom.setLargeFeatureWithSalt(levelSeed, salt, regionX, regionZ);
|
|
}
|
|
// Leaf end - Matter - Secure Seed
|
|
@@ -133,7 +133,7 @@ public abstract class StructurePlacement {
|
|
}
|
|
|
|
private static boolean legacyProbabilityReducerWithDouble(long baseSeed, int salt, int chunkX, int chunkZ, float probability, @org.jetbrains.annotations.Nullable Integer saltOverride) { // Paper - Add missing structure set seed configs
|
|
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
|
+ WorldgenRandom worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L)); // Leaf - Faster random generator
|
|
if (saltOverride == null) { // Paper - Add missing structure set seed configs
|
|
worldgenRandom.setLargeFeatureSeed(baseSeed, chunkX, chunkZ);
|
|
// Paper start - Add missing structure set seed configs
|
|
@@ -145,7 +145,7 @@ public abstract class StructurePlacement {
|
|
}
|
|
|
|
private static boolean legacyArbitrarySaltProbabilityReducer(long levelSeed, int salt, int regionX, int regionZ, float probability, @org.jetbrains.annotations.Nullable Integer saltOverride) { // Paper - Add missing structure set seed configs
|
|
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
|
+ WorldgenRandom worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L)); // Leaf - Faster random generator
|
|
worldgenRandom.setLargeFeatureWithSalt(levelSeed, regionX, regionZ, saltOverride != null ? saltOverride : HIGHLY_ARBITRARY_RANDOM_SALT); // Paper - Add missing structure set seed configs
|
|
return worldgenRandom.nextFloat() < probability;
|
|
}
|
|
@@ -153,7 +153,7 @@ public abstract class StructurePlacement {
|
|
private static boolean legacyPillagerOutpostReducer(long levelSeed, int salt, int regionX, int regionZ, float probability, @org.jetbrains.annotations.Nullable Integer saltOverride) { // Paper - Add missing structure set seed configs; ignore here
|
|
int i = regionX >> 4;
|
|
int i1 = regionZ >> 4;
|
|
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
|
+ WorldgenRandom worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L)); // Leaf - Faster random generator
|
|
worldgenRandom.setSeed(i ^ i1 << 4 ^ levelSeed);
|
|
worldgenRandom.nextInt();
|
|
return worldgenRandom.nextInt((int)(1.0F / probability)) == 0;
|
|
diff --git a/net/minecraft/world/level/levelgen/structure/structures/OceanMonumentStructure.java b/net/minecraft/world/level/levelgen/structure/structures/OceanMonumentStructure.java
|
|
index 6941b2c89df8a7c77166e3fb76150cbc852371d9..661c26c4b981d504988c7498be45a5ddacaf90d8 100644
|
|
--- a/net/minecraft/world/level/levelgen/structure/structures/OceanMonumentStructure.java
|
|
+++ b/net/minecraft/world/level/levelgen/structure/structures/OceanMonumentStructure.java
|
|
@@ -56,7 +56,7 @@ public class OceanMonumentStructure extends Structure {
|
|
if (piecesContainer.isEmpty()) {
|
|
return piecesContainer;
|
|
} else {
|
|
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(RandomSupport.generateUniqueSeed()));
|
|
+ WorldgenRandom worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(RandomSupport.generateUniqueSeed()) : new LegacyRandomSource(RandomSupport.generateUniqueSeed())); // Leaf - Faster random generator
|
|
worldgenRandom.setLargeFeatureSeed(seed, chunkPos.x, chunkPos.z);
|
|
StructurePiece structurePiece = piecesContainer.pieces().get(0);
|
|
BoundingBox boundingBox = structurePiece.getBoundingBox();
|
|
diff --git a/net/minecraft/world/level/levelgen/synth/PerlinSimplexNoise.java b/net/minecraft/world/level/levelgen/synth/PerlinSimplexNoise.java
|
|
index 434e72fd770a259d67e5e7f110f49b09bab6c54e..720098d50ecefeff25e8f032e33742ad6bd6ab21 100644
|
|
--- a/net/minecraft/world/level/levelgen/synth/PerlinSimplexNoise.java
|
|
+++ b/net/minecraft/world/level/levelgen/synth/PerlinSimplexNoise.java
|
|
@@ -43,7 +43,7 @@ public class PerlinSimplexNoise {
|
|
|
|
if (i1 > 0) {
|
|
long l = (long)(simplexNoise.getValue(simplexNoise.xo, simplexNoise.yo, simplexNoise.zo) * 9.223372E18F);
|
|
- RandomSource randomSource = new WorldgenRandom(new LegacyRandomSource(l));
|
|
+ RandomSource randomSource = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(l) : new LegacyRandomSource(l)); // Leaf - Faster random generator
|
|
|
|
for (int i5 = i3 - 1; i5 >= 0; i5--) {
|
|
if (i5 < i2 && octaves.contains(i3 - i5)) {
|