From 4b842fc4c0a3b1801bf4e63cc555271283bd7f1a Mon Sep 17 00:00:00 2001 From: Kris Bichocolate Date: Fri, 16 May 2025 13:40:13 +0200 Subject: [PATCH] Make saved forced chunks work Previously, the list of forceload'ed chunks was saved and would be visible with the query command, but the actual loading didn't happen. This copies the part of MinecraftServer's prepareStartRegion that deals with it when loading saves into fantasy's world prep code. --- .../java/xyz/nucleoid/fantasy/RuntimeWorldManager.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/xyz/nucleoid/fantasy/RuntimeWorldManager.java b/src/main/java/xyz/nucleoid/fantasy/RuntimeWorldManager.java index ed4ba23..2fc45f8 100644 --- a/src/main/java/xyz/nucleoid/fantasy/RuntimeWorldManager.java +++ b/src/main/java/xyz/nucleoid/fantasy/RuntimeWorldManager.java @@ -7,6 +7,7 @@ import net.minecraft.registry.SimpleRegistry; import net.minecraft.registry.entry.RegistryEntryInfo; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.world.ChunkTicketManager; import net.minecraft.server.world.ServerWorld; import net.minecraft.text.Text; import net.minecraft.util.ProgressListener; @@ -47,6 +48,7 @@ RuntimeWorld add(RegistryKey worldKey, RuntimeWorldConfig config, Runtime ((RemoveFromRegistry) dimensionsRegistry).fantasy$setFrozen(isFrozen); RuntimeWorld world = config.getWorldConstructor().createWorld(this.server, worldKey, config, style); + this.promoteForcedChunksToTickets(world); this.serverAccess.getWorlds().put(world.getRegistryKey(), world); ServerWorldEvents.LOAD.invoker().onWorldLoad(this.server, world); @@ -57,6 +59,13 @@ RuntimeWorld add(RegistryKey worldKey, RuntimeWorldConfig config, Runtime return world; } + private void promoteForcedChunksToTickets(ServerWorld world) { + ChunkTicketManager chunkTicketManager = world.getPersistentStateManager().get(ChunkTicketManager.STATE_TYPE); + if (chunkTicketManager != null) { + chunkTicketManager.promoteToRealTickets(); + } + } + void delete(ServerWorld world) { RegistryKey dimensionKey = world.getRegistryKey();