From 49dde87ce16efe3ba5f01faf65c39926a4334713 Mon Sep 17 00:00:00 2001 From: Integer Limit <103940576+IntegerLimit@users.noreply.github.com> Date: Sat, 4 Jan 2025 16:54:20 +1100 Subject: [PATCH] Fix Localization Issues on Dedicated Servers --- .../nomilabs/mixin/topaddons/AddonForgeMixin.java | 8 ++++---- .../mixin/topaddons/ElementTankGaugeMixin.java | 10 ++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/nomiceu/nomilabs/mixin/topaddons/AddonForgeMixin.java b/src/main/java/com/nomiceu/nomilabs/mixin/topaddons/AddonForgeMixin.java index afef1c5..827c5f1 100644 --- a/src/main/java/com/nomiceu/nomilabs/mixin/topaddons/AddonForgeMixin.java +++ b/src/main/java/com/nomiceu/nomilabs/mixin/topaddons/AddonForgeMixin.java @@ -17,7 +17,6 @@ import com.llamalad7.mixinextras.sugar.Share; import com.llamalad7.mixinextras.sugar.ref.LocalIntRef; import com.llamalad7.mixinextras.sugar.ref.LocalRef; -import com.nomiceu.nomilabs.util.LabsTranslate; import gregtech.api.metatileentity.SimpleMachineMetaTileEntity; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; @@ -56,7 +55,8 @@ private String useUnlocalizedName3(Fluid instance, FluidStack stack) { @ModifyConstant(method = "addProbeInfo", constant = @Constant(stringValue = "Tank")) private String localizedTank(String constant) { - return LabsTranslate.translate("topaddons.fluid_display.tank.display.default"); + String langKey = "topaddons.fluid_display.tank.display.default"; + return langKey; } @Inject(method = "addProbeInfo", @@ -94,9 +94,9 @@ private void gtTankNames(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer play if (tile instanceof IGregTechTileEntity gt && gt.getMetaTileEntity() instanceof SimpleMachineMetaTileEntity) { if (i > inputAmt.get() - 1) - tankName.set(LabsTranslate.translate("topaddons.fluid_display.tank.display.output")); + tankName.set("topaddons.fluid_display.tank.display.output"); else - tankName.set(LabsTranslate.translate("topaddons.fluid_display.tank.display.input")); + tankName.set("topaddons.fluid_display.tank.display.input"); } } } diff --git a/src/main/java/com/nomiceu/nomilabs/mixin/topaddons/ElementTankGaugeMixin.java b/src/main/java/com/nomiceu/nomilabs/mixin/topaddons/ElementTankGaugeMixin.java index 9c28e29..9b21364 100644 --- a/src/main/java/com/nomiceu/nomilabs/mixin/topaddons/ElementTankGaugeMixin.java +++ b/src/main/java/com/nomiceu/nomilabs/mixin/topaddons/ElementTankGaugeMixin.java @@ -13,6 +13,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import com.nomiceu.nomilabs.integration.top.LabsFluidNameElement; +import com.nomiceu.nomilabs.util.LabsTranslate; import gregtech.api.util.TextFormattingUtil; import io.github.drmanganese.topaddons.elements.ElementTankGauge; @@ -92,7 +93,7 @@ private void newRenderLogic(int x, int y, CallbackInfo ci) { ElementTextRender.render(labs$getCapacityInfo(), x + 3, y + 2); ElementTextRender.render(labs$getTankFluidTitle(), x + 1, y + 14); } else { - drawSmallText(x + 2, y + 2, tankName, 0xffffffff); + drawSmallText(x + 2, y + 2, labs$getTranslatedTankName(), 0xffffffff); } ci.cancel(); @@ -117,11 +118,16 @@ private void newHeightLogic(CallbackInfoReturnable cir) { private String labs$getTankFluidTitle() { if (labs$tankFluidTitle != null) return labs$tankFluidTitle; - labs$tankFluidTitle = tankName + ": " + + labs$tankFluidTitle = labs$getTranslatedTankName() + ": " + LabsFluidNameElement.translateFluid(fluidName, amount, "ElementTankGauge"); return labs$tankFluidTitle; } + @Unique + private String labs$getTranslatedTankName() { + return LabsTranslate.translate(tankName); + } + @Unique private String labs$getCapacityInfo() { if (labs$capacityInfo != null) return labs$capacityInfo;