mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
349 lines
29 KiB
Diff
349 lines
29 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 6f14f321d2fa83abab0aa1b262ff873b208a67be..5d9c3054e32636b051cc6b210c71bb722c1de1c8 100644
|
|
--- a/net/minecraft/server/level/ServerChunkCache.java
|
|
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
|
@@ -150,7 +150,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 boolean isChunkNearPlayer(final ChunkMap chunkMap, final ChunkPos chunkPos, final LevelChunk levelChunk) {
|
|
final ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkData chunkData = ((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemChunkHolder)((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemLevelChunk)levelChunk).moonrise$getChunkAndHolder().holder())
|
|
.moonrise$getRealChunkHolder().holderData;
|
|
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
|
index b3c388f6108360708baf275121af18f46622494f..84d3df4008e56d8ceba2b422f42c34295c5e0a83 100644
|
|
--- a/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
|
@@ -902,7 +902,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();
|
|
@@ -951,7 +951,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();
|
|
boolean isRaining = this.isRaining();
|
|
int minBlockX = pos.getMinBlockX();
|
|
diff --git a/net/minecraft/util/RandomSource.java b/net/minecraft/util/RandomSource.java
|
|
index 98a54bc4de251014342cda6d0951b7fea79ce553..6d56134cc9ed9d73104ae77b1a0baa5a0a45759c 100644
|
|
--- a/net/minecraft/util/RandomSource.java
|
|
+++ b/net/minecraft/util/RandomSource.java
|
|
@@ -15,18 +15,32 @@ 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());
|
|
}
|
|
+ // Leaf end - Faster random generator
|
|
|
|
RandomSource fork();
|
|
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index 539cd1fe6ff15a4ebcbd65f41d8711d1f4ce5b97..034e10e912ab9b4b5435ad88c0cd4183c8b5c1a1 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -143,7 +143,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 13edbcdabc159e3694e7dbe824ccb5bb447fe788..367ba07f63917dc75883d5fd3dde93dc9ffc144a 100644
|
|
--- a/net/minecraft/world/level/Level.java
|
|
+++ b/net/minecraft/world/level/Level.java
|
|
@@ -126,7 +126,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
|
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;
|
|
@@ -182,7 +182,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
|
public final Map<ServerExplosion.CacheKey, Float> explosionDensityCache = new 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 f44461f92a10cbfdb8fcdbc3a2442e526b9d3d33..b4c5eea26e87ee6f466c53a6dd0867909df7e848 100644
|
|
--- a/net/minecraft/world/level/biome/Biome.java
|
|
+++ b/net/minecraft/world/level/biome/Biome.java
|
|
@@ -54,14 +54,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 2b19e989b4475e905d77bf9d47403c724b81fccd..472105a1e392f2e1b080483f3038de4f303919ce 100644
|
|
--- a/net/minecraft/world/level/chunk/ChunkGenerator.java
|
|
+++ b/net/minecraft/world/level/chunk/ChunkGenerator.java
|
|
@@ -458,7 +458,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);
|
|
}
|
|
@@ -567,7 +567,7 @@ public abstract class ChunkGenerator {
|
|
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 - Feature Secure Seed
|
|
diff --git a/net/minecraft/world/level/levelgen/DensityFunctions.java b/net/minecraft/world/level/levelgen/DensityFunctions.java
|
|
index 04527a5c65ad630f794fed9071d485aedd02257a..15fc39f9c77fdd03a0ca4a39d173c851b9454f08 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..08cf526ae87dd2560fcb50d5786701701e34ec00 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 RNG
|
|
}
|
|
|
|
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 e416b27c7f6604349766d44284ee004d5f62d9b2..1d27550bb5f29b6bfe8e0ad4fc4c9d39a9d7b29e 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 - 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()));
|
|
+ : 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 - Feature 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 533dc888e4c1febe4e4b71bd6e1c1affbeb492a9..7f8293497912532fd6b83a0962a722b0e6267721 100644
|
|
--- a/net/minecraft/world/level/levelgen/structure/Structure.java
|
|
+++ b/net/minecraft/world/level/levelgen/structure/Structure.java
|
|
@@ -256,7 +256,7 @@ public abstract class Structure {
|
|
);
|
|
}
|
|
// Leaf end - Matter - Feature 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 d7040165f2b5bb8c60bf32c7bd57ddc0b49faec8..ebba2592726356eb837b733c36148f444c2d7f13 100644
|
|
--- a/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java
|
|
+++ b/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java
|
|
@@ -74,7 +74,7 @@ public class RandomSpreadStructurePlacement extends StructurePlacement {
|
|
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 - Feature 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 03247c55e0448cabc24ff281e2d1c7df527161da..2a9f66ac0fe8f664d404c68df7414be6b0396082 100644
|
|
--- a/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java
|
|
+++ b/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java
|
|
@@ -125,7 +125,7 @@ public abstract class StructurePlacement {
|
|
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 - Feature Secure Seed
|
|
@@ -134,7 +134,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
|
|
@@ -146,7 +146,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;
|
|
}
|
|
@@ -154,7 +154,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)) {
|