Skip to content

Commit fec7eb6

Browse files
committed
Avoid error from mods that replace chunk system
1 parent 7c550a1 commit fec7eb6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

common/src/main/java/org/embeddedt/modernfix/ModernFix.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,19 @@ public void onServerStarted() {
6363
ClassInfoManager.clear();
6464
}
6565

66+
@SuppressWarnings("ConstantValue")
6667
public void onServerDead(MinecraftServer server) {
6768
/* Clear as much data from the integrated server as possible, in case a mod holds on to it */
6869
try {
6970
for(ServerLevel level : server.getAllLevels()) {
7071
ChunkMap chunkMap = level.getChunkSource().chunkMap;
71-
chunkMap.updatingChunkMap.clear();
72-
chunkMap.visibleChunkMap.clear();
73-
chunkMap.pendingUnloads.clear();
72+
// Null check for mods that replace chunk system
73+
if(chunkMap.updatingChunkMap != null)
74+
chunkMap.updatingChunkMap.clear();
75+
if(chunkMap.visibleChunkMap != null)
76+
chunkMap.visibleChunkMap.clear();
77+
if(chunkMap.pendingUnloads != null)
78+
chunkMap.pendingUnloads.clear();
7479
}
7580
} catch(RuntimeException e) {
7681
ModernFix.LOGGER.error("Couldn't clear chunk data", e);

0 commit comments

Comments
 (0)