mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-15 03:41:30 +01:00
feat: add properties to configure chunk queue
This commit is contained in:
parent
40ac94d092
commit
a910ce359d
@ -79,6 +79,7 @@ import net.minestom.server.statistic.PlayerStatistic;
|
|||||||
import net.minestom.server.timer.Scheduler;
|
import net.minestom.server.timer.Scheduler;
|
||||||
import net.minestom.server.utils.MathUtils;
|
import net.minestom.server.utils.MathUtils;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
import net.minestom.server.utils.PacketUtils;
|
||||||
|
import net.minestom.server.utils.PropertyUtils;
|
||||||
import net.minestom.server.utils.async.AsyncUtils;
|
import net.minestom.server.utils.async.AsyncUtils;
|
||||||
import net.minestom.server.utils.chunk.ChunkUpdateLimitChecker;
|
import net.minestom.server.utils.chunk.ChunkUpdateLimitChecker;
|
||||||
import net.minestom.server.utils.chunk.ChunkUtils;
|
import net.minestom.server.utils.chunk.ChunkUtils;
|
||||||
@ -121,8 +122,9 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
|||||||
private static final int PACKET_PER_TICK = Integer.getInteger("minestom.packet-per-tick", 20);
|
private static final int PACKET_PER_TICK = Integer.getInteger("minestom.packet-per-tick", 20);
|
||||||
private static final int PACKET_QUEUE_SIZE = Integer.getInteger("minestom.packet-queue-size", 1000);
|
private static final int PACKET_QUEUE_SIZE = Integer.getInteger("minestom.packet-queue-size", 1000);
|
||||||
|
|
||||||
private static final float MIN_CHUNKS_PER_TICK = 0.01f;
|
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 = 64.0f;
|
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");
|
public static final boolean EXPERIMENT_PERFORM_POSE_UPDATES = Boolean.getBoolean("minestom.experiment.pose-updates");
|
||||||
|
|
||||||
@ -767,8 +769,8 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
|||||||
public void onChunkBatchReceived(float newTargetChunksPerTick) {
|
public void onChunkBatchReceived(float newTargetChunksPerTick) {
|
||||||
// logger.debug("chunk batch received player={} chunks/tick={} lead={}", username, newTargetChunksPerTick, chunkBatchLead);
|
// logger.debug("chunk batch received player={} chunks/tick={} lead={}", username, newTargetChunksPerTick, chunkBatchLead);
|
||||||
chunkBatchLead -= 1;
|
chunkBatchLead -= 1;
|
||||||
targetChunksPerTick = Float.isNaN(newTargetChunksPerTick) ? MIN_CHUNKS_PER_TICK
|
targetChunksPerTick = Float.isNaN(newTargetChunksPerTick) ? MIN_CHUNKS_PER_TICK : MathUtils.clamp(
|
||||||
: MathUtils.clamp(newTargetChunksPerTick, MIN_CHUNKS_PER_TICK, MAX_CHUNKS_PER_TICK);
|
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)
|
// Beyond the first batch we can preemptively send up to 10 (matching mojang server)
|
||||||
if (maxChunkBatchLead == 1) maxChunkBatchLead = 10;
|
if (maxChunkBatchLead == 1) maxChunkBatchLead = 10;
|
||||||
|
@ -23,4 +23,14 @@ public final class PropertyUtils {
|
|||||||
public static String getString(@NotNull String name, @Nullable String defaultValue) {
|
public static String getString(@NotNull String name, @Nullable String defaultValue) {
|
||||||
return System.getProperty(name, 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user