mirror of
https://github.com/FabricMC/fabric.git
synced 2025-04-11 22:45:38 -04:00
Fix ItemGroup language generation. (#2785)
This commit is contained in:
parent
23a79c8a40
commit
33a4e2d71e
2 changed files with 11 additions and 2 deletions
fabric-data-generation-api-v1/src
main/java/net/fabricmc/fabric/api/datagen/v1/provider
testmod/java/net/fabricmc/fabric/test/datagen
|
@ -40,6 +40,8 @@ import net.minecraft.entity.effect.StatusEffect;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.stat.StatType;
|
||||
import net.minecraft.text.TextContent;
|
||||
import net.minecraft.text.TranslatableTextContent;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
|
||||
|
@ -147,7 +149,14 @@ public abstract class FabricLanguageProvider implements DataProvider {
|
|||
* @param value The value of the entry.
|
||||
*/
|
||||
default void add(ItemGroup group, String value) {
|
||||
add(group.getDisplayName().toString(), value);
|
||||
final TextContent content = group.getDisplayName().getContent();
|
||||
|
||||
if (content instanceof TranslatableTextContent translatableTextContent) {
|
||||
add(translatableTextContent.getKey(), value);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new UnsupportedOperationException("Cannot add language entry for ItemGroup (%s) as the display name is not translatable.".formatted(group.getDisplayName().getString()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,7 +42,7 @@ public class DataGeneratorTestContent implements ModInitializer {
|
|||
|
||||
public static final ItemGroup SIMPLE_ITEM_GROUP = FabricItemGroup.builder(new Identifier(MOD_ID, "simple"))
|
||||
.icon(() -> new ItemStack(Items.DIAMOND_PICKAXE))
|
||||
.displayName(Text.literal("Data gen test"))
|
||||
.displayName(Text.translatable("fabric-data-gen-api-v1-testmod.simple_item_group"))
|
||||
.build();
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue