mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2026-01-06 15:51:31 +00:00
Add Legacy LeafConfig converter
This commit is contained in:
81
patches/server/0045-Faster-Natural-Spawning.patch
Normal file
81
patches/server/0045-Faster-Natural-Spawning.patch
Normal file
@@ -0,0 +1,81 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Thu, 21 Sep 2023 02:56:22 -0400
|
||||
Subject: [PATCH] Faster Natural Spawning
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/util/RandomSource.java b/src/main/java/net/minecraft/util/RandomSource.java
|
||||
index ff1ad1024419182f7f3de578442c1c033d4c9ebb..5e51a1c79811291a740ad4d5e79a7d672f4a2ab6 100644
|
||||
--- a/src/main/java/net/minecraft/util/RandomSource.java
|
||||
+++ b/src/main/java/net/minecraft/util/RandomSource.java
|
||||
@@ -16,6 +16,12 @@ public interface RandomSource {
|
||||
return create(RandomSupport.generateUniqueSeed());
|
||||
}
|
||||
|
||||
+ // Leaf start - Generate random seed faster
|
||||
+ static RandomSource createFaster() {
|
||||
+ return create(RandomSupport.generateFasterSeed());
|
||||
+ }
|
||||
+ // Leaf end
|
||||
+
|
||||
/** @deprecated */
|
||||
@Deprecated
|
||||
static RandomSource createThreadSafe() {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 3c5d8275782df8d9b3fb6e8047bfde02e26ca93f..a4c5bab9d2a714f15d8053e988e6f585377170d3 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -126,6 +126,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
protected float oThunderLevel;
|
||||
public float thunderLevel;
|
||||
public final RandomSource random = RandomSource.create();
|
||||
+ public final RandomSource randomFaster = RandomSource.createFaster(); // Leaf - Generate random seed faster
|
||||
/** @deprecated */
|
||||
@Deprecated
|
||||
private final RandomSource threadSafeRandom = RandomSource.createThreadSafe();
|
||||
diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||
index 31003588de8bef9952a688c486049077328e89a3..9c4a8b6a4371bf8b1af05fb180b8fee020226e05 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||
@@ -422,12 +422,12 @@ public final class NaturalSpawner {
|
||||
|
||||
private static BlockPos getRandomPosWithin(ServerLevel world, LevelChunk chunk) { // Gale - Airplane - Use ThreadUnsafeRandom for mob spawning - accept ServerLevel
|
||||
ChunkPos chunkcoordintpair = chunk.getPos();
|
||||
- // Gale start - Airplane - Use ThreadUnsafeRandom for mob spawning - use ThreadUnsafeRandom
|
||||
- int i = chunkcoordintpair.getMinBlockX() + world.randomTickRandom.nextInt(16);
|
||||
- int j = chunkcoordintpair.getMinBlockZ() + world.randomTickRandom.nextInt(16);
|
||||
+ // Gale start - Airplane - Use ThreadUnsafeRandom for mob spawning - use ThreadUnsafeRandom // Leaf start - Generate random seed faster
|
||||
+ int i = chunkcoordintpair.getMinBlockX() + world.randomFaster.nextInt(16);
|
||||
+ int j = chunkcoordintpair.getMinBlockZ() + world.randomFaster.nextInt(16);
|
||||
// Gale end - Airplane - Use ThreadUnsafeRandom for mob spawning - use ThreadUnsafeRandom
|
||||
int k = chunk.getHeight(Heightmap.Types.WORLD_SURFACE, i, j) + 1;
|
||||
- int l = Mth.randomBetweenInclusive(world.randomTickRandom, world.getMinBuildHeight(), k); // Gale - Airplane - Use ThreadUnsafeRandom for mob spawning - use ThreadUnsafeRandom
|
||||
+ int l = Mth.randomBetweenInclusive(world.randomFaster, world.getMinBuildHeight(), k); // Gale - Airplane - Use ThreadUnsafeRandom for mob spawning - use ThreadUnsafeRandom // Leaf end
|
||||
return new BlockPos(i, l, j);
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/levelgen/RandomSupport.java b/src/main/java/net/minecraft/world/level/levelgen/RandomSupport.java
|
||||
index 36f9d68b70fbd1cd3790a9bb5a729a11da8cbf83..458ef9e6f68f89f34a9e1bd74b50d52eeb93342e 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/RandomSupport.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/levelgen/RandomSupport.java
|
||||
@@ -5,6 +5,7 @@ import com.google.common.base.Charsets;
|
||||
import com.google.common.hash.HashFunction;
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.google.common.primitives.Longs;
|
||||
+import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
public final class RandomSupport {
|
||||
@@ -43,6 +44,12 @@ public final class RandomSupport {
|
||||
}) ^ System.nanoTime();
|
||||
}
|
||||
|
||||
+ // Leaf start - Generate random seed faster
|
||||
+ public static long generateFasterSeed() {
|
||||
+ return SEED_UNIQUIFIER.updateAndGet((seedUniquifier) -> seedUniquifier * 1181783497276652981L)^ ThreadLocalRandom.current().nextLong();
|
||||
+ }
|
||||
+ // Leaf end
|
||||
+
|
||||
public static record Seed128bit(long seedLo, long seedHi) {
|
||||
public RandomSupport.Seed128bit xor(long seedLo, long seedHi) {
|
||||
return new RandomSupport.Seed128bit(this.seedLo ^ seedLo, this.seedHi ^ seedHi);
|
||||
Reference in New Issue
Block a user