mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
count all chunks for ticking
Co-authored-by: Taiyou06 <kaandindar21@gmail.com>
This commit is contained in:
@@ -1,24 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Taiyou06 <kaandindar21@gmail.com>
|
|
||||||
Date: Sun, 16 Feb 2025 01:13:04 +0100
|
|
||||||
Subject: [PATCH] Use ensureCapacity to pre-populate the size of ticking chunks
|
|
||||||
list output
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
|
||||||
index 0fd51020ca9480be2855eb58a7d4d43511829512..b1400a1cc41717437ccb0f2b7854e54c5b985985 100644
|
|
||||||
--- a/net/minecraft/server/level/ServerChunkCache.java
|
|
||||||
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
|
||||||
@@ -585,7 +585,11 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
|
||||||
final ServerChunkCache.ChunkAndHolder[] raw = tickingChunks.getRawDataUnchecked();
|
|
||||||
final int size = tickingChunks.size();
|
|
||||||
|
|
||||||
- final ChunkMap chunkMap = this.chunkMap;
|
|
||||||
+ // Leaf start - Use ensureCapacity to pre-populate the size of ticking chunks list output
|
|
||||||
+ if (output instanceof ArrayList<LevelChunk> arrayList) {
|
|
||||||
+ arrayList.ensureCapacity(size);
|
|
||||||
+ }
|
|
||||||
+ // Leaf end - Use ensureCapacity to pre-populate the size of ticking chunks list output
|
|
||||||
|
|
||||||
for (int i = 0; i < size; ++i) {
|
|
||||||
final ServerChunkCache.ChunkAndHolder chunkAndHolder = raw[i];
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Taiyou06 <kaandindar21@gmail.com>
|
|
||||||
Date: Sun, 16 Feb 2025 01:13:04 +0100
|
|
||||||
Subject: [PATCH] Directly use the pre-filtered ticking chunks list as the
|
|
||||||
output
|
|
||||||
|
|
||||||
This patch uses already pre filtered chunks, which completely skips the isChunkNearPlayer check
|
|
||||||
|
|
||||||
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
|
||||||
index b1400a1cc41717437ccb0f2b7854e54c5b985985..f57f8e610dac80b8095bfc0c7e4b22ff5ad6b13c 100644
|
|
||||||
--- a/net/minecraft/server/level/ServerChunkCache.java
|
|
||||||
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
|
||||||
@@ -592,14 +592,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
|
||||||
// Leaf end - Use ensureCapacity to pre-populate the size of ticking chunks list output
|
|
||||||
|
|
||||||
for (int i = 0; i < size; ++i) {
|
|
||||||
- final ServerChunkCache.ChunkAndHolder chunkAndHolder = raw[i];
|
|
||||||
- final LevelChunk levelChunk = chunkAndHolder.chunk();
|
|
||||||
-
|
|
||||||
- if (!this.isChunkNearPlayer(chunkMap, levelChunk.getPos(), levelChunk)) {
|
|
||||||
- continue;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- output.add(levelChunk);
|
|
||||||
+ output.add(raw[i].chunk()); // Leaf - Directly use the pre-filtered ticking chunks list as the output
|
|
||||||
}
|
|
||||||
// Paper end - chunk tick iteration optimisation
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Taiyou06 <kaandindar21@gmail.com>
|
||||||
|
Date: Sun, 16 Feb 2025 01:13:04 +0100
|
||||||
|
Subject: [PATCH] count all chunks for ticking
|
||||||
|
|
||||||
|
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
||||||
|
index e07fdd22e08cb4e30cf606c055e85b5946e8c046..432c98b582ab40f893835a7a24ef9bbdacc49bd7 100644
|
||||||
|
--- a/net/minecraft/server/level/ServerChunkCache.java
|
||||||
|
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
||||||
|
@@ -589,6 +589,14 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||||
|
final int size = tickingChunks.size();
|
||||||
|
|
||||||
|
final ChunkMap chunkMap = this.chunkMap;
|
||||||
|
+ // Leaf start - count all chunks for ticking
|
||||||
|
+ if (org.dreeam.leaf.config.modules.opt.CountAllChunksForTicking.enabled) {
|
||||||
|
+ for (int i = 0; i < size; ++i) {
|
||||||
|
+ output.add(raw[i].chunk());
|
||||||
|
+ }
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ // Leaf end - count all chunks for ticking
|
||||||
|
|
||||||
|
for (int i = 0; i < size; ++i) {
|
||||||
|
final ServerChunkCache.ChunkAndHolder chunkAndHolder = raw[i];
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package org.dreeam.leaf.config.modules.opt;
|
||||||
|
|
||||||
|
import org.dreeam.leaf.config.ConfigModules;
|
||||||
|
import org.dreeam.leaf.config.EnumConfigCategory;
|
||||||
|
|
||||||
|
public class CountAllChunksForTicking extends ConfigModules {
|
||||||
|
|
||||||
|
public String getBasePath() {
|
||||||
|
return EnumConfigCategory.PERF.getBaseKeyName() + ".count-all-chunks-for-ticking";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean enabled = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoaded() {
|
||||||
|
enabled = config.getBoolean(getBasePath(), enabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user