diff options
author | iouter <62897714+iouter@users.noreply.github.com> | 2022-10-13 00:54:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-12 18:54:21 +0200 |
commit | 0fab6334c54843e93398c495e0d00d72ca3aa67b (patch) | |
tree | b619b40519eeff00b2db9dc97acd5aeaa9a45b51 /src/main/java/gtPlusPlus/core/item | |
parent | d42ad8f81bc79e87184a60c449a7a209c3a3681f (diff) | |
download | GT5-Unofficial-0fab6334c54843e93398c495e0d00d72ca3aa67b.tar.gz GT5-Unofficial-0fab6334c54843e93398c495e0d00d72ca3aa67b.tar.bz2 GT5-Unofficial-0fab6334c54843e93398c495e0d00d72ca3aa67b.zip |
fix material localization (#395)
* fix material localization
* spotlessApply
Diffstat (limited to 'src/main/java/gtPlusPlus/core/item')
-rw-r--r-- | src/main/java/gtPlusPlus/core/item/base/BaseItemComponent.java | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/src/main/java/gtPlusPlus/core/item/base/BaseItemComponent.java b/src/main/java/gtPlusPlus/core/item/base/BaseItemComponent.java index 60685786f3..36f53640aa 100644 --- a/src/main/java/gtPlusPlus/core/item/base/BaseItemComponent.java +++ b/src/main/java/gtPlusPlus/core/item/base/BaseItemComponent.java @@ -41,6 +41,7 @@ public class BaseItemComponent extends Item { public final Material componentMaterial; public final String materialName; public final String unlocalName; + public final String translatedMaterialName; public final ComponentTypes componentType; public final int componentColour; public Object extraData; @@ -52,6 +53,7 @@ public class BaseItemComponent extends Item { this.componentMaterial = material; this.unlocalName = "item" + componentType.COMPONENT_NAME + material.getUnlocalizedName(); this.materialName = material.getLocalizedName(); + this.translatedMaterialName = material.getTranslatedName(); this.componentType = componentType; this.setCreativeTab(AddToCreativeTab.tabMisc); this.setUnlocalizedName(this.unlocalName); @@ -76,6 +78,18 @@ public class BaseItemComponent extends Item { } } registerComponent(); + + String aFormattedLangName = componentType.getName(); + if (!aFormattedLangName.startsWith(" ")) { + if (aFormattedLangName.contains("@")) { + String[] aSplit = aFormattedLangName.split("@"); + aFormattedLangName = aSplit[0] + " %material " + aSplit[1]; + } + } + if (aFormattedLangName.equals(componentType.getName())) { + aFormattedLangName = "%material" + aFormattedLangName; + } + GT_LanguageManager.addStringLocalization("gtplusplus.item." + unlocalName + ".name", aFormattedLangName); } // For Cell Generation @@ -93,6 +107,8 @@ public class BaseItemComponent extends Item { this.componentMaterial = aTempMaterial; this.unlocalName = "itemCell" + aFormattedNameForFluids; this.materialName = localName; + this.translatedMaterialName = + GT_LanguageManager.addStringLocalization("gtplusplus.fluid." + this.unlocalName, this.materialName); this.componentType = ComponentTypes.CELL; this.setCreativeTab(AddToCreativeTab.tabMisc); this.setUnlocalizedName(aFormattedNameForFluids); @@ -106,6 +122,18 @@ public class BaseItemComponent extends Item { ComponentTypes.CELL.getOreDictName() + Utils.sanitizeStringKeepBrackets(localName), ItemUtils.getSimpleStack(this)); registerComponent(); + + String aFormattedLangName = componentType.getName(); + if (!aFormattedLangName.startsWith(" ")) { + if (aFormattedLangName.contains("@")) { + String[] aSplit = aFormattedLangName.split("@"); + aFormattedLangName = aSplit[0] + " %material " + aSplit[1]; + } + } + if (aFormattedLangName.equals(componentType.getName())) { + aFormattedLangName = "%material" + aFormattedLangName; + } + GT_LanguageManager.addStringLocalization("gtplusplus.item." + unlocalName + ".name", aFormattedLangName); } public boolean registerComponent() { @@ -181,30 +209,10 @@ public class BaseItemComponent extends Item { @Override public String getItemStackDisplayName(ItemStack stack) { - if (componentMaterial == null) { - String aFormattedLangName = componentType.getName(); - if (!aFormattedLangName.startsWith(" ")) { - if (aFormattedLangName.contains("@")) { - String[] aSplit = aFormattedLangName.split("@"); - aFormattedLangName = aSplit[0] + " " + getMaterialName() + " " + aSplit[1]; - } - } - if (aFormattedLangName.equals(componentType.getName())) { - aFormattedLangName = getMaterialName() + aFormattedLangName; - } - return GT_LanguageManager.addStringLocalization(unlocalName, aFormattedLangName); - } - String aFormattedLangName = componentType.getName(); - if (!aFormattedLangName.startsWith(" ")) { - if (aFormattedLangName.contains("@")) { - String[] aSplit = aFormattedLangName.split("@"); - aFormattedLangName = aSplit[0] + " " + componentMaterial.getLocalizedName() + " " + aSplit[1]; - } - } - if (aFormattedLangName.equals(componentType.getName())) { - aFormattedLangName = componentMaterial.getLocalizedName() + aFormattedLangName; - } - return GT_LanguageManager.addStringLocalization(unlocalName, aFormattedLangName); + return GT_LanguageManager.getTranslation("gtplusplus.item." + unlocalName + ".name") + .replace("%s", "%temp") + .replace("%material", translatedMaterialName) + .replace("%temp", "%s"); } @SuppressWarnings({"unchecked", "rawtypes"}) |