|
10 | 10 | import journeymap.client.model.region.RegionCoord; |
11 | 11 | import net.minecraft.core.BlockPos; |
12 | 12 | import net.minecraft.core.Holder; |
| 13 | +import net.minecraft.core.registries.Registries; |
13 | 14 | import net.minecraft.resources.ResourceKey; |
14 | 15 | import net.minecraft.world.level.Level; |
15 | 16 | import net.minecraft.world.level.biome.Biome; |
|
18 | 19 | import net.minecraft.world.level.chunk.LevelChunk; |
19 | 20 |
|
20 | 21 | import static gjum.minecraft.mapsync.mod.MapSyncMod.logger; |
| 22 | +import static gjum.minecraft.mapsync.mod.Utils.getBiomeRegistry; |
21 | 23 | import static gjum.minecraft.mapsync.mod.Utils.mc; |
22 | 24 |
|
23 | 25 | public class JourneyMapHelperReal { |
@@ -64,6 +66,9 @@ private static boolean renderWithDiagnostics( |
64 | 66 | // keep this call in one place so failures are logged with context |
65 | 67 | final boolean rendered = JourneymapClient.getInstance().getChunkRenderController().renderChunk(rCoord, mapType, chunkMd); |
66 | 68 | return rendered; |
| 69 | + } catch (ChunkMD.ChunkMissingException e) { |
| 70 | + logger.error("Chunk missing for rendering {} at {}", mapName, chunkMd.chunkTile.chunkPos()); |
| 71 | + return false; |
67 | 72 | } catch (Throwable t) { |
68 | 73 | logger.error("Exception rendering {} at {}", mapName, chunkMd.chunkTile.chunkPos(), t); |
69 | 74 | return false; |
@@ -165,7 +170,12 @@ public int getHeight(BlockPos pos) { |
165 | 170 | @Override |
166 | 171 | public Holder<Biome> getBiomeHolder(BlockPos pos) { |
167 | 172 | 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); |
169 | 179 | } |
170 | 180 |
|
171 | 181 | @Override |
|
0 commit comments