Skip to content

Commit 91481f7

Browse files
committed
turn chunk missing error into log msg
1 parent 9b9e996 commit 91481f7

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

mapsync-mod/src/main/java/gjum/minecraft/mapsync/mod/integrations/journeymap/JourneyMapHelperReal.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import journeymap.client.model.region.RegionCoord;
1111
import net.minecraft.core.BlockPos;
1212
import net.minecraft.core.Holder;
13+
import net.minecraft.core.registries.Registries;
1314
import net.minecraft.resources.ResourceKey;
1415
import net.minecraft.world.level.Level;
1516
import net.minecraft.world.level.biome.Biome;
@@ -18,6 +19,7 @@
1819
import net.minecraft.world.level.chunk.LevelChunk;
1920

2021
import static gjum.minecraft.mapsync.mod.MapSyncMod.logger;
22+
import static gjum.minecraft.mapsync.mod.Utils.getBiomeRegistry;
2123
import static gjum.minecraft.mapsync.mod.Utils.mc;
2224

2325
public class JourneyMapHelperReal {
@@ -64,6 +66,9 @@ private static boolean renderWithDiagnostics(
6466
// keep this call in one place so failures are logged with context
6567
final boolean rendered = JourneymapClient.getInstance().getChunkRenderController().renderChunk(rCoord, mapType, chunkMd);
6668
return rendered;
69+
} catch (ChunkMD.ChunkMissingException e) {
70+
logger.error("Chunk missing for rendering {} at {}", mapName, chunkMd.chunkTile.chunkPos());
71+
return false;
6772
} catch (Throwable t) {
6873
logger.error("Exception rendering {} at {}", mapName, chunkMd.chunkTile.chunkPos(), t);
6974
return false;
@@ -165,7 +170,12 @@ public int getHeight(BlockPos pos) {
165170
@Override
166171
public Holder<Biome> getBiomeHolder(BlockPos pos) {
167172
var biome = getBiome(pos);
168-
return biome != null ? Holder.direct(biome) : null;
173+
if (biome == null || mc.level == null) return null;
174+
var biomeKey = getBiomeRegistry().getResourceKey(biome).orElse(null);
175+
if (biomeKey == null) return null;
176+
return mc.level.registryAccess()
177+
.lookupOrThrow(Registries.BIOME)
178+
.getOrThrow(biomeKey);
169179
}
170180

171181
@Override

0 commit comments

Comments
 (0)