From e9eb96862c0521e66edc07659d50759c72a00f73 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Sun, 1 Dec 2024 14:07:46 -0800 Subject: [PATCH] Properly handle large values of spawnChunkRadius The chunk system does not allow ticket levels below 0, so we need to add tickets for each individual chunk instead. --- ...rtup-flag-to-disable-gamerule-limits.patch | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/patches/server/Add-startup-flag-to-disable-gamerule-limits.patch b/patches/server/Add-startup-flag-to-disable-gamerule-limits.patch index 3859ab859e..c06a806cdc 100644 --- a/patches/server/Add-startup-flag-to-disable-gamerule-limits.patch +++ b/patches/server/Add-startup-flag-to-disable-gamerule-limits.patch @@ -5,6 +5,34 @@ Subject: [PATCH] Add startup flag to disable gamerule limits -DPaper.DisableGameRuleLimits=true will disable gamerule limits +diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/level/ServerLevel.java ++++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + } + + if (this.lastSpawnChunkRadius > 1) { +- this.getChunkSource().removeRegionTicket(TicketType.START, new ChunkPos(blockposition1), this.lastSpawnChunkRadius, Unit.INSTANCE); ++ // Paper start - allow disabling gamerule limits ++ for (ChunkPos chunkPos : io.papermc.paper.util.MCUtil.getSpiralOutChunks(blockposition1, this.lastSpawnChunkRadius - 2)) { ++ this.getChunkSource().removeTicketAtLevel(TicketType.START, chunkPos, net.minecraft.server.level.ChunkLevel.ENTITY_TICKING_LEVEL, Unit.INSTANCE); ++ } ++ // Paper end - allow disabling gamerule limits + } + + int i = this.getGameRules().getInt(GameRules.RULE_SPAWN_CHUNK_RADIUS) + 1; + + if (i > 1) { +- this.getChunkSource().addRegionTicket(TicketType.START, new ChunkPos(pos), i, Unit.INSTANCE); ++ // Paper start - allow disabling gamerule limits ++ for (ChunkPos chunkPos : io.papermc.paper.util.MCUtil.getSpiralOutChunks(pos, i - 2)) { ++ this.getChunkSource().addTicketAtLevel(TicketType.START, chunkPos, net.minecraft.server.level.ChunkLevel.ENTITY_TICKING_LEVEL, Unit.INSTANCE); ++ } ++ // Paper end - allow disabling gamerule limits + } + + this.lastSpawnChunkRadius = i; diff --git a/src/main/java/net/minecraft/world/level/GameRules.java b/src/main/java/net/minecraft/world/level/GameRules.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/GameRules.java