mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
73ffcb09faoptimize mob spawning333373d204fix async mob spawning data race7c9f88e4f8[ci skip] cleanupbf9486f0f0remove hash lookup in optimize random tick915ac01cd3cleanupb90c1cd527fix playermobcaps commandfd34d9f626cleanup5d663b4d36optimize collectSpawningChunks (#382)
65 lines
4.0 KiB
Diff
65 lines
4.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: hayanesuru <hayanesuru@outlook.jp>
|
|
Date: Fri, 6 Jun 2025 20:46:10 +0900
|
|
Subject: [PATCH] optimize random tick
|
|
|
|
|
|
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
|
index 56516dd07433161f5afd448aaf535c59d14c2528..9992eeda9535e6304e7019e7eb7e5c1458ddd89e 100644
|
|
--- a/net/minecraft/server/level/ServerChunkCache.java
|
|
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
|
@@ -675,7 +675,13 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
|
list.clear();
|
|
}
|
|
|
|
- this.iterateTickingChunksFaster(); // Paper - chunk tick iteration optimisations
|
|
+ // Leaf start - optimize random tick
|
|
+ if (org.dreeam.leaf.config.modules.opt.OptimizeRandomTick.enabled) {
|
|
+ this.level.randomTickSystem.tick(this.level);
|
|
+ } else {
|
|
+ this.iterateTickingChunksFaster(); // Paper - chunk tick iteration optimisations
|
|
+ }
|
|
+ // Leaf end - optimize random tick
|
|
if (_boolean) {
|
|
this.level.tickCustomSpawners(this.spawnEnemies, this.spawnFriendlies);
|
|
}
|
|
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
|
index 983b03c9cf1c91e9954da0ed8be99c2dfaa5a9c6..4bd5e0268d52d63e160ccfe3d1509bbda421bc0f 100644
|
|
--- a/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1111,6 +1111,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 final org.dreeam.leaf.world.NatureSpawnChunkMap natureSpawnChunkMap = new org.dreeam.leaf.world.NatureSpawnChunkMap(); // Leaf - optimize mob spawning
|
|
+ public final org.dreeam.leaf.world.RandomTickSystem randomTickSystem = new org.dreeam.leaf.world.RandomTickSystem(); // Leaf - optimize random tick
|
|
public void tickChunk(LevelChunk chunk, int randomTickSpeed) {
|
|
final net.minecraft.world.level.levelgen.BitRandomSource simpleRandom = this.simpleRandom; // Paper - optimise random ticking // Leaf - Faster random generator - upcasting
|
|
ChunkPos pos = chunk.getPos();
|
|
diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java
|
|
index 31f19dfe16e270b55f3b44754c97ed8d9fa422cf..174da710d2b86de98cbf6499d4a954f9476a225a 100644
|
|
--- a/net/minecraft/world/level/chunk/LevelChunk.java
|
|
+++ b/net/minecraft/world/level/chunk/LevelChunk.java
|
|
@@ -150,6 +150,10 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
|
}
|
|
// Gale end - Airplane - optimize random calls in chunk ticking - instead of using a random every time the chunk is ticked, define when lightning strikes preemptively
|
|
|
|
+ // Leaf start - optimize random tick
|
|
+ public boolean leaf$tickingBlocksDirty = true;
|
|
+ public int[] leaf$tickingCount = {};
|
|
+ // Leaf end - optimize random tick
|
|
public LevelChunk(Level level, ChunkPos pos) {
|
|
this(level, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, null, null, null);
|
|
}
|
|
@@ -414,6 +418,11 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
|
if (blockState == state) {
|
|
return null;
|
|
} else {
|
|
+ // Leaf start - optimize random tick
|
|
+ if (blockState.isRandomlyTicking() != state.isRandomlyTicking()) {
|
|
+ leaf$tickingBlocksDirty = true;
|
|
+ }
|
|
+ // Leaf end - optimize random tick
|
|
Block block = state.getBlock();
|
|
this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING).update(i, y, i2, state);
|
|
this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES).update(i, y, i2, state);
|