diff --git a/src/main/java/ca/spottedleaf/moonrise/common/util/ChunkSystem.java b/src/main/java/ca/spottedleaf/moonrise/common/util/ChunkSystem.java index 1cae0f26..408b59fe 100644 --- a/src/main/java/ca/spottedleaf/moonrise/common/util/ChunkSystem.java +++ b/src/main/java/ca/spottedleaf/moonrise/common/util/ChunkSystem.java @@ -11,6 +11,7 @@ import net.minecraft.server.level.FullChunkStatus; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.level.progress.ChunkProgressListener; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.LevelChunk; @@ -80,7 +81,13 @@ public static void onChunkHolderCreate(final ServerLevel level, final ChunkHolde } public static void onChunkHolderDelete(final ServerLevel level, final ChunkHolder holder) { - + // Update progress listener for LevelLoadingScreen + final ChunkProgressListener progressListener = level.getChunkSource().chunkMap.progressListener; + if (progressListener != null) { + ChunkSystem.scheduleChunkTask(level, holder.getPos().x, holder.getPos().z, () -> { + progressListener.onStatusChange(holder.getPos(), null); + }); + } } public static void onChunkPreBorder(final LevelChunk chunk, final ChunkHolder holder) { diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java index b6a471b6..7a5f3be6 100644 --- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java +++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java @@ -38,6 +38,7 @@ import net.minecraft.server.level.ChunkLevel; import net.minecraft.server.level.FullChunkStatus; import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.progress.ChunkProgressListener; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.chunk.ChunkAccess; @@ -1353,6 +1354,17 @@ void addStatusConsumer(final ChunkStatus status, final Consumer con } private void completeStatusConsumers(ChunkStatus status, final ChunkAccess chunk) { + // Update progress listener for LevelLoadingScreen + if (chunk != null) { + final ChunkProgressListener progressListener = this.world.getChunkSource().chunkMap.progressListener; + if (progressListener != null) { + final ChunkStatus finalStatus = status; + this.scheduler.scheduleChunkTask(this.chunkX, this.chunkZ, () -> { + progressListener.onStatusChange(this.vanillaChunkHolder.getPos(), finalStatus); + }); + } + } + // need to tell future statuses to complete if cancelled do { this.completeStatusConsumers0(status, chunk); diff --git a/src/main/resources/moonrise.accesswidener b/src/main/resources/moonrise.accesswidener index 76c9eaed..e5f0e764 100644 --- a/src/main/resources/moonrise.accesswidener +++ b/src/main/resources/moonrise.accesswidener @@ -43,6 +43,7 @@ accessible method net/minecraft/server/level/ChunkMap setServerViewDistance (I)V accessible method net/minecraft/server/level/ChunkMap upgradeChunkTag (Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/nbt/CompoundTag; accessible field net/minecraft/server/level/ChunkMap worldGenContext Lnet/minecraft/world/level/chunk/status/WorldGenContext; accessible field net/minecraft/server/level/ChunkMap tickingGenerated Ljava/util/concurrent/atomic/AtomicInteger; +accessible field net/minecraft/server/level/ChunkMap progressListener Lnet/minecraft/server/level/progress/ChunkProgressListener; # ChunkLevel accessible field net/minecraft/server/level/ChunkLevel FULL_CHUNK_LEVEL I