From b7c4ae49f38ec17da8d105fef445c69ad64abd53 Mon Sep 17 00:00:00 2001 From: WakelessSloth56 Date: Sat, 26 Nov 2022 20:52:50 +0800 Subject: [PATCH] fix(game.world): fix getDimensionName method --- .../auioc/mcmod/arnicalib/game/world/LevelUtils.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/auioc/mcmod/arnicalib/game/world/LevelUtils.java b/src/main/java/org/auioc/mcmod/arnicalib/game/world/LevelUtils.java index 28ae3590..87042b1c 100644 --- a/src/main/java/org/auioc/mcmod/arnicalib/game/world/LevelUtils.java +++ b/src/main/java/org/auioc/mcmod/arnicalib/game/world/LevelUtils.java @@ -4,6 +4,7 @@ import java.util.UUID; import java.util.function.Function; import java.util.stream.Collectors; +import javax.annotation.Nullable; import org.auioc.mcmod.arnicalib.game.chat.TextUtils; import org.auioc.mcmod.arnicalib.game.server.ServerUtils; import net.minecraft.Util; @@ -69,12 +70,18 @@ public static Component getMoonphaseName(Level level) { } public static Component getDimensionName(Level level) { - return TextUtils.translatable(Util.makeDescriptionId("dimension", level.dimension().getRegistryName())); + return TextUtils.translatable(Util.makeDescriptionId("dimension", level.dimension().location())); } public static Component getBiomeName(Level level, BlockPos pos) { + var id = getBiomeId(level, pos); + return (id != null) ? TextUtils.translatable(Util.makeDescriptionId("biome", id)) : TextUtils.empty(); + } + + @Nullable + public static ResourceLocation getBiomeId(Level level, BlockPos pos) { var b = level.getBiome(pos).unwrapKey(); - return (b.isPresent()) ? TextUtils.translatable(Util.makeDescriptionId("biome", b.get().location())) : TextUtils.empty(); + return (b.isPresent()) ? b.get().location() : null; }