Skip to content

Commit

Permalink
null check progress listener
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Aug 24, 2024
1 parent 9296638 commit 18eed89
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()));
}
Expand Down

0 comments on commit 18eed89

Please sign in to comment.