From fac7b5016718514ae8f854257ca7b0eca17dcfd2 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Sun, 17 Nov 2024 05:03:15 -0700 Subject: [PATCH] Adjust WorldUtil.isChunkLoaded and ChunkCache for compatibility with Moonrise chunk system (#10422) Adjusts chunk loaded check and chunk cache for compatibility with the Moonrise chunk system. The new calls have equivalent functionality and will work with the Vanilla chunk system and Moonrise's. I tested founding a colony in a fresh world as well as founding a second colony (abandoning the first one) with and without Moonrise. --- src/main/java/com/minecolonies/api/util/WorldUtil.java | 3 ++- .../minecolonies/core/entity/pathfinding/world/ChunkCache.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/minecolonies/api/util/WorldUtil.java b/src/main/java/com/minecolonies/api/util/WorldUtil.java index fe6fa24c615..7f2502606b6 100644 --- a/src/main/java/com/minecolonies/api/util/WorldUtil.java +++ b/src/main/java/com/minecolonies/api/util/WorldUtil.java @@ -7,6 +7,7 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ChunkHolder; +import net.minecraft.server.level.FullChunkStatus; import net.minecraft.server.level.ServerChunkCache; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.Tuple; @@ -67,7 +68,7 @@ public static boolean isChunkLoaded(final LevelAccessor world, final int x, fina final ChunkHolder holder = ((ServerChunkCache) world.getChunkSource()).chunkMap.getVisibleChunkIfPresent(ChunkPos.asLong(x, z)); if (holder != null) { - return holder.getFullChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK).isSuccess(); + return holder.getFullStatus().isOrAfter(FullChunkStatus.FULL) && holder.getChunkIfPresent(ChunkStatus.FULL) != null; } return false; diff --git a/src/main/java/com/minecolonies/core/entity/pathfinding/world/ChunkCache.java b/src/main/java/com/minecolonies/core/entity/pathfinding/world/ChunkCache.java index bb682e4e4eb..7283622e630 100644 --- a/src/main/java/com/minecolonies/core/entity/pathfinding/world/ChunkCache.java +++ b/src/main/java/com/minecolonies/core/entity/pathfinding/world/ChunkCache.java @@ -78,7 +78,7 @@ public ChunkCache(Level worldIn, BlockPos posFromIn, BlockPos posToIn) final ChunkHolder holder = serverChunkCache.chunkMap.getVisibleChunkIfPresent(ChunkPos.asLong(k, l)); if (holder != null) { - this.chunkArray[k - this.chunkX][l - this.chunkZ] = holder.getFullChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK).orElse(null); + this.chunkArray[k - this.chunkX][l - this.chunkZ] = (LevelChunk) holder.getChunkIfPresent(ChunkStatus.FULL); } } }