From aa73a30ac4c5a90b744f0bbbf16614abfb78c64a Mon Sep 17 00:00:00 2001 From: James Seibel Date: Wed, 17 Jan 2024 20:57:10 -0600 Subject: [PATCH] Fix C2ME throwing errors when attempting to get region file --- .../RegionFileStorageExternalCache.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/RegionFileStorageExternalCache.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/RegionFileStorageExternalCache.java index edbc1c89f..bcdd6f5ab 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/RegionFileStorageExternalCache.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/RegionFileStorageExternalCache.java @@ -21,6 +21,8 @@ public class RegionFileStorageExternalCache implements AutoCloseable { private static final Logger LOGGER = DhLoggerBuilder.getLogger(); + /** Can be null due to the C2ME mod */ + @Nullable public final RegionFileStorage storage; public static final int MAX_CACHE_SIZE = 16; @@ -56,6 +58,19 @@ public class RegionFileStorageExternalCache implements AutoCloseable @Nullable public RegionFile getRegionFile(ChunkPos pos) throws IOException { + if (this.storage == null) + { + if (!regionCacheNullPointerWarningSent) + { + regionCacheNullPointerWarningSent = true; + LOGGER.warn("Unable to access Minecraft's chunk cache. This may be due to another mod changing said cache. DH will be unable to access any Minecraft chunk data until said mod is removed."); + } + + return null; + } + + + long posLong = ChunkPos.asLong(pos.getRegionX(), pos.getRegionZ()); RegionFile rFile = null;