diff --git a/build.gradle b/build.gradle index 943369364..15a12e46d 100644 --- a/build.gradle +++ b/build.gradle @@ -432,6 +432,8 @@ loom { inherit testmodClient name "Auto Test Client" vmArg "-Dfabric.autoTest" + vmArg "-Dfabric-tag-conventions-v2.missingTagTranslationWarning=fail" + vmArg "-Dfabric-tag-conventions-v1.legacyTagWarning=fail" } // Create duplicate tasks for this, as jacoco slows things down a bit @@ -525,6 +527,8 @@ tasks.register('runProductionAutoTestClient', JavaExec) { jvmArgs( "-Dfabric.addMods=${remapJar.archiveFile.get().asFile.absolutePath}${File.pathSeparator}${remapTestmodJar.archiveFile.get().asFile.absolutePath}", "-Dfabric.autoTest", + "-Dfabric-tag-conventions-v2.missingTagTranslationWarning=fail", + "-Dfabric-tag-conventions-v1.legacyTagWarning=fail" ) jvmArgs(debugArgs) } diff --git a/deprecated/fabric-convention-tags-v1/src/main/java/net/fabricmc/fabric/impl/tag/convention/ConventionLogWarnings.java b/deprecated/fabric-convention-tags-v1/src/main/java/net/fabricmc/fabric/impl/tag/convention/ConventionLogWarnings.java index 0caa1ef77..e97d5f619 100644 --- a/deprecated/fabric-convention-tags-v1/src/main/java/net/fabricmc/fabric/impl/tag/convention/ConventionLogWarnings.java +++ b/deprecated/fabric-convention-tags-v1/src/main/java/net/fabricmc/fabric/impl/tag/convention/ConventionLogWarnings.java @@ -29,7 +29,6 @@ import net.minecraft.registry.DynamicRegistryManager; import net.minecraft.registry.Registry; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.tag.BlockTags; import net.minecraft.registry.tag.ItemTags; import net.minecraft.registry.tag.TagKey; import net.minecraft.util.Identifier; @@ -49,7 +48,7 @@ public class ConventionLogWarnings implements ModInitializer { private static final LogWarningMode LOG_LEGACY_WARNING_MODE = setupLogWarningModeProperty(); private static LogWarningMode setupLogWarningModeProperty() { - String property = System.getProperty("fabric-tag-conventions-v1.legacyTagWarning", LogWarningMode.DEV_SHORT.name()).toUpperCase(Locale.ROOT); + String property = System.getProperty("fabric-tag-conventions-v1.legacyTagWarning", LogWarningMode.SHORT.name()).toUpperCase(Locale.ROOT); try { return LogWarningMode.valueOf(property); @@ -61,8 +60,13 @@ public class ConventionLogWarnings implements ModInitializer { private enum LogWarningMode { SILENCED, - DEV_SHORT, - DEV_VERBOSE + SHORT, + VERBOSE, + FAIL; + + boolean isVerbose() { + return this == VERBOSE || this == FAIL; + } } /** @@ -211,25 +215,7 @@ public class ConventionLogWarnings implements ModInitializer { createMapEntry(RegistryKeys.ITEM, "stews", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.SOUPS_FOODS), createMapEntry(RegistryKeys.ITEM, "candy", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.CANDIES_FOODS), createMapEntry(RegistryKeys.ITEM, "candies", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.CANDIES_FOODS), - createMapEntry(TagKey.of(RegistryKeys.ITEM, Identifier.of("minecraft", "music_discs")), net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.MUSIC_DISCS), - - // V2 tags that are now discouraged - createMapEntry(ConventionalItemTags.COAL, ItemTags.COALS), - createMapEntry(RegistryKeys.ITEM, "tools/shears", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.SHEAR_TOOLS), - createMapEntry(RegistryKeys.ITEM, "tools/spears", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.SPEAR_TOOLS), - createMapEntry(RegistryKeys.ITEM, "tools/bows", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.BOW_TOOLS), - createMapEntry(RegistryKeys.ITEM, "tools/crossbows", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.CROSSBOW_TOOLS), - createMapEntry(RegistryKeys.ITEM, "tools/shields", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.SHIELD_TOOLS), - createMapEntry(RegistryKeys.ITEM, "tools/fishing_rods", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.FISHING_ROD_TOOLS), - createMapEntry(RegistryKeys.ITEM, "tools/brushes", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.BRUSH_TOOLS), - createMapEntry(RegistryKeys.ITEM, "tools/melee_weapons", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.MELEE_WEAPON_TOOLS), - createMapEntry(RegistryKeys.ITEM, "tools/ranged_weapons", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.RANGED_WEAPON_TOOLS), - createMapEntry(RegistryKeys.ITEM, "tools/mining_tools", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.MINING_TOOL_TOOLS), - createMapEntry(RegistryKeys.ITEM, "raw_blocks", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.STORAGE_BLOCKS), - createMapEntry(RegistryKeys.ITEM, "raw_blocks/copper", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.STORAGE_BLOCKS_RAW_COPPER), - createMapEntry(RegistryKeys.ITEM, "raw_blocks/gold", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.STORAGE_BLOCKS_RAW_GOLD), - createMapEntry(RegistryKeys.ITEM, "raw_blocks/iron", net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.STORAGE_BLOCKS_RAW_IRON), - createMapEntry(net.fabricmc.fabric.api.tag.convention.v2.ConventionalBlockTags.SHULKER_BOXES, BlockTags.SHULKER_BOXES) + createMapEntry(TagKey.of(RegistryKeys.ITEM, Identifier.of("minecraft", "music_discs")), net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags.MUSIC_DISCS) ); @Override @@ -273,9 +259,7 @@ public class ConventionLogWarnings implements ModInitializer { """); // Print out all legacy tags when desired. - boolean isConfigSetToVerbose = LOG_LEGACY_WARNING_MODE == LogWarningMode.DEV_VERBOSE; - - if (isConfigSetToVerbose) { + if (LOG_LEGACY_WARNING_MODE.isVerbose()) { stringBuilder.append("\nLegacy tags and their replacement:"); for (TagKey tagKey : legacyTags) { @@ -284,6 +268,10 @@ public class ConventionLogWarnings implements ModInitializer { } LOGGER.warn(stringBuilder.toString()); + + if (LOG_LEGACY_WARNING_MODE == LogWarningMode.FAIL) { + throw new RuntimeException("Legacy Tag validation failed"); + } }); } diff --git a/fabric-convention-tags-v2/src/datagen/java/net/fabricmc/fabric/impl/tag/convention/datagen/generators/EnglishTagLangGenerator.java b/fabric-convention-tags-v2/src/datagen/java/net/fabricmc/fabric/impl/tag/convention/datagen/generators/EnglishTagLangGenerator.java index cc437ae7d..66de224a6 100644 --- a/fabric-convention-tags-v2/src/datagen/java/net/fabricmc/fabric/impl/tag/convention/datagen/generators/EnglishTagLangGenerator.java +++ b/fabric-convention-tags-v2/src/datagen/java/net/fabricmc/fabric/impl/tag/convention/datagen/generators/EnglishTagLangGenerator.java @@ -265,6 +265,7 @@ public class EnglishTagLangGenerator extends FabricLanguageProvider { translationBuilder.add(ConventionalItemTags.PLAYER_WORKSTATIONS_CRAFTING_TABLES, "Crafting Tables"); translationBuilder.add(ConventionalItemTags.PLAYER_WORKSTATIONS_FURNACES, "Furnaces"); translationBuilder.add(ConventionalItemTags.STRINGS, "Strings"); + translationBuilder.add(ConventionalItemTags.LEATHERS, "Leathers"); translationBuilder.add(ConventionalItemTags.MUSIC_DISCS, "Music Discs"); translationBuilder.add(ConventionalItemTags.RODS, "Rods"); translationBuilder.add(ConventionalItemTags.WOODEN_RODS, "Wooden Rods"); diff --git a/fabric-convention-tags-v2/src/generated/resources/assets/fabric-convention-tags-v2/lang/en_us.json b/fabric-convention-tags-v2/src/generated/resources/assets/fabric-convention-tags-v2/lang/en_us.json index e40332974..653b24b02 100644 --- a/fabric-convention-tags-v2/src/generated/resources/assets/fabric-convention-tags-v2/lang/en_us.json +++ b/fabric-convention-tags-v2/src/generated/resources/assets/fabric-convention-tags-v2/lang/en_us.json @@ -176,6 +176,7 @@ "tag.item.c.ingots.gold": "Gold Ingots", "tag.item.c.ingots.iron": "Iron Ingots", "tag.item.c.ingots.netherite": "Netherite Ingots", + "tag.item.c.leathers": "Leathers", "tag.item.c.music_discs": "Music Discs", "tag.item.c.nuggets": "Nuggets", "tag.item.c.ores": "Ores", diff --git a/fabric-convention-tags-v2/src/main/java/net/fabricmc/fabric/impl/tag/convention/v2/TranslationConventionLogWarnings.java b/fabric-convention-tags-v2/src/main/java/net/fabricmc/fabric/impl/tag/convention/v2/TranslationConventionLogWarnings.java index b75f8a950..776c98fbe 100644 --- a/fabric-convention-tags-v2/src/main/java/net/fabricmc/fabric/impl/tag/convention/v2/TranslationConventionLogWarnings.java +++ b/fabric-convention-tags-v2/src/main/java/net/fabricmc/fabric/impl/tag/convention/v2/TranslationConventionLogWarnings.java @@ -59,7 +59,12 @@ public class TranslationConventionLogWarnings implements ModInitializer { private enum LogWarningMode { SILENCED, SHORT, - VERBOSE + VERBOSE, + FAIL; + + boolean verbose() { + return this == VERBOSE || this == FAIL; + } } public void onInitialize() { @@ -99,9 +104,7 @@ public class TranslationConventionLogWarnings implements ModInitializer { """); // Print out all untranslated tags when desired. - boolean isConfigSetToVerbose = LOG_UNTRANSLATED_WARNING_MODE == LogWarningMode.VERBOSE; - - if (isConfigSetToVerbose) { + if (LOG_UNTRANSLATED_WARNING_MODE.verbose()) { stringBuilder.append("\nUntranslated item tags:"); for (TagKey tagKey : untranslatedItemTags) { @@ -110,6 +113,10 @@ public class TranslationConventionLogWarnings implements ModInitializer { } LOGGER.warn(stringBuilder.toString()); + + if (LOG_UNTRANSLATED_WARNING_MODE == LogWarningMode.FAIL) { + throw new RuntimeException("Tag translation validation failed"); + } }); } } diff --git a/fabric-resource-conditions-api-v1/src/testmod/resources/assets/fabric-resource-conditions-api-v1-testmod/lang/en_us.json b/fabric-resource-conditions-api-v1/src/testmod/resources/assets/fabric-resource-conditions-api-v1-testmod/lang/en_us.json new file mode 100644 index 000000000..e92b05537 --- /dev/null +++ b/fabric-resource-conditions-api-v1/src/testmod/resources/assets/fabric-resource-conditions-api-v1-testmod/lang/en_us.json @@ -0,0 +1,3 @@ +{ + "tag.item.fabric-resource-conditions-api-v1-testmod.test_condition": "Test Condition" +}