Skip to content

Commit

Permalink
Adjust WorldUtil.isChunkLoaded and ChunkCache for compatibility with …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
jpenilla authored Nov 17, 2024
1 parent 271ddc2 commit fac7b50
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/main/java/com/minecolonies/api/util/WorldUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit fac7b50

Please sign in to comment.