From 6130c65c4889b91c39af971adb9968d2ebdc18f3 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 14 Jan 2024 15:53:21 -0600 Subject: [PATCH] Add messages to chunk loading about world optimization --- .../BatchGenerationEnvironment.java | 10 +++++-- .../mimicObject/ChunkLoader.java | 26 +++++++++++++++++-- coreSubProjects | 2 +- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java index 59cc24b62..bed2582a3 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java @@ -405,12 +405,18 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv { try { - LOAD_LOGGER.info("DistantHorizons: Loading chunk " + chunkPos + " from disk."); + LOAD_LOGGER.info("DistantHorizons: Loading chunk [" + chunkPos + "] from disk."); return ChunkLoader.read(level, chunkPos, chunkData); } catch (Exception e) { - LOAD_LOGGER.error("DistantHorizons: Couldn't load or make chunk " + chunkPos + ". Returning an empty chunk. Error: " + e.getMessage(), e); + LOAD_LOGGER.error( + "DistantHorizons: couldn't load or make chunk at ["+chunkPos+"]." + + "Please try optimizing your world to fix this issue. \n" + + "World optimization can be done from the singleplayer world selection screen.\n" + + "Error: ["+e.getMessage()+"]." + , e); + return EmptyChunk(level, chunkPos); } } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java index 7edb2d77e..97828775d 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java @@ -81,6 +81,8 @@ import net.minecraft.world.level.material.Fluid; public class ChunkLoader { + private static boolean zeroChunkPosErrorLogged = false; + #if MC_VER >= MC_1_19_2 private static final Codec> BLOCK_STATE_CODEC = PalettedContainer.codecRW(Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState()); #elif MC_VER >= MC_1_18_2 @@ -232,8 +234,28 @@ public class ChunkLoader ChunkPos actualPos = new ChunkPos(tagLevel.getInt("xPos"), tagLevel.getInt("zPos")); if (!Objects.equals(chunkPos, actualPos)) { - LOGGER.error("Chunk file at {} is in the wrong location; Ignoring. (Expected {}, got {})", chunkPos, chunkPos, actualPos); - return null; + if (actualPos.equals(ChunkPos.ZERO)) + { + if (!zeroChunkPosErrorLogged) + { + zeroChunkPosErrorLogged = true; + + // explicit chunkPos toString is necessary otherwise the JDK 17 compiler breaks + LOGGER.warn("Chunk file at ["+chunkPos.toString()+"] doesn't have a chunk pos. \n" + + "This might happen if the world was created using an external program. \n" + + "DH will attempt to parse the chunk anyway and won't log this message again.\n" + + "If issues arise please try optimizing your world to fix this issue. \n" + + "World optimization can be done from the singleplayer world selection screen."+ + ""); + } + } + else + { + // everything is on one line to fix a JDK 17 compiler issue + // if the issue is ever resolved, feel free to make this multi-line for readability + LOGGER.error("Chunk file at ["+chunkPos.toString()+"] is in the wrong location. \nPlease try optimizing your world to fix this issue. \nWorld optimization can be done from the singleplayer world selection screen. \n(Expected pos: ["+chunkPos.toString()+"], actual ["+actualPos.toString()+"])"); + return null; + } } ChunkStatus.ChunkType chunkType = readChunkType(tagLevel); diff --git a/coreSubProjects b/coreSubProjects index 45c47533c..163c0bf1f 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 45c47533c27c41476f721abb989fae17e8268446 +Subproject commit 163c0bf1fac5eb3f17406a6bcc0ed8ba5d5b041f