I18n for machines implementation

This commit is contained in:
Bufka2011 2025-08-23 17:09:19 -06:00
parent fb4bca3544
commit fa6b4faeee
6 changed files with 123 additions and 76 deletions

View File

@ -8,6 +8,7 @@ import com.hbm.inventory.recipes.loader.GenericRecipe;
import com.hbm.items.machine.ItemBlueprints;
import com.hbm.lib.RefStrings;
import com.hbm.tileentity.machine.TileEntityMachineAssemblyMachine;
import com.hbm.util.i18n.I18nUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.OpenGlHelper;
@ -44,7 +45,7 @@ public class GUIMachineAssemblyMachine extends GuiInfoContainer {
GenericRecipe recipe = (GenericRecipe) AssemblyMachineRecipes.INSTANCE.recipeNameMap.get(this.assembler.assemblerModule.recipe);
this.func_146283_a(recipe.print(), mouseX, mouseY);
} else {
this.drawCreativeTabHoveringText(EnumChatFormatting.YELLOW + "Click to set recipe", mouseX, mouseY);
this.drawCreativeTabHoveringText(EnumChatFormatting.YELLOW + I18nUtil.resolveKey("gui.recipe.setRecipe"), mouseX, mouseY);
}
}
}

View File

@ -8,6 +8,7 @@ import com.hbm.inventory.recipes.loader.GenericRecipe;
import com.hbm.items.machine.ItemBlueprints;
import com.hbm.lib.RefStrings;
import com.hbm.tileentity.machine.TileEntityMachineChemicalPlant;
import com.hbm.util.i18n.I18nUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.OpenGlHelper;
@ -46,7 +47,7 @@ public class GUIMachineChemicalPlant extends GuiInfoContainer {
GenericRecipe recipe = (GenericRecipe) ChemicalPlantRecipes.INSTANCE.recipeNameMap.get(this.chemplant.chemplantModule.recipe);
this.func_146283_a(recipe.print(), mouseX, mouseY);
} else {
this.drawCreativeTabHoveringText(EnumChatFormatting.YELLOW + "Click to set recipe", mouseX, mouseY);
this.drawCreativeTabHoveringText(EnumChatFormatting.YELLOW + I18nUtil.resolveKey("gui.recipe.setRecipe"), mouseX, mouseY);
}
}
}
@ -60,10 +61,10 @@ public class GUIMachineChemicalPlant extends GuiInfoContainer {
@Override
protected void drawGuiContainerForegroundLayer(int i, int j) {
String name = this.chemplant.hasCustomInventoryName() ? this.chemplant.getInventoryName() : I18n.format(this.chemplant.getInventoryName());
String name = this.chemplant.hasCustomInventoryName() ? this.chemplant.getInventoryName() : I18nUtil.resolveKey(this.chemplant.getInventoryName());
this.fontRendererObj.drawString(name, 70 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(I18nUtil.resolveKey("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
}
@Override

View File

@ -8,6 +8,7 @@ import com.hbm.inventory.recipes.loader.GenericRecipe;
import com.hbm.items.machine.ItemBlueprints;
import com.hbm.lib.RefStrings;
import com.hbm.tileentity.machine.TileEntityMachinePUREX;
import com.hbm.util.i18n.I18nUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.OpenGlHelper;
@ -46,7 +47,7 @@ public class GUIMachinePUREX extends GuiInfoContainer {
GenericRecipe recipe = (GenericRecipe) PUREXRecipes.INSTANCE.recipeNameMap.get(this.purex.purexModule.recipe);
this.func_146283_a(recipe.print(), mouseX, mouseY);
} else {
this.drawCreativeTabHoveringText(EnumChatFormatting.YELLOW + "Click to set recipe", mouseX, mouseY);
this.drawCreativeTabHoveringText(EnumChatFormatting.YELLOW + I18nUtil.resolveKey("gui.recipe.setRecipe"), mouseX, mouseY);
}
}
}

View File

@ -115,24 +115,53 @@ public class GenericRecipe {
public List<String> print() {
List<String> list = new ArrayList();
list.add(EnumChatFormatting.YELLOW + this.getLocalizedName());
// autoswitch group (two lines: label + "Enabled for")
if(this.autoSwitchGroup != null) {
String[] lines = I18nUtil.resolveKeyArray("autoswitch", I18nUtil.resolveKey(this.autoSwitchGroup));
for(String line : lines) list.add(EnumChatFormatting.GOLD + line);
String groupNameLocalized = I18nUtil.resolveKey(this.autoSwitchGroup);
list.add(EnumChatFormatting.GOLD + I18nUtil.resolveKey("gui.recipe.autoswitch") + ": " + groupNameLocalized);
list.add(EnumChatFormatting.GOLD + I18nUtil.resolveKey("gui.recipe.enabledFor") + " " + groupNameLocalized);
}
if(duration > 0) list.add(EnumChatFormatting.RED + "Duration: " + this.duration / 20D + "s");
if(power > 0) list.add(EnumChatFormatting.RED + "Consumption: " + BobMathUtil.getShortNumber(power) + "HE/t");
list.add(EnumChatFormatting.BOLD + "Input:");
// duration (seconds)
if(duration > 0) {
double seconds = this.duration / 20D;
list.add(EnumChatFormatting.RED + I18nUtil.resolveKey("gui.recipe.duration") + ": " + seconds + "s");
}
// power / consumption
if(power > 0) {
list.add(EnumChatFormatting.RED + I18nUtil.resolveKey("gui.recipe.consumption") + ": " + BobMathUtil.getShortNumber(power) + "HE/t");
}
// input label + items
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("gui.recipe.input") + ":");
if(inputItem != null) for(AStack stack : inputItem) {
ItemStack display = stack.extractForCyclingDisplay(20);
list.add(" " + EnumChatFormatting.GRAY + display.stackSize + "x " + display.getDisplayName());
}
if(inputFluid != null) for(FluidStack fluid : inputFluid) list.add(" " + EnumChatFormatting.BLUE + fluid.fill + "mB " + fluid.type.getLocalizedName() + (fluid.pressure == 0 ? "" : " at " + EnumChatFormatting.RED + fluid.pressure + " PU"));
list.add(EnumChatFormatting.BOLD + "Output:");
if(outputItem != null) for(IOutput output : outputItem) for(String line : output.getLabel()) list.add(" " + line);
if(outputFluid != null) for(FluidStack fluid : outputFluid) list.add(" " + EnumChatFormatting.BLUE + fluid.fill + "mB " + fluid.type.getLocalizedName() + (fluid.pressure == 0 ? "" : " at " + EnumChatFormatting.RED + fluid.pressure + " PU"));
if(inputFluid != null) for(FluidStack fluid : inputFluid) {
String mB = I18nUtil.resolveKey("gui.recipe.mB");
String pressurePart = fluid.pressure == 0 ? "" :
" " + I18nUtil.resolveKey("gui.recipe.atPressure") + " " + EnumChatFormatting.RED + fluid.pressure + " PU";
list.add(" " + EnumChatFormatting.BLUE + fluid.fill + mB + " " + fluid.type.getLocalizedName() + pressurePart);
}
// output label + items
list.add(EnumChatFormatting.BOLD + I18nUtil.resolveKey("gui.recipe.output") + ":");
if(outputItem != null) for(IOutput output : outputItem)
for(String line : output.getLabel()) list.add(" " + line);
if(outputFluid != null) for(FluidStack fluid : outputFluid) {
String mB = I18nUtil.resolveKey("gui.recipe.mB");
String pressurePart = fluid.pressure == 0 ? "" :
" " + I18nUtil.resolveKey("gui.recipe.atPressure") + " " + EnumChatFormatting.RED + fluid.pressure + " PU";
list.add(" " + EnumChatFormatting.BLUE + fluid.fill + mB + " " + fluid.type.getLocalizedName() + pressurePart);
}
return list;
}
/** Default impl only matches localized name substring, can be extended to include ingredients as well */
public boolean matchesSearch(String substring) {
return getLocalizedName().toLowerCase(Locale.US).contains(substring.toLowerCase(Locale.US));

View File

@ -6270,4 +6270,15 @@ desc.gui.upgrade.overdrive= * §7Overdrive§r: Stacks to level 3
desc.gui.upgrade.power= * §1Power-Saving§r: Stacks to level 3
desc.gui.upgrade.speed= * §4Speed§r: Stacks to level 3
# Shared recipe labels
gui.recipe.duration=Duration
gui.recipe.consumption=Consumption
gui.recipe.input=Input
gui.recipe.output=Output
gui.recipe.mB=mB
gui.recipe.atPressure=at
gui.recipe.autoswitch=Auto-switch group
gui.recipe.enabledFor=Enabled for
gui.recipe.setRecipe=Click to set recipe
tile.oc_cable_paintable.name=Paintable Network Cable

View File

@ -6614,11 +6614,15 @@ desc.util.warhead=Боеголовка
desc.util.chip_inaccuracy=Неточность чипа
desc.util.fin_inaccuracy=Неточность стабилизатора
gui.chemical.duration=Длительность: %s
gui.chemical.consumption=Потребление: %s
gui.chemical.input=Вход:
gui.chemical.output=Выход:
gui.chemical.click_to_set_recipe=Нажмите, чтобы выбрать рецепт
# Shared recipe labels
gui.recipe.duration=Длительность
gui.recipe.consumption=Потребление
gui.recipe.input=Вход
gui.recipe.output=Выход
gui.recipe.mB=mB
gui.recipe.atPressure=при давлении в
gui.recipe.autoswitch=Группа автоматического переключения
gui.recipe.enabledFor=Включено для
gui.recipe.setRecipe=Нажмите, чтобы выбрать рецепт
// Last updated 23.08.2025 by Bufka2011, MrKimkimora and TactiCOOLHimZa //