From a7ac31bcf560883b5e6517a193eb2189ff48dd06 Mon Sep 17 00:00:00 2001 From: solonovamax Date: Sat, 5 Oct 2024 18:17:59 -0400 Subject: [PATCH 1/2] Use translation key from name element, with fallback to Util.createTranslationKey formatting for StatType --- .../api/datagen/v1/provider/FabricLanguageProvider.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricLanguageProvider.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricLanguageProvider.java index 30d896f57c..1d78bd2b5b 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricLanguageProvider.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricLanguageProvider.java @@ -207,7 +207,11 @@ default void add(RegistryEntry entityAttribute, String value) { * @param value The value of the entry. */ default void add(StatType statType, String value) { - add("stat_type." + Registries.STAT_TYPE.getId(statType).toString().replace(':', '.'), value); + if (statType.getName() instanceof TranslatableTextContent translatableTextContent) { + add(translatableTextContent.getKey(), value); + } else { // fallback to Util.createTranslationKey formatting (should it error instead?) + add(Util.createTranslationKey("stat_type", Registries.STAT_TYPE.getId(statType)), value); + } } /** From 9339092e913d807d7adc95dd1c2cdf0fb8203c65 Mon Sep 17 00:00:00 2001 From: solonovamax Date: Wed, 9 Oct 2024 16:47:40 -0400 Subject: [PATCH 2/2] Fix spotless issues --- .../api/datagen/v1/provider/FabricLanguageProvider.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricLanguageProvider.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricLanguageProvider.java index 1d78bd2b5b..66c1e48f92 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricLanguageProvider.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricLanguageProvider.java @@ -207,10 +207,10 @@ default void add(RegistryEntry entityAttribute, String value) { * @param value The value of the entry. */ default void add(StatType statType, String value) { - if (statType.getName() instanceof TranslatableTextContent translatableTextContent) { - add(translatableTextContent.getKey(), value); - } else { // fallback to Util.createTranslationKey formatting (should it error instead?) - add(Util.createTranslationKey("stat_type", Registries.STAT_TYPE.getId(statType)), value); + if (statType.getName() instanceof TranslatableTextContent translatableTextContent) { + add(translatableTextContent.getKey(), value); + } else { // fallback to Util.createTranslationKey formatting (should it error instead?) + add(Util.createTranslationKey("stat_type", Registries.STAT_TYPE.getId(statType)), value); } }