Class LanguageProvider

java.lang.Object
net.ixdarklord.coolcatcore.api.datagen.language.LanguageProvider

public abstract class LanguageProvider extends Object

A platform-agnostic, extensible language provider inspired by Fabric’s TranslationBuilder. Used to define and collect all language entries for data generation on both Forge and Fabric.

Extend this class and implement addTranslations() to register translation keys. Platform-specific wrappers (Forge or Fabric) will automatically call this method during datagen.

Example Usage:


 public class MyModLanguageProvider extends LanguageProvider {
     @Override
     public void addTranslations() {
         add("itemGroup.my_mod_tab", "My Mod Items");
         add(MyModItems.MAGIC_WAND.get(), "Magic Wand");
         add(MyModEffects.MANA_BOOST.get(), "Mana Boost");
     }
 }
 
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(@NotNull String key, @NotNull String value)
    Adds a direct translation entry.
    void
    add(Path path)
    Merges an existing language JSON file into this provider.
    void
    add(net.minecraft.client.KeyMapping keyMapping, String value)
    Adds a translation for a KeyMapping.
    void
    add(net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> entityAttribute, String value)
    Adds a translation for an Attribute.
    void
    add(net.minecraft.resources.ResourceKey<net.minecraft.world.item.CreativeModeTab> key, String value)
    Adds a translation for a CreativeModeTab.
    void
    add(net.minecraft.resources.ResourceLocation identifier, String value)
    Adds a translation for a ResourceLocation.
    void
    add(net.minecraft.stats.StatType<?> statType, String value)
    Adds a translation for a StatType.
    void
    add(net.minecraft.world.effect.MobEffect effect, String value)
    Adds a translation for a MobEffect.
    void
    add(net.minecraft.world.entity.ai.attributes.Attribute entityAttribute, String value)
    Adds a translation for an Attribute.
    void
    add(net.minecraft.world.entity.EntityType<?> entityType, String value)
    Adds a translation for an EntityType.
    void
    add(net.minecraft.world.item.alchemy.Potion potion, String value)
    Adds translation entries for a Potion.
    void
    add(net.minecraft.world.item.enchantment.Enchantment enchantment, String value)
    Adds a translation for an Enchantment.
    void
    add(net.minecraft.world.item.Item item, String value)
    Adds a translation for an Item.
    void
    addCurios(String key, String value)
    Adds a Curios slot translation.
    void
    addEnchantment(net.minecraft.resources.ResourceKey<net.minecraft.world.item.enchantment.Enchantment> enchantment, String value)
    Adds a translation for an Enchantment.
    void
    addPotion(net.minecraft.world.item.alchemy.Potion potion, String baseName, @Nullable String type)
    Adds translation entries for a Potion with a specific type suffix.
    abstract void
     
    void
    addTrinkets(String key, String value)
    Adds a Trinkets slot translation.
    Returns all collected translations as an unmodifiable map.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LanguageProvider

      public LanguageProvider()
  • Method Details

    • addTranslations

      public abstract void addTranslations()
    • add

      public void add(@NotNull @NotNull String key, @NotNull @NotNull String value)
      Adds a direct translation entry.
    • add

      public void add(net.minecraft.world.item.Item item, String value)
      Adds a translation for an Item.
    • add

      public void add(net.minecraft.world.effect.MobEffect effect, String value)
      Adds a translation for a MobEffect.
    • add

      public void add(net.minecraft.client.KeyMapping keyMapping, String value)
      Adds a translation for a KeyMapping.
    • addEnchantment

      public void addEnchantment(net.minecraft.resources.ResourceKey<net.minecraft.world.item.enchantment.Enchantment> enchantment, String value)
      Adds a translation for an Enchantment.
    • add

      public void add(net.minecraft.world.item.enchantment.Enchantment enchantment, String value)
      Adds a translation for an Enchantment.
    • add

      public void add(net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> entityAttribute, String value)
      Adds a translation for an Attribute.
    • add

      public void add(net.minecraft.world.entity.ai.attributes.Attribute entityAttribute, String value)
      Adds a translation for an Attribute.
    • add

      public void add(net.minecraft.world.entity.EntityType<?> entityType, String value)
      Adds a translation for an EntityType.
    • add

      public void add(net.minecraft.stats.StatType<?> statType, String value)
      Adds a translation for a StatType.
    • add

      public void add(net.minecraft.resources.ResourceLocation identifier, String value)
      Adds a translation for a ResourceLocation.
    • add

      public void add(net.minecraft.resources.ResourceKey<net.minecraft.world.item.CreativeModeTab> key, String value)
      Adds a translation for a CreativeModeTab.
    • add

      public void add(net.minecraft.world.item.alchemy.Potion potion, String value)
      Adds translation entries for a Potion.
    • addPotion

      public void addPotion(net.minecraft.world.item.alchemy.Potion potion, String baseName, @Nullable @Nullable String type)
      Adds translation entries for a Potion with a specific type suffix.
    • addCurios

      public void addCurios(String key, String value)
      Adds a Curios slot translation.
    • addTrinkets

      public void addTrinkets(String key, String value)
      Adds a Trinkets slot translation.
    • add

      public void add(Path path) throws IOException
      Merges an existing language JSON file into this provider.
      Parameters:
      path - The path to the JSON language file.
      Throws:
      IOException - If the file cannot be read.
    • getTranslations

      public Map<String,String> getTranslations()
      Returns all collected translations as an unmodifiable map.