mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2026-01-04 15:41:40 +00:00
Some changes to optimizations and api (#172)
* Add faster random generator for Entity random * Option for replace worldgen random with L64X128MixRandomSource & Cleanup * Allocate 1 thread for AsyncLocator by default * Rename to worldgen * Add config option for backed random generator * Add SplittableGenerator check * Cache random generator * Revert cache Caching RNGs will cause some issues during worldgen * Set to final & cleanup * LevelChunkMixin * Filter null values * Use Xoroshiro128PlusPlus by default * Benchmark results * Revert changes * Better smooth teleport api * Set seed to 0
This commit is contained in:
@@ -6,25 +6,41 @@ Subject: [PATCH] Slice: Smooth Teleports
|
||||
Original license: MIT
|
||||
Original project: https://github.com/Cryptite/Slice
|
||||
|
||||
Co-authored-by: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||
index d5df69a2e5b228545dfaaaa98ce88ec0da806315..a6d43ac0ee1b4bac6efc3283c7eea643a45e2d93 100644
|
||||
index f96ca62d81db8362a9f74f00ff54b151f96c04fe..f1d9f17b3ef15e2db5dabe563f7c56fa9c1be651 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||
@@ -3691,6 +3691,19 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||
@@ -3691,6 +3691,33 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||
String getClientBrandName();
|
||||
// Paper end
|
||||
|
||||
+ /**
|
||||
+ * This abuses some of how Minecraft works and allows teleporting a player to another world without
|
||||
+ * This abuses some of how Minecraft works and attempts to teleport a player to another world without
|
||||
+ * triggering typical respawn packets. All of natural state of chunk resends, entity adds/removes, etc still
|
||||
+ * happen but the visual "refresh" of a world change is hidden. Depending on the destination location/world,
|
||||
+ * this can act as a "smooth teleport" to a world if the new world is very similar looking to the old one.
|
||||
+ *
|
||||
+ * @param location New location to teleport this Player to
|
||||
+ * @deprecated use {@link #teleportWithoutRespawnOptionally(Location)}
|
||||
+ */
|
||||
+ // Slice start
|
||||
+ @org.jetbrains.annotations.ApiStatus.Experimental
|
||||
+ @Deprecated(since = "1.21.1", forRemoval = true)
|
||||
+ void teleportWithoutRespawn(@NotNull Location location);
|
||||
+
|
||||
+ /**
|
||||
+ * This abuses some of how Minecraft works and attempts to teleport a player to another world without
|
||||
+ * triggering typical respawn packets. All of natural state of chunk resends, entity adds/removes, etc still
|
||||
+ * happen but the visual "refresh" of a world change is hidden. Depending on the destination location/world,
|
||||
+ * this can act as a "smooth teleport" to a world if the new world is very similar looking to the old one.
|
||||
+ *
|
||||
+ * @param location New location to teleport this Player to
|
||||
+ * @return Whether the teleport was successful
|
||||
+ */
|
||||
+ @org.jetbrains.annotations.ApiStatus.Experimental
|
||||
+ boolean teleportWithoutRespawnOptionally(@NotNull Location location);
|
||||
+ // Slice end
|
||||
+
|
||||
// Paper start - Teleport API
|
||||
|
||||
@@ -6,6 +6,8 @@ Subject: [PATCH] Slice: Smooth Teleports
|
||||
Original license: MIT
|
||||
Original project: https://github.com/Cryptite/Slice
|
||||
|
||||
Co-authored-by: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 1dc2af59bafa5a5dc6721da02cde19a3ca77af28..b2ae3fdf128e7d66e3f3430266321a6a09fa0be6 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -19,7 +21,7 @@ index 1dc2af59bafa5a5dc6721da02cde19a3ca77af28..b2ae3fdf128e7d66e3f3430266321a6a
|
||||
// Paper start - rewrite chunk system
|
||||
private ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader;
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index bf3561764bab8e1b237c2b9760181853f60c8fa7..26a92a77481c46969b68e454b906b3935ad02043 100644
|
||||
index bf3561764bab8e1b237c2b9760181853f60c8fa7..fa658c59c61449e6499f5f0c334df180e532f883 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -901,10 +901,10 @@ public abstract class PlayerList {
|
||||
@@ -27,29 +29,48 @@ index bf3561764bab8e1b237c2b9760181853f60c8fa7..26a92a77481c46969b68e454b906b393
|
||||
LevelData worlddata = worldserver1.getLevelData();
|
||||
|
||||
- entityplayer1.connection.send(new ClientboundRespawnPacket(entityplayer1.createCommonSpawnInfo(worldserver1), (byte) i));
|
||||
+ if (!entityplayer.smoothWorldTeleport) entityplayer1.connection.send(new ClientboundRespawnPacket(entityplayer1.createCommonSpawnInfo(worldserver1), (byte) i)); // Slice
|
||||
+ if (!entityplayer.smoothWorldTeleport || !isSameLogicalHeight((ServerLevel) fromWorld, worldserver)) entityplayer1.connection.send(new ClientboundRespawnPacket(entityplayer1.createCommonSpawnInfo(worldserver1), (byte) i)); // Slice // Leaf
|
||||
entityplayer1.connection.send(new ClientboundSetChunkCacheRadiusPacket(worldserver1.spigotConfig.viewDistance)); // Spigot
|
||||
entityplayer1.connection.send(new ClientboundSetSimulationDistancePacket(worldserver1.spigotConfig.simulationDistance)); // Spigot
|
||||
- entityplayer1.connection.teleport(CraftLocation.toBukkit(entityplayer1.position(), worldserver1.getWorld(), entityplayer1.getYRot(), entityplayer1.getXRot())); // CraftBukkit
|
||||
+ if (!entityplayer.smoothWorldTeleport) entityplayer1.connection.teleport(CraftLocation.toBukkit(entityplayer1.position(), worldserver1.getWorld(), entityplayer1.getYRot(), entityplayer1.getXRot())); // CraftBukkit // Slice
|
||||
+ if (!entityplayer.smoothWorldTeleport || !isSameLogicalHeight((ServerLevel) fromWorld, worldserver)) entityplayer1.connection.teleport(CraftLocation.toBukkit(entityplayer1.position(), worldserver1.getWorld(), entityplayer1.getYRot(), entityplayer1.getXRot())); // CraftBukkit // Slice // Leaf
|
||||
entityplayer1.connection.send(new ClientboundSetDefaultSpawnPositionPacket(worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle()));
|
||||
entityplayer1.connection.send(new ClientboundChangeDifficultyPacket(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
|
||||
entityplayer1.connection.send(new ClientboundSetExperiencePacket(entityplayer1.experienceProgress, entityplayer1.totalExperience, entityplayer1.experienceLevel));
|
||||
@@ -965,6 +965,8 @@ public abstract class PlayerList {
|
||||
return entityplayer1;
|
||||
}
|
||||
|
||||
+ private boolean isSameLogicalHeight(ServerLevel level1, ServerLevel level2) { return level1.getLogicalHeight() == level2.getLogicalHeight(); } // Leaf - Check world height before smooth teleport
|
||||
+
|
||||
public void sendActivePlayerEffects(ServerPlayer player) {
|
||||
this.sendActiveEffects(player, player.connection);
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 88668656c8586d758b636561066d96dd883e6201..95c6275ec833a0bfe4e7b8105db5abafd69079c3 100644
|
||||
index 88668656c8586d758b636561066d96dd883e6201..75f1e56281014a8fc7e682478307d8f40ad4bdcc 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -1365,6 +1365,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
@@ -1365,6 +1365,25 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
// Paper end
|
||||
}
|
||||
|
||||
+ // Slice start
|
||||
+ @Override
|
||||
+ public void teleportWithoutRespawn(Location location) {
|
||||
+ ServerPlayer serverPlayer = getHandle();
|
||||
+ serverPlayer.smoothWorldTeleport = true;
|
||||
+ teleport(location);
|
||||
+ serverPlayer.smoothWorldTeleport = false;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean teleportWithoutRespawnOptionally(Location location) {
|
||||
+ ServerPlayer serverPlayer = getHandle();
|
||||
+ serverPlayer.smoothWorldTeleport = true;
|
||||
+ boolean teleportResult = teleport(location);
|
||||
+ serverPlayer.smoothWorldTeleport = false;
|
||||
+ return teleportResult;
|
||||
+ }
|
||||
+ // Slice end
|
||||
+
|
||||
@Override
|
||||
|
||||
@@ -9,10 +9,10 @@ Original project: https://github.com/LeavesMC/Leaves
|
||||
This patch is Powered by Xaero Map
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 73d67b3bebcf3dff210e25dda0b3df206e129173..a25a8268d148862312ebf93cf9d7828b4e051375 100644
|
||||
index bbd64da6ffa78c7e2376f38456681aaf1823528a..135a53742607dfccff17aa86f80f106b4a31f6b0 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -1336,6 +1336,7 @@ public abstract class PlayerList {
|
||||
@@ -1338,6 +1338,7 @@ public abstract class PlayerList {
|
||||
player.connection.send(new ClientboundInitializeBorderPacket(worldborder));
|
||||
player.connection.send(new ClientboundSetTimePacket(world.getGameTime(), world.getDayTime(), world.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)));
|
||||
player.connection.send(new ClientboundSetDefaultSpawnPositionPacket(world.getSharedSpawnPos(), world.getSharedSpawnAngle()));
|
||||
|
||||
@@ -215,7 +215,7 @@ index b2ae3fdf128e7d66e3f3430266321a6a09fa0be6..7c6bda95b8b08cc70182f19cf0b991f7
|
||||
this.stats = server.getPlayerList().getPlayerStats(this);
|
||||
this.advancements = server.getPlayerList().getPlayerAdvancements(this);
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index a25a8268d148862312ebf93cf9d7828b4e051375..b7228c495871d3222f184c1ede4d846d9c13a435 100644
|
||||
index 135a53742607dfccff17aa86f80f106b4a31f6b0..94b43be23f1b6498a09e9c45d2ec02df8fbd6d17 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -155,6 +155,7 @@ public abstract class PlayerList {
|
||||
@@ -462,10 +462,10 @@ index 770606c4462d85d116f6d0bf91192dc49f438d0f..4317420bd5d3fc8e20ffd7f3a3d48c5a
|
||||
if (entity instanceof EnderDragonPart complexPart) {
|
||||
if (complexPart.parentMob instanceof EnderDragon) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 95c6275ec833a0bfe4e7b8105db5abafd69079c3..7294c6cc2cf65e3c142d174025d24d854bbe68ae 100644
|
||||
index 75f1e56281014a8fc7e682478307d8f40ad4bdcc..8addddffe97751524f265241ac644a9291405c42 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -2263,7 +2263,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
@@ -2273,7 +2273,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
||||
@Override
|
||||
public boolean canSee(Player player) {
|
||||
|
||||
@@ -29,7 +29,7 @@ index 4d91b50e527320647f6c9aa20fc5da071c3fdee0..dde015810f6e914ad99dcb8ab66c7aa3
|
||||
}
|
||||
// CraftBukkit end
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index c6964b6027e0ac57e3e01deae0da22665f2afc40..801a237b666fe8f26e477d848b1f9e31a4025fd0 100644
|
||||
index 0021f9bf8d6870bd9275ef59567c51ffce7615d0..a2f329e958fe72d262da9a4cee050efb69294df4 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -200,7 +200,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
@@ -41,7 +41,7 @@ index c6964b6027e0ac57e3e01deae0da22665f2afc40..801a237b666fe8f26e477d848b1f9e31
|
||||
private final Set<UUID> unlistedEntities = new HashSet<>(); // Paper - Add Listing API for Player
|
||||
private static final WeakHashMap<Plugin, WeakReference<Plugin>> pluginWeakReferences = new WeakHashMap<>();
|
||||
private int hash = 0;
|
||||
@@ -2269,9 +2269,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
@@ -2279,9 +2279,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
||||
@Override
|
||||
public boolean canSee(org.bukkit.entity.Entity entity) {
|
||||
|
||||
@@ -26,10 +26,10 @@ index a608f57ebca98eda88ad749d0aad021678be54f9..1f301caa36212c85b06a33c714cb1050
|
||||
this.player.connection.send(this.updateClientChunkRadius(sendViewDistance));
|
||||
this.player.connection.send(this.updateClientSimulationDistance(tickViewDistance));
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index b7228c495871d3222f184c1ede4d846d9c13a435..505d7376681071e67c460d5a88eaa95f3d6ab820 100644
|
||||
index 94b43be23f1b6498a09e9c45d2ec02df8fbd6d17..0d41cd4fe9b423a8644475494bcfb73f98e8b70b 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -1718,7 +1718,7 @@ public abstract class PlayerList {
|
||||
@@ -1720,7 +1720,7 @@ public abstract class PlayerList {
|
||||
|
||||
public void setViewDistance(int viewDistance) {
|
||||
this.viewDistance = viewDistance;
|
||||
|
||||
@@ -5,10 +5,10 @@ Subject: [PATCH] Remove useless creating stats json bases on player name logic
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 505d7376681071e67c460d5a88eaa95f3d6ab820..bc7dd0ceea8bb304fb4370084bf19f29c1df0828 100644
|
||||
index 0d41cd4fe9b423a8644475494bcfb73f98e8b70b..8d8f552acd4d2e846e1fd0bc19574d93c372fc2b 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -1685,6 +1685,8 @@ public abstract class PlayerList {
|
||||
@@ -1687,6 +1687,8 @@ public abstract class PlayerList {
|
||||
File file = this.server.getWorldPath(LevelResource.PLAYER_STATS_DIR).toFile();
|
||||
File file1 = new File(file, String.valueOf(uuid) + ".json");
|
||||
|
||||
@@ -17,7 +17,7 @@ index 505d7376681071e67c460d5a88eaa95f3d6ab820..bc7dd0ceea8bb304fb4370084bf19f29
|
||||
if (!file1.exists()) {
|
||||
File file2 = new File(file, displayName + ".json"); // CraftBukkit
|
||||
Path path = file2.toPath();
|
||||
@@ -1693,6 +1695,8 @@ public abstract class PlayerList {
|
||||
@@ -1695,6 +1697,8 @@ public abstract class PlayerList {
|
||||
file2.renameTo(file1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ index 50dc68a005490415b88780397ef6c26859596dd5..162115048cffc824376e54b7f60ae071
|
||||
public static record Favicon(byte[] iconBytes) {
|
||||
private static final String PREFIX = "data:image/png;base64,";
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 2e78a464ae2f85722786e9da668f42851d8d65c4..86462d3eff74f373820ccdbb162978d1d4a6d9d6 100644
|
||||
index eecc459c7e16dfcda57f0682e90ed1b38d71da44..5a88fd8997d2703a1318df441a2789a7b1ab229c 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -707,6 +707,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@@ -151,10 +151,10 @@ index 8a3736dbf6ee0b2c6fbb514b2841154d2ad9f0f5..22eb98d51e0cbc996195f7f1ba07c0e4
|
||||
if (packet == null || this.processedDisconnect) { // Spigot
|
||||
return;
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 3ac1446ed791e06e2bbf226b925890ac4d1a16de..2cdfd22baf31df99e2c2b1d114c47cb88569538f 100644
|
||||
index dad180fa1bab9cd9ed08891d42836020f6e709b2..0d791d0e0cbbc77dd1e5b376f82c26e3618c236e 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -1639,7 +1639,7 @@ public abstract class PlayerList {
|
||||
@@ -1641,7 +1641,7 @@ public abstract class PlayerList {
|
||||
// Paper end
|
||||
boolean flag = this.verifyChatTrusted(message);
|
||||
|
||||
@@ -163,7 +163,7 @@ index 3ac1446ed791e06e2bbf226b925890ac4d1a16de..2cdfd22baf31df99e2c2b1d114c47cb8
|
||||
OutgoingChatMessage outgoingchatmessage = OutgoingChatMessage.create(message);
|
||||
boolean flag1 = false;
|
||||
|
||||
@@ -1668,6 +1668,7 @@ public abstract class PlayerList {
|
||||
@@ -1670,6 +1670,7 @@ public abstract class PlayerList {
|
||||
}
|
||||
|
||||
public boolean verifyChatTrusted(PlayerChatMessage message) { // Paper - private -> public
|
||||
|
||||
@@ -1,55 +1,149 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HaHaWTH <fsjk947@gmail.com>
|
||||
Date: Fri, 3 May 2024 01:12:58 +0800
|
||||
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) (GraalVM 21)
|
||||
SimpleRandom (Moonrise): 80ms
|
||||
FasterRandomSource (Leaf) (Backed by Xoroshiro128PlusPlus): 35ms
|
||||
LegacyRandomSource (Vanilla): 200ms
|
||||
XoroshiroRandomSource (Vanilla): 47ms
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/util/RandomSource.java b/src/main/java/net/minecraft/util/RandomSource.java
|
||||
index 67d94b649148b3165f09d75d8c9db10db4cc7874..e0fffcaff4ccb8b20a85a68fa73d3076246aad0c 100644
|
||||
index 67d94b649148b3165f09d75d8c9db10db4cc7874..77b91adf528d1bf66a42a4c6791de40e87c5b26a 100644
|
||||
--- a/src/main/java/net/minecraft/util/RandomSource.java
|
||||
+++ b/src/main/java/net/minecraft/util/RandomSource.java
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.world.level.levelgen.PositionalRandomFactory;
|
||||
import net.minecraft.world.level.levelgen.RandomSupport;
|
||||
import net.minecraft.world.level.levelgen.SingleThreadedRandomSource;
|
||||
import net.minecraft.world.level.levelgen.ThreadSafeLegacyRandomSource;
|
||||
+import org.dreeam.leaf.util.math.random.TheFasterRandom;
|
||||
|
||||
public interface RandomSource {
|
||||
@Deprecated
|
||||
@@ -23,16 +24,28 @@ public interface RandomSource {
|
||||
@@ -21,18 +21,32 @@ public interface RandomSource {
|
||||
}
|
||||
// Leaf end - Generate random seed faster
|
||||
|
||||
+ // Leaf start - Faster random generator
|
||||
@Deprecated
|
||||
static RandomSource createThreadSafe() {
|
||||
- return new ThreadSafeLegacyRandomSource(RandomSupport.generateUniqueSeed());
|
||||
- }
|
||||
+ return org.dreeam.leaf.config.modules.opt.FastRNG.enabled
|
||||
+ ? new TheFasterRandom(RandomSupport.generateFasterSeed())
|
||||
+ ? new org.dreeam.leaf.util.math.random.FasterRandomSource(RandomSupport.generateFasterSeed())
|
||||
+ : new ThreadSafeLegacyRandomSource(RandomSupport.generateUniqueSeed());
|
||||
+ } // Leaf - Faster RNG
|
||||
}
|
||||
|
||||
static RandomSource create(long seed) {
|
||||
- return new LegacyRandomSource(seed);
|
||||
+ return org.dreeam.leaf.config.modules.opt.FastRNG.enabled
|
||||
+ ? new TheFasterRandom(seed)
|
||||
+ ? 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 createForSlimeChunk(long seed) {
|
||||
+ return org.dreeam.leaf.config.modules.opt.FastRNG.enabled && !org.dreeam.leaf.config.modules.opt.FastRNG.useLegacyForSlimeChunk
|
||||
+ ? new TheFasterRandom(seed)
|
||||
+ : new LegacyRandomSource(seed);
|
||||
+ } // Leaf - Faster RNG
|
||||
+
|
||||
static RandomSource createNewThreadLocalInstance() {
|
||||
- return new SingleThreadedRandomSource(ThreadLocalRandom.current().nextLong());
|
||||
- }
|
||||
+ return org.dreeam.leaf.config.modules.opt.FastRNG.enabled
|
||||
+ ? new TheFasterRandom(RandomSupport.generateFasterSeed())
|
||||
+ ? new org.dreeam.leaf.util.math.random.FasterRandomSource(RandomSupport.generateFasterSeed())
|
||||
+ : new SingleThreadedRandomSource(ThreadLocalRandom.current().nextLong());
|
||||
+ } // Leaf - Faster RNG
|
||||
}
|
||||
+ // Leaf end - Faster random generator
|
||||
|
||||
RandomSource fork();
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 08a3714c530fb375ee729e91965c65efb9e6e3d2..2427e8535d40204a42c214c2a47359d1555da38f 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -177,7 +177,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
|
||||
private static final class RandomRandomSource extends java.util.Random implements net.minecraft.world.level.levelgen.BitRandomSource {
|
||||
private boolean locked = false;
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/biome/Biome.java b/src/main/java/net/minecraft/world/level/biome/Biome.java
|
||||
index 90c165c890a2d998e3b0af9b4310e3995ede6f64..b4757a0294cb392f59d7e045d3226c90da3f6dbf 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/biome/Biome.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/biome/Biome.java
|
||||
@@ -50,14 +50,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/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||
index 00ed0d5ad535faa36111ab28bb0cf1317eb067ec..0daad8b06b10bbe9f7f29b7697cb77cd0b40195f 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||
@@ -494,7 +494,7 @@ public abstract class ChunkGenerator {
|
||||
int x = ichunkaccess.getPos().x;
|
||||
int z = ichunkaccess.getPos().z;
|
||||
for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) {
|
||||
- WorldgenRandom seededrandom = new WorldgenRandom(new net.minecraft.world.level.levelgen.LegacyRandomSource(generatoraccessseed.getSeed()));
|
||||
+ WorldgenRandom seededrandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(generatoraccessseed.getSeed()) : new net.minecraft.world.level.levelgen.LegacyRandomSource(generatoraccessseed.getSeed())); // Leaf - Faster random generator
|
||||
seededrandom.setDecorationSeed(generatoraccessseed.getSeed(), x, z);
|
||||
populator.populate(world, new org.bukkit.craftbukkit.util.RandomSourceWrapper.RandomWrapper(seededrandom), x, z, limitedRegion);
|
||||
}
|
||||
@@ -594,7 +594,7 @@ public abstract class ChunkGenerator {
|
||||
chunkcoordintpair.x, chunkcoordintpair.z, su.plo.matter.Globals.Salt.GENERATE_FEATURE, 0
|
||||
);
|
||||
} else {
|
||||
- seededrandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
+ seededrandom = 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
|
||||
|
||||
seededrandom.setLargeFeatureSeed(placementCalculator.getLevelSeed(), chunkcoordintpair.x, chunkcoordintpair.z);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/levelgen/DensityFunctions.java b/src/main/java/net/minecraft/world/level/levelgen/DensityFunctions.java
|
||||
index ac8447e20531ad59d5e26c6db541d6e844d56c0f..0dab53e8e99e7de71cbd2d22a283b49bac635178 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/DensityFunctions.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/levelgen/DensityFunctions.java
|
||||
@@ -521,7 +521,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/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
||||
index c991da3d975e07f3e1e59d5b2e91ed629ea608e6..f7d0eb09640b8b8eeec9269eca867f53e05d023b 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
||||
@@ -232,7 +232,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator {
|
||||
BiomeManager biomemanager1 = biomeAccess.withDifferentSource((j, k, l) -> {
|
||||
return this.biomeSource.getNoiseBiome(j, k, l, noiseConfig.sampler());
|
||||
});
|
||||
- WorldgenRandom seededrandom = new WorldgenRandom(new LegacyRandomSource(RandomSupport.generateUniqueSeed()));
|
||||
+ WorldgenRandom seededrandom = 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
|
||||
boolean flag = true;
|
||||
ChunkPos chunkcoordintpair = chunk.getPos();
|
||||
NoiseChunk noisechunk = chunk.getOrCreateNoiseChunk((ichunkaccess1) -> {
|
||||
@@ -427,7 +427,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator {
|
||||
if (!((NoiseGeneratorSettings) this.settings.value()).disableMobGeneration()) {
|
||||
ChunkPos chunkcoordintpair = region.getCenter();
|
||||
Holder<Biome> holder = region.getBiome(chunkcoordintpair.getWorldPosition().atY(region.getMaxBuildHeight() - 1));
|
||||
- WorldgenRandom seededrandom = new WorldgenRandom(new LegacyRandomSource(RandomSupport.generateUniqueSeed()));
|
||||
+ WorldgenRandom seededrandom = 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
|
||||
|
||||
seededrandom.setDecorationSeed(region.getSeed(), chunkcoordintpair.getMinBlockX(), chunkcoordintpair.getMinBlockZ());
|
||||
NaturalSpawner.spawnMobsForChunkGeneration(region, holder, chunkcoordintpair, seededrandom);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/levelgen/WorldgenRandom.java b/src/main/java/net/minecraft/world/level/levelgen/WorldgenRandom.java
|
||||
index c6efe6faf68c7a7b1df344e2e527aa7e44bfacb8..fe89e7b7c4267ee2969d1505f83cba1ac17cb13e 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/WorldgenRandom.java
|
||||
@@ -66,18 +160,164 @@ index c6efe6faf68c7a7b1df344e2e527aa7e44bfacb8..fe89e7b7c4267ee2969d1505f83cba1a
|
||||
}
|
||||
|
||||
public static enum Algorithm {
|
||||
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 fecbce25736dab20e8459cb3b1c636fa7f7eab6b..9309bad317acf8919db3b8cc0153efe2a532bd72 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/GeodeFeature.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/levelgen/feature/GeodeFeature.java
|
||||
@@ -45,7 +45,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> list2 = Lists.newLinkedList();
|
||||
diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/stateproviders/DualNoiseProvider.java b/src/main/java/net/minecraft/world/level/levelgen/feature/stateproviders/DualNoiseProvider.java
|
||||
index c7eabcbf9132c5dac1e376332f563d8912447b03..8b8cef5f8e73185ea2f8143fbd4fb5f5afc9ef6e 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/stateproviders/DualNoiseProvider.java
|
||||
+++ b/src/main/java/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/src/main/java/net/minecraft/world/level/levelgen/feature/stateproviders/NoiseBasedStateProvider.java b/src/main/java/net/minecraft/world/level/levelgen/feature/stateproviders/NoiseBasedStateProvider.java
|
||||
index 990457fb23d22c3b8732d70da54ac5aaed8221db..f55475b812fd989d076c7715b8f060ab8f9ddd26 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/stateproviders/NoiseBasedStateProvider.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/levelgen/feature/stateproviders/NoiseBasedStateProvider.java
|
||||
@@ -28,7 +28,7 @@ public abstract class NoiseBasedStateProvider extends BlockStateProvider {
|
||||
this.seed = seed;
|
||||
this.parameters = noiseParameters;
|
||||
this.scale = scale;
|
||||
- this.noise = NormalNoise.create(new WorldgenRandom(new LegacyRandomSource(seed)), noiseParameters);
|
||||
+ 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)), noiseParameters); // Leaf - Faster random generator
|
||||
}
|
||||
|
||||
protected double getNoiseValue(BlockPos pos, double scale) {
|
||||
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 10e39fcdce7c205a695b9c1b8c3551b07a64cfa0..72adc7aa05d568875a7cc98e877e4e41b07b73bd 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/structure/Structure.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/levelgen/structure/Structure.java
|
||||
@@ -241,7 +241,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));
|
||||
worldgenRandom.setLargeFeatureSeed(seed, chunkPos.x, chunkPos.z);
|
||||
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
|
||||
index 5ae511a5a178b0202e6a60cb882fca37a2a92fd4..c763b8a11786d8d746ee72218805aad601deaad4 100644
|
||||
--- 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
|
||||
@@ -78,7 +78,7 @@ public class RandomSpreadStructurePlacement extends StructurePlacement {
|
||||
i, j, 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, j, this.salt());
|
||||
}
|
||||
// Leaf end - Matter - Feature Secure Seed
|
||||
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 d97bb945f59dc7d8da1374fda5beee0d6d0f0f5d..9973f89e65a6a6f7edfbd40b722f1d7b030872d5 100644
|
||||
--- 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
|
||||
@@ -125,7 +125,7 @@ public abstract class StructurePlacement {
|
||||
chunkX, chunkZ, 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(seed, salt, chunkX, chunkZ);
|
||||
}
|
||||
// Leaf end - Matter - Feature Secure Seed
|
||||
@@ -134,7 +134,7 @@ public abstract class StructurePlacement {
|
||||
}
|
||||
|
||||
private static boolean legacyProbabilityReducerWithDouble(long seed, int salt, int chunkX, int chunkZ, float frequency, @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(seed, chunkX, chunkZ);
|
||||
// Paper start - Add missing structure set seed configs
|
||||
@@ -146,7 +146,7 @@ public abstract class StructurePlacement {
|
||||
}
|
||||
|
||||
private static boolean legacyArbitrarySaltProbabilityReducer(long seed, int salt, int chunkX, int chunkZ, float frequency, @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(seed, chunkX, chunkZ, saltOverride != null ? saltOverride : HIGHLY_ARBITRARY_RANDOM_SALT); // Paper - Add missing structure set seed configs
|
||||
return worldgenRandom.nextFloat() < frequency;
|
||||
}
|
||||
@@ -154,7 +154,7 @@ public abstract class StructurePlacement {
|
||||
private static boolean legacyPillagerOutpostReducer(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
|
||||
int i = chunkX >> 4;
|
||||
int j = chunkZ >> 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((long)(i ^ j << 4) ^ seed);
|
||||
worldgenRandom.nextInt();
|
||||
return worldgenRandom.nextInt((int)(1.0F / frequency)) == 0;
|
||||
diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/structures/OceanMonumentStructure.java b/src/main/java/net/minecraft/world/level/levelgen/structure/structures/OceanMonumentStructure.java
|
||||
index 9693641e4129458d94f78a487d66d27fe35cd94e..019f9fb994a1836b73a68cfc9e120515884fba1e 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/structure/structures/OceanMonumentStructure.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/levelgen/structure/structures/OceanMonumentStructure.java
|
||||
@@ -55,7 +55,7 @@ public class OceanMonumentStructure extends Structure {
|
||||
if (pieces.isEmpty()) {
|
||||
return pieces;
|
||||
} 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(worldSeed, pos.x, pos.z);
|
||||
StructurePiece structurePiece = pieces.pieces().get(0);
|
||||
BoundingBox boundingBox = structurePiece.getBoundingBox();
|
||||
diff --git a/src/main/java/net/minecraft/world/level/levelgen/synth/PerlinSimplexNoise.java b/src/main/java/net/minecraft/world/level/levelgen/synth/PerlinSimplexNoise.java
|
||||
index 64bddc5c2722f7d2a18c31dc654547907b663710..b7302317d47a13c153b7c9fea993635c8f347ef4 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/synth/PerlinSimplexNoise.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/levelgen/synth/PerlinSimplexNoise.java
|
||||
@@ -43,7 +43,7 @@ public class PerlinSimplexNoise {
|
||||
|
||||
if (j > 0) {
|
||||
long n = (long)(simplexNoise.getValue(simplexNoise.xo, simplexNoise.yo, simplexNoise.zo) * 9.223372E18F);
|
||||
- RandomSource randomSource = new WorldgenRandom(new LegacyRandomSource(n));
|
||||
+ RandomSource randomSource = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(n) : new LegacyRandomSource(n)); // Leaf - Faster random generator
|
||||
|
||||
for (int o = l - 1; o >= 0; o--) {
|
||||
if (o < k && octaves.contains(l - o)) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java
|
||||
index cab7ca4218e5903b6a5e518af55457b9a1b5111c..43d62e756a1ffd8e066a3a781329f9dc33a913cc 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java
|
||||
@@ -96,7 +96,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
|
||||
diff --git a/src/main/java/org/dreeam/leaf/config/modules/opt/FastRNG.java b/src/main/java/org/dreeam/leaf/config/modules/opt/FastRNG.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..1c90bcfef92a383ee16f551c5a5bff3e9d013e7f
|
||||
index 0000000000000000000000000000000000000000..c0fe3e9dfed1bbf3d1f5848b343928d9b80c443b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/dreeam/leaf/config/modules/opt/FastRNG.java
|
||||
@@ -0,0 +1,49 @@
|
||||
@@ -0,0 +1,80 @@
|
||||
+package org.dreeam.leaf.config.modules.opt;
|
||||
+
|
||||
+import org.dreeam.leaf.config.ConfigModules;
|
||||
+import org.dreeam.leaf.config.EnumConfigCategory;
|
||||
+import org.dreeam.leaf.config.LeafConfig;
|
||||
+
|
||||
+import java.util.random.RandomGeneratorFactory;
|
||||
+
|
||||
+public class FastRNG extends ConfigModules {
|
||||
+
|
||||
+ public String getBasePath() {
|
||||
@@ -85,21 +325,40 @@ index 0000000000000000000000000000000000000000..1c90bcfef92a383ee16f551c5a5bff3e
|
||||
+ }
|
||||
+
|
||||
+ public static boolean enabled = false;
|
||||
+ public static boolean enableForWorldgen = false;
|
||||
+ public static String randomGenerator = "Xoroshiro128PlusPlus";
|
||||
+ public static boolean warnForSlimeChunk = true;
|
||||
+ public static boolean useLegacyForSlimeChunk = false;
|
||||
+
|
||||
+ public static boolean worldgenEnabled() { return enabled && enableForWorldgen; } // Helper function
|
||||
+ @Override
|
||||
+ public void onLoaded() {
|
||||
+ config.addCommentRegionBased(getBasePath(), """
|
||||
+ Use faster random generator? (Up to 100X faster)
|
||||
+ Requires a JVM that supports RandomGenerator and the LXM generators.
|
||||
+ Some JREs don't support this and will cause a crash.""",
|
||||
+ Use faster random generator?
|
||||
+ Requires a JVM that supports RandomGenerator.
|
||||
+ Some JREs don't support this.""",
|
||||
+ """
|
||||
+ 是否使用更快的随机生成器? (速度最高可提升至100倍)
|
||||
+ 需要支持 RandomGenerator 和 LXM 随机生成器的JVM.
|
||||
+ 一些 JRE 不支持此功能, 会导致崩溃.""");
|
||||
+ 是否使用更快的随机生成器?
|
||||
+ 需要支持 RandomGenerator 的 JVM.
|
||||
+ 一些 JRE 不支持此功能.""");
|
||||
+
|
||||
+ enabled = config.getBoolean(getBasePath() + ".enabled", enabled);
|
||||
+ randomGenerator = config.getString(getBasePath() + ".random-generator", randomGenerator,
|
||||
+ config.pickStringRegionBased(
|
||||
+ """
|
||||
+ Which random generator will be used?
|
||||
+ See https://openjdk.org/jeps/356""",
|
||||
+ """
|
||||
+ 使用什么种类的随机生成器.
|
||||
+ 请参阅 https://openjdk.org/jeps/356"""));
|
||||
+ enableForWorldgen = config.getBoolean(getBasePath() + ".enable-for-worldgen", enableForWorldgen,
|
||||
+ config.pickStringRegionBased(
|
||||
+ """
|
||||
+ Enable faster random generator for world generation.
|
||||
+ WARNING: This will affect world generation!!!""",
|
||||
+ """
|
||||
+ 是否为世界生成启用更快的随机生成器.
|
||||
+ 警告: 此项会影响世界生成!!!"""));
|
||||
+ warnForSlimeChunk = config.getBoolean(getBasePath() + ".warn-for-slime-chunk", warnForSlimeChunk,
|
||||
+ config.pickStringRegionBased(
|
||||
+ "Warn if you are not using legacy random source for slime chunk generation.",
|
||||
@@ -111,6 +370,16 @@ index 0000000000000000000000000000000000000000..1c90bcfef92a383ee16f551c5a5bff3e
|
||||
+ """
|
||||
+ 是否使用原版随机生成器来生成史莱姆区块."""));
|
||||
+
|
||||
+ if (enabled) {
|
||||
+ try {
|
||||
+ RandomGeneratorFactory.of(randomGenerator);
|
||||
+ } catch (Exception e) {
|
||||
+ LeafConfig.LOGGER.error("Faster random generator is enabled but {} is not supported by your JVM, " +
|
||||
+ "falling back to legacy random source.", randomGenerator);
|
||||
+ enabled = false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (enabled && warnForSlimeChunk) {
|
||||
+ LeafConfig.LOGGER.warn("You enabled faster random generator, it will offset location of slime chunk");
|
||||
+ LeafConfig.LOGGER.warn("If your server has slime farms or facilities need vanilla slime chunk,");
|
||||
@@ -121,98 +390,149 @@ index 0000000000000000000000000000000000000000..1c90bcfef92a383ee16f551c5a5bff3e
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/dreeam/leaf/util/math/random/TheFasterRandom.java b/src/main/java/org/dreeam/leaf/util/math/random/TheFasterRandom.java
|
||||
diff --git a/src/main/java/org/dreeam/leaf/util/math/random/FasterRandomSource.java b/src/main/java/org/dreeam/leaf/util/math/random/FasterRandomSource.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..c13c8e5a2fba4267eb254e75f993bc6a9b861f6e
|
||||
index 0000000000000000000000000000000000000000..77fe5ab83535156c016a4808969ae76bd6b92288
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/dreeam/leaf/util/math/random/TheFasterRandom.java
|
||||
@@ -0,0 +1,89 @@
|
||||
+++ b/src/main/java/org/dreeam/leaf/util/math/random/FasterRandomSource.java
|
||||
@@ -0,0 +1,127 @@
|
||||
+package org.dreeam.leaf.util.math.random;
|
||||
+
|
||||
+import com.google.common.annotations.VisibleForTesting;
|
||||
+import net.minecraft.util.Mth;
|
||||
+import net.minecraft.util.RandomSource;
|
||||
+import net.minecraft.world.level.levelgen.BitRandomSource;
|
||||
+import net.minecraft.world.level.levelgen.LegacyRandomSource;
|
||||
+import net.minecraft.world.level.levelgen.PositionalRandomFactory;
|
||||
+import org.dreeam.leaf.config.modules.opt.FastRNG;
|
||||
+
|
||||
+import java.util.concurrent.ThreadLocalRandom;
|
||||
+import java.util.random.RandomGenerator;
|
||||
+import java.util.random.RandomGeneratorFactory;
|
||||
+
|
||||
+
|
||||
+public class TheFasterRandom implements BitRandomSource {
|
||||
+public class FasterRandomSource implements BitRandomSource {
|
||||
+ private static final int INT_BITS = 48;
|
||||
+ private static final long SEED_MASK = 0xFFFFFFFFFFFFL;
|
||||
+ private static final long MULTIPLIER = 25214903917L;
|
||||
+ private static final long INCREMENT = 11L;
|
||||
+ private static final RandomGeneratorFactory<RandomGenerator.SplittableGenerator> RANDOM_GENERATOR_FACTORY = RandomGeneratorFactory.of(
|
||||
+ "L64X128MixRandom");
|
||||
+
|
||||
+ private static final RandomGeneratorFactory<RandomGenerator> RANDOM_GENERATOR_FACTORY = RandomGeneratorFactory.of(FastRNG.randomGenerator);
|
||||
+ private static final boolean isSplittableGenerator = RANDOM_GENERATOR_FACTORY.isSplittable();
|
||||
+ private long seed;
|
||||
+ private RandomGenerator.SplittableGenerator randomGenerator;
|
||||
+ private RandomGenerator randomGenerator;
|
||||
+ public static final FasterRandomSource SHARED_INSTANCE = new FasterRandomSource(ThreadLocalRandom.current().nextLong());
|
||||
+
|
||||
+ public TheFasterRandom(long seed) {
|
||||
+ public FasterRandomSource(long seed) {
|
||||
+ this.seed = seed;
|
||||
+ this.randomGenerator = RANDOM_GENERATOR_FACTORY.create(seed);
|
||||
+ }
|
||||
+
|
||||
+ public TheFasterRandom(long seed, RandomGenerator.SplittableGenerator randomGenerator) {
|
||||
+ private FasterRandomSource(long seed, RandomGenerator.SplittableGenerator randomGenerator) {
|
||||
+ this.seed = seed;
|
||||
+ this.randomGenerator = randomGenerator;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public RandomSource fork() {
|
||||
+ return new TheFasterRandom(seed, randomGenerator.split());
|
||||
+ public final RandomSource fork() {
|
||||
+ if (isSplittableGenerator) {
|
||||
+ return new FasterRandomSource(seed, ((RandomGenerator.SplittableGenerator) this.randomGenerator).split());
|
||||
+ }
|
||||
+ return new FasterRandomSource(this.nextLong());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public PositionalRandomFactory forkPositional() {
|
||||
+ return new LegacyRandomSource.LegacyPositionalRandomFactory(this.seed);
|
||||
+ public final PositionalRandomFactory forkPositional() {
|
||||
+ return new FasterRandomSourcePositionalRandomFactory(this.seed);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setSeed(long seed) {
|
||||
+ public final void setSeed(long seed) {
|
||||
+ this.seed = seed;
|
||||
+ this.randomGenerator = RANDOM_GENERATOR_FACTORY.create(seed);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int next(int bits) {
|
||||
+ public final int next(int bits) {
|
||||
+ // >>> instead of Mojang's >> fixes MC-239059
|
||||
+ return (int) ((seed * MULTIPLIER + INCREMENT & SEED_MASK) >>> INT_BITS - bits);
|
||||
+ }
|
||||
+
|
||||
+ public static class FasterRandomSourcePositionalRandomFactory implements PositionalRandomFactory {
|
||||
+ private final long seed;
|
||||
+
|
||||
+ public FasterRandomSourcePositionalRandomFactory(long seed) {
|
||||
+ this.seed = seed;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public RandomSource at(int x, int y, int z) {
|
||||
+ long l = Mth.getSeed(x, y, z);
|
||||
+ long m = l ^ this.seed;
|
||||
+ return new FasterRandomSource(m);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public RandomSource fromHashOf(String seed) {
|
||||
+ int i = seed.hashCode();
|
||||
+ return new FasterRandomSource((long)i ^ this.seed);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public RandomSource fromSeed(long seed) {
|
||||
+ return new FasterRandomSource(seed);
|
||||
+ }
|
||||
+
|
||||
+ @VisibleForTesting
|
||||
+ @Override
|
||||
+ public void parityConfigString(StringBuilder info) {
|
||||
+ info.append("FasterRandomSourcePositionalRandomFactory{").append(this.seed).append("}");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int nextInt() {
|
||||
+ public final int nextInt() {
|
||||
+ return randomGenerator.nextInt();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int nextInt(int bound) {
|
||||
+ public final int nextInt(int bound) {
|
||||
+ return randomGenerator.nextInt(bound);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public long nextLong() {
|
||||
+ public final long nextLong() {
|
||||
+ return randomGenerator.nextLong();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean nextBoolean() {
|
||||
+ public final boolean nextBoolean() {
|
||||
+ return randomGenerator.nextBoolean();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public float nextFloat() {
|
||||
+ public final float nextFloat() {
|
||||
+ return randomGenerator.nextFloat();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public double nextDouble() {
|
||||
+ public final double nextDouble() {
|
||||
+ return randomGenerator.nextDouble();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public double nextGaussian() {
|
||||
+ public final double nextGaussian() {
|
||||
+ return randomGenerator.nextGaussian();
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/su/plo/matter/WorldgenCryptoRandom.java b/src/main/java/su/plo/matter/WorldgenCryptoRandom.java
|
||||
index fab359afe44c573b8b315115810ddefd85b4d22b..42f4ca3f8ef3b5c4152b4b58e51cdba229ff1a0a 100644
|
||||
--- a/src/main/java/su/plo/matter/WorldgenCryptoRandom.java
|
||||
+++ b/src/main/java/su/plo/matter/WorldgenCryptoRandom.java
|
||||
@@ -24,7 +24,7 @@ public class WorldgenCryptoRandom extends WorldgenRandom {
|
||||
private final long[] cachedInternalState = new long[16];
|
||||
|
||||
public WorldgenCryptoRandom(int x, int z, Globals.Salt typeSalt, long salt) {
|
||||
- super(new LegacyRandomSource(0L));
|
||||
+ super(org.dreeam.leaf.config.modules.opt.FastRNG.enabled ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L));
|
||||
if (typeSalt != null) {
|
||||
this.setSecureSeed(x, z, typeSalt, salt);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Configurable connection message
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 2cdfd22baf31df99e2c2b1d114c47cb88569538f..8e3bbc7a0cf2a3e5999738c0f764544f5e64ef4a 100644
|
||||
index 0d791d0e0cbbc77dd1e5b376f82c26e3618c236e..6da4b4d3f00527aabf398ab614140bc6f8c7442c 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -452,7 +452,7 @@ public abstract class PlayerList {
|
||||
@@ -35,7 +35,7 @@ index 2cdfd22baf31df99e2c2b1d114c47cb88569538f..8e3bbc7a0cf2a3e5999738c0f764544f
|
||||
this.cserver.getPluginManager().callEvent(playerQuitEvent);
|
||||
entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage());
|
||||
|
||||
@@ -1812,4 +1812,29 @@ public abstract class PlayerList {
|
||||
@@ -1814,4 +1814,29 @@ public abstract class PlayerList {
|
||||
public boolean isAllowCommandsForAllPlayers() {
|
||||
return this.allowCommandsForAllPlayers;
|
||||
}
|
||||
|
||||
@@ -368,7 +368,7 @@ index 14ceb3308474e76220bd64b0254df3f2925d4206..6cd45791b19df76e367d2693bce349c6
|
||||
private final net.minecraft.world.entity.LivingEntity entity; // Purpur
|
||||
diff --git a/src/main/java/org/dreeam/leaf/async/tracker/MultithreadedTracker.java b/src/main/java/org/dreeam/leaf/async/tracker/MultithreadedTracker.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..1ecaa9f4b4843c05af2139ae3e4b0dd00a78a917
|
||||
index 0000000000000000000000000000000000000000..4f214a8f058434cb7f4930df75fc3d0f310878ae
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/dreeam/leaf/async/tracker/MultithreadedTracker.java
|
||||
@@ -0,0 +1,182 @@
|
||||
@@ -435,7 +435,7 @@ index 0000000000000000000000000000000000000000..1ecaa9f4b4843c05af2139ae3e4b0dd0
|
||||
+ tickAsyncWithCompatMode(level);
|
||||
+ }
|
||||
+ } catch (Exception e) {
|
||||
+ LOGGER.error("Failed to execute async task.", e);
|
||||
+ LOGGER.error("Error occurred while executing async task.", e);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
|
||||
@@ -251,10 +251,10 @@ index d8ce44a180f848f4c9c04967470c4359af979b2f..90abb83a6baa60bbcbedc7d818c3bc9f
|
||||
}
|
||||
diff --git a/src/main/java/org/dreeam/leaf/async/locate/AsyncLocator.java b/src/main/java/org/dreeam/leaf/async/locate/AsyncLocator.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0eaa9b60ac139db47a028970557c3a84166efc49
|
||||
index 0000000000000000000000000000000000000000..fcede5af1f1352a8c8c089993040838d1e7c3042
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/dreeam/leaf/async/locate/AsyncLocator.java
|
||||
@@ -0,0 +1,160 @@
|
||||
@@ -0,0 +1,164 @@
|
||||
+package org.dreeam.leaf.async.locate;
|
||||
+
|
||||
+import ca.spottedleaf.moonrise.common.util.TickThread;
|
||||
@@ -293,8 +293,12 @@ index 0000000000000000000000000000000000000000..0eaa9b60ac139db47a028970557c3a84
|
||||
+
|
||||
+ static {
|
||||
+ int threads = org.dreeam.leaf.config.modules.async.AsyncLocator.asyncLocatorThreads;
|
||||
+ LOCATING_EXECUTOR_SERVICE = Executors.newFixedThreadPool(
|
||||
+ LOCATING_EXECUTOR_SERVICE = new ThreadPoolExecutor(
|
||||
+ 1,
|
||||
+ threads,
|
||||
+ org.dreeam.leaf.config.modules.async.AsyncLocator.asyncLocatorKeepalive,
|
||||
+ TimeUnit.SECONDS,
|
||||
+ new LinkedBlockingQueue<>(),
|
||||
+ new ThreadFactoryBuilder()
|
||||
+ .setThreadFactory(
|
||||
+ r -> new AsyncLocatorThread(r, "Leaf Async Locator Thread") {
|
||||
@@ -418,7 +422,7 @@ index 0000000000000000000000000000000000000000..0eaa9b60ac139db47a028970557c3a84
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/org/dreeam/leaf/config/modules/async/AsyncLocator.java b/src/main/java/org/dreeam/leaf/config/modules/async/AsyncLocator.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0a2e562af7f7b08f6e95702f26f97f2c6f6aeb02
|
||||
index 0000000000000000000000000000000000000000..0d741e4d6e7a39cf3da0f40816daa0405122a90a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/dreeam/leaf/config/modules/async/AsyncLocator.java
|
||||
@@ -0,0 +1,37 @@
|
||||
@@ -436,6 +440,7 @@ index 0000000000000000000000000000000000000000..0a2e562af7f7b08f6e95702f26f97f2c
|
||||
+
|
||||
+ public static boolean enabled = false;
|
||||
+ public static int asyncLocatorThreads = 0;
|
||||
+ public static int asyncLocatorKeepalive = 60;
|
||||
+
|
||||
+ @Override
|
||||
+ public void onLoaded() {
|
||||
@@ -448,11 +453,10 @@ index 0000000000000000000000000000000000000000..0a2e562af7f7b08f6e95702f26f97f2c
|
||||
+ 目前可用于 /locate 指令, 海豚寻宝和末影之眼.""");
|
||||
+ enabled = config.getBoolean(getBasePath() + ".enabled", enabled);
|
||||
+ asyncLocatorThreads = config.getInt(getBasePath() + ".threads", asyncLocatorThreads);
|
||||
+ asyncLocatorKeepalive = config.getInt(getBasePath() + ".keepalive", asyncLocatorKeepalive);
|
||||
+
|
||||
+ if (asyncLocatorThreads < 0)
|
||||
+ asyncLocatorThreads = Math.max(Runtime.getRuntime().availableProcessors() + asyncLocatorThreads, 1);
|
||||
+ else if (asyncLocatorThreads == 0)
|
||||
+ asyncLocatorThreads = Math.max(Runtime.getRuntime().availableProcessors() / 4, 1);
|
||||
+ if (asyncLocatorThreads <= 0)
|
||||
+ asyncLocatorThreads = 1;
|
||||
+ if (!enabled)
|
||||
+ asyncLocatorThreads = 0;
|
||||
+ else
|
||||
|
||||
Reference in New Issue
Block a user