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 4aaeffc5..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; @@ -81,9 +82,12 @@ public static void onChunkHolderCreate(final ServerLevel level, final ChunkHolde public static void onChunkHolderDelete(final ServerLevel level, final ChunkHolder holder) { // Update progress listener for LevelLoadingScreen - ChunkSystem.scheduleChunkTask(level, holder.getPos().x, holder.getPos().z, () -> { - level.getChunkSource().chunkMap.progressListener.onStatusChange(holder.getPos(), null); - }); + 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 6a80da9c..448d66b8 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; @@ -1359,10 +1360,13 @@ private void completeStatusConsumers(ChunkStatus status, final ChunkAccess chunk // Update progress listener for LevelLoadingScreen if (chunk != null) { - final ChunkStatus finalStatus = status; - this.scheduler.scheduleChunkTask(this.chunkX, this.chunkZ, () -> { - this.world.getChunkSource().chunkMap.progressListener.onStatusChange(this.vanillaChunkHolder.getPos(), finalStatus); - }); + 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); + }); + } } } while (chunk == null && status != (status = ((ChunkSystemChunkStatus)status).moonrise$getNextStatus())); }