hollow-cube/chunk-sending-rate-config

(cherry picked from commit a981bd78ff)
This commit is contained in:
mworzala 2023-06-30 16:41:00 -04:00 committed by Matt Worzala
parent 7cce1aa479
commit f31b74a386
2 changed files with 4 additions and 2 deletions

View File

@ -707,14 +707,14 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
(x, z) -> chunkQueue.add(ChunkUtils.getChunkIndex(x, z)));
var iter = chunkQueue.iterator();
Supplier<TaskSchedule> taskRunnable = () -> {
for (int i = 0; i < 50; i++) {
for (int i = 0; i < ChunkUtils.NEW_CHUNK_COUNT_PER_INTERVAL; i++) {
if (!iter.hasNext()) return TaskSchedule.stop();
var next = iter.nextLong();
chunkAdder.accept(ChunkUtils.getChunkCoordX(next), ChunkUtils.getChunkCoordZ(next));
}
return TaskSchedule.tick(20);
return TaskSchedule.tick(ChunkUtils.NEW_CHUNK_SEND_INTERVAL);
};
scheduler().submitTask(taskRunnable);
} else {

View File

@ -17,6 +17,8 @@ import java.util.function.Consumer;
public final class ChunkUtils {
public static final boolean USE_NEW_CHUNK_SENDING = Boolean.getBoolean("minestom.use-new-chunk-sending");
public static final int NEW_CHUNK_COUNT_PER_INTERVAL = Integer.getInteger("minestom.new-chunk-sending-count-per-interval", 50);
public static final int NEW_CHUNK_SEND_INTERVAL = Integer.getInteger("minestom.new-chunk-sending-send-interval", 20);
private ChunkUtils() {
}