Optimise chunk tick iteration

When per-player mob spawning is enabled we do not need to randomly
shuffle the chunk list. Additionally, we can use the NearbyPlayers
class to quickly retrieve nearby players instead of possible
searching all players on the server.
This commit is contained in:
Spottedleaf 2023-09-23 21:43:10 -07:00
parent 8d922746d9
commit 38dc3b25d8
54 changed files with 1115 additions and 1340 deletions

View file

@ -131,7 +131,7 @@ index 5d65baba605dd83e5f74d526aeda36d8ede8c014..92e76dd39dc3575e9466031dd799080a
}
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index 515aedcf9969b818dfdc02a16a7f7178b5bb5593..56900156d79781f15357a3d25906d32b615366ce 100644
index fde60133d2c5557cd8d4a4d2e3a16aa96974fcbb..d13652d5001c117582b8c470d40207a6c10cb096 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -1,6 +1,7 @@
@ -142,7 +142,7 @@ index 515aedcf9969b818dfdc02a16a7f7178b5bb5593..56900156d79781f15357a3d25906d32b
import com.google.common.collect.Maps;
import com.google.common.collect.UnmodifiableIterator;
import com.mojang.logging.LogUtils;
@@ -568,10 +569,16 @@ public class LevelChunk extends ChunkAccess {
@@ -569,10 +570,16 @@ public class LevelChunk extends ChunkAccess {
// CraftBukkit start
} else {
@ -163,7 +163,7 @@ index 515aedcf9969b818dfdc02a16a7f7178b5bb5593..56900156d79781f15357a3d25906d32b
// CraftBukkit end
}
}
@@ -1149,6 +1156,7 @@ public class LevelChunk extends ChunkAccess {
@@ -1150,6 +1157,7 @@ public class LevelChunk extends ChunkAccess {
// Paper start - Prevent tile entity and entity crashes
final String msg = String.format("BlockEntity threw exception at %s:%s,%s,%s", LevelChunk.this.getLevel().getWorld().getName(), this.getPos().getX(), this.getPos().getY(), this.getPos().getZ());
net.minecraft.server.MinecraftServer.LOGGER.error(msg, throwable);