9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/leaf-server/paper-patches/features/0040-Faster-random-generator.patch
2025-06-03 09:49:56 +08:00

29 lines
1.4 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/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java
index 73c51c66857f53128b737304205295b67e8444e8..348bf5ed91ded3537a86bc0708e0158ad4f9296d 100644
--- a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java
+++ b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java
@@ -97,7 +97,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
}
private static WorldgenRandom getSeededRandom() {
- return new WorldgenRandom(new LegacyRandomSource(0));
+ return new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0) : new LegacyRandomSource(0)); // Leaf - Faster random generator
}
@Override