Skip to content

Commit

Permalink
Add translations for item tags (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
Swedz authored Sep 19, 2024
1 parent 80e3b94 commit 81d2fbc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@
"rei_categories.extended_industrialization.steel_bending_machine": "Steel Bending Machine",
"rei_categories.extended_industrialization.steel_canning_machine": "Canning Machine",
"rei_categories.extended_industrialization.steel_composter": "Steel Composter",
"tag.item.extended_industrialization.farmer_plantable": "Farmer Plantable",
"tag.item.extended_industrialization.farmer_voidable": "Farmer Voidable",
"tag.item.extended_industrialization.photovoltaic_cell": "Photovoltaic Cells",
"tag.item.extended_industrialization.rainbow_dyeable": "Rainbow Dyeable",
"text.extended_industrialization.activated": "Activated",
"text.extended_industrialization.brewery_brews_multiple": "Brews %s potions at a time.",
"text.extended_industrialization.brewery_requires_blazing_essence": "Requires %s to brew potions.",
Expand Down
25 changes: 19 additions & 6 deletions src/main/java/net/swedz/extended_industrialization/EITags.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
package net.swedz.extended_industrialization;

import com.google.common.collect.Maps;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;

import java.util.Collections;
import java.util.Map;

public final class EITags
{
private static final Map<TagKey<Item>, String> TRANSLATIONS = Maps.newHashMap();

public static Map<TagKey<Item>, String> translations()
{
return Collections.unmodifiableMap(TRANSLATIONS);
}

public static final class Items
{
public static final TagKey<Item> FARMER_PLANTABLE = item("farmer_plantable");
public static final TagKey<Item> FARMER_VOIDABLE = item("farmer_voidable");
public static final TagKey<Item> PHOTOVOLTAIC_CELL = item("photovoltaic_cell");
public static final TagKey<Item> RAINBOW_DYEABLE = item("rainbow_dyeable");
public static final TagKey<Item> FARMER_PLANTABLE = item("farmer_plantable", "Farmer Plantable");
public static final TagKey<Item> FARMER_VOIDABLE = item("farmer_voidable", "Farmer Voidable");
public static final TagKey<Item> PHOTOVOLTAIC_CELL = item("photovoltaic_cell", "Photovoltaic Cells");
public static final TagKey<Item> RAINBOW_DYEABLE = item("rainbow_dyeable", "Rainbow Dyeable");
}

public static final class Blocks
Expand All @@ -23,9 +34,11 @@ public static final class Blocks
public static final TagKey<Block> MACHINE_CHAINER_RELAY = block("machine_chainer/relay");
}

public static TagKey<Item> item(String path)
public static TagKey<Item> item(String path, String englishName)
{
return TagKey.create(BuiltInRegistries.ITEM.key(), EI.id(path));
TagKey<Item> tag = TagKey.create(BuiltInRegistries.ITEM.key(), EI.id(path));
TRANSLATIONS.put(tag, englishName);
return tag;
}

public static TagKey<Item> itemCommon(String path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.swedz.extended_industrialization.EIFluids;
import net.swedz.extended_industrialization.EIItems;
import net.swedz.extended_industrialization.EIKeybinds;
import net.swedz.extended_industrialization.EITags;
import net.swedz.extended_industrialization.EIText;
import net.swedz.tesseract.neoforge.datagen.mi.MIDatagenHooks;
import net.swedz.tesseract.neoforge.registry.holder.FluidHolder;
Expand Down Expand Up @@ -42,6 +43,8 @@ protected void addTranslations()
this.add(keybind.descriptionId(), keybind.englishName());
}

EITags.translations().forEach(this::add);

MIDatagenHooks.Client.withLanguageHook(this, EI.ID);

this.add("itemGroup.%s.%s".formatted(EI.ID, EI.ID), EI.NAME);
Expand Down

0 comments on commit 81d2fbc

Please sign in to comment.