diff --git a/src/main/java/net/minestom/server/entity/Player.java b/src/main/java/net/minestom/server/entity/Player.java index cba2e0d4a..5b2886ae1 100644 --- a/src/main/java/net/minestom/server/entity/Player.java +++ b/src/main/java/net/minestom/server/entity/Player.java @@ -80,6 +80,7 @@ import net.minestom.server.statistic.PlayerStatistic; import net.minestom.server.timer.Scheduler; import net.minestom.server.utils.MathUtils; import net.minestom.server.utils.PacketUtils; +import net.minestom.server.utils.PropertyUtils; import net.minestom.server.utils.async.AsyncUtils; import net.minestom.server.utils.chunk.ChunkUpdateLimitChecker; import net.minestom.server.utils.chunk.ChunkUtils; @@ -120,8 +121,9 @@ public class Player extends LivingEntity implements CommandSender, Localizable, private static final Component REMOVE_MESSAGE = Component.text("You have been removed from the server without reason.", NamedTextColor.RED); - private static final float MIN_CHUNKS_PER_TICK = 0.01f; - private static final float MAX_CHUNKS_PER_TICK = 64.0f; + private static final float MIN_CHUNKS_PER_TICK = PropertyUtils.getFloat("minestom.chunk-queue.min-per-tick", 0.01f); + private static final float MAX_CHUNKS_PER_TICK = PropertyUtils.getFloat("minestom.chunk-queue.max-per-tick", 64.0f); + private static final float CHUNKS_PER_TICK_MULTIPLIER = PropertyUtils.getFloat("minestom.chunk-queue.multiplier", 1f); public static final boolean EXPERIMENT_PERFORM_POSE_UPDATES = Boolean.getBoolean("minestom.experiment.pose-updates"); @@ -772,8 +774,8 @@ public class Player extends LivingEntity implements CommandSender, Localizable, public void onChunkBatchReceived(float newTargetChunksPerTick) { // logger.debug("chunk batch received player={} chunks/tick={} lead={}", username, newTargetChunksPerTick, chunkBatchLead); chunkBatchLead -= 1; - targetChunksPerTick = Float.isNaN(newTargetChunksPerTick) ? MIN_CHUNKS_PER_TICK - : MathUtils.clamp(newTargetChunksPerTick, MIN_CHUNKS_PER_TICK, MAX_CHUNKS_PER_TICK); + targetChunksPerTick = Float.isNaN(newTargetChunksPerTick) ? MIN_CHUNKS_PER_TICK : MathUtils.clamp( + newTargetChunksPerTick * CHUNKS_PER_TICK_MULTIPLIER, MIN_CHUNKS_PER_TICK, MAX_CHUNKS_PER_TICK); // Beyond the first batch we can preemptively send up to 10 (matching mojang server) if (maxChunkBatchLead == 1) maxChunkBatchLead = 10; diff --git a/src/main/java/net/minestom/server/utils/PropertyUtils.java b/src/main/java/net/minestom/server/utils/PropertyUtils.java index 62d82f286..25a796af4 100644 --- a/src/main/java/net/minestom/server/utils/PropertyUtils.java +++ b/src/main/java/net/minestom/server/utils/PropertyUtils.java @@ -23,4 +23,14 @@ public final class PropertyUtils { public static String getString(@NotNull String name, @Nullable String defaultValue) { return System.getProperty(name, defaultValue); } + + public static Float getFloat(String name, Float defaultValue) { + Float result = defaultValue; + try { + final String value = System.getProperty(name); + if (value != null) result = Float.parseFloat(value); + } catch (IllegalArgumentException | NullPointerException ignored) { + } + return result; + } }