From 6c0d32c6ca9ceae92c23e536b195fdf71d6e0907 Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Tue, 23 Jul 2024 12:33:45 +0100 Subject: [PATCH] chore: added standard methods to get dimension key translations And default translations for vanilla dims plus a couple modded ones --- .../ftb/mods/ftblibrary/util/TextComponentUtils.java | 11 +++++++++++ .../main/resources/assets/ftblibrary/lang/en_us.json | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/dev/ftb/mods/ftblibrary/util/TextComponentUtils.java b/common/src/main/java/dev/ftb/mods/ftblibrary/util/TextComponentUtils.java index c5fb858f..cb8835dc 100644 --- a/common/src/main/java/dev/ftb/mods/ftblibrary/util/TextComponentUtils.java +++ b/common/src/main/java/dev/ftb/mods/ftblibrary/util/TextComponentUtils.java @@ -3,6 +3,9 @@ import dev.architectury.injectables.annotations.ExpectPlatform; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; public class TextComponentUtils { @ExpectPlatform @@ -15,4 +18,12 @@ public static Component hotkeyTooltip(String txt) { .append(Component.literal(txt).withStyle(ChatFormatting.GRAY)) .append(Component.literal("]").withStyle(ChatFormatting.DARK_GRAY)); } + + public static Component translatedDimension(ResourceKey key) { + return translatedDimension(key.location()); + } + + public static Component translatedDimension(ResourceLocation dimId) { + return Component.translatableWithFallback(dimId.toLanguageKey("dimension"), dimId.toString()); + } } diff --git a/common/src/main/resources/assets/ftblibrary/lang/en_us.json b/common/src/main/resources/assets/ftblibrary/lang/en_us.json index dbf765af..8d3f7d76 100644 --- a/common/src/main/resources/assets/ftblibrary/lang/en_us.json +++ b/common/src/main/resources/assets/ftblibrary/lang/en_us.json @@ -93,5 +93,10 @@ "ftblibrary.panel.position.right": "Right", "ftblibrary.panel.position.bottom_left": "Bottom Left", "ftblibrary.panel.position.bottom": "Bottom", - "ftblibrary.panel.position.bottom_right": "Bottom Right" + "ftblibrary.panel.position.bottom_right": "Bottom Right", + "dimension.minecraft.overworld": "Overworld", + "dimension.minecraft.the_nether": "The Nether", + "dimension.minecraft.the_end": "The End", + "dimension.hyperbox.hyperbox": "Hyperbox", + "dimension.ae2.spatial_storage": "AE2 Spatial Storage" }