From 9b4b4c8a98a844af850153830483b931c3005285 Mon Sep 17 00:00:00 2001 From: Forever_178 Date: Tue, 17 Dec 2024 22:35:58 +0800 Subject: [PATCH 1/4] Fix interface terminal localization Interface terminal and interface configuration terminal can display machine name as client language. --- src/main/java/appeng/helpers/DualityInterface.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/appeng/helpers/DualityInterface.java b/src/main/java/appeng/helpers/DualityInterface.java index bf2d5f80b43..1501b5addf6 100644 --- a/src/main/java/appeng/helpers/DualityInterface.java +++ b/src/main/java/appeng/helpers/DualityInterface.java @@ -1455,7 +1455,7 @@ public String getTermName() { } if (what.getItem() != Items.AIR) { - return what.getItem().getItemStackDisplayName(what); + return what.getItem().getTranslationKey(what); } final Item item = Item.getItemFromBlock(directedBlock); From a9cb43dc149f891ceb36ebda768ac9dc0994f478 Mon Sep 17 00:00:00 2001 From: Forever_178 Date: Wed, 18 Dec 2024 01:51:14 +0800 Subject: [PATCH 2/4] Fix the molecular assembler filter. Modecular assembler filter can work for any language. --- .../client/gui/implementations/GuiInterfaceTerminal.java | 5 +++-- src/main/java/appeng/client/me/ClientDCInternalInv.java | 4 ++++ src/main/java/appeng/helpers/DualityInterface.java | 8 +++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/appeng/client/gui/implementations/GuiInterfaceTerminal.java b/src/main/java/appeng/client/gui/implementations/GuiInterfaceTerminal.java index b78928e651e..db0d1d8b3a2 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiInterfaceTerminal.java +++ b/src/main/java/appeng/client/gui/implementations/GuiInterfaceTerminal.java @@ -69,7 +69,7 @@ public class GuiInterfaceTerminal extends AEBaseGui { private static final int OFFSET_X = 21; private static final int MAGIC_HEIGHT_NUMBER = 52 + 99; - private static final String MOLECULAR_ASSEMBLER = "molecular assembler"; + private static final String MOLECULAR_ASSEMBLER = "tile.appliedenergistics2.molecular_assembler"; private final boolean jeiEnabled; private final int jeiButtonPadding; @@ -536,7 +536,8 @@ private void refreshList() { continue; } // Exit if molecular assembler filter is on and this is not a molecular assembler - if (onlyMolecularAssemblers && !entry.getName().toLowerCase().contains(MOLECULAR_ASSEMBLER)) { + // Forge documantation said unlocalized name shouldn't be use for logic, so we might need a better way...... + if (onlyMolecularAssemblers && !entry.getUnlocalizedName().equals(MOLECULAR_ASSEMBLER)) { cachedSearch.remove(entry); continue; } diff --git a/src/main/java/appeng/client/me/ClientDCInternalInv.java b/src/main/java/appeng/client/me/ClientDCInternalInv.java index d3bac675f7a..d221e008ba0 100644 --- a/src/main/java/appeng/client/me/ClientDCInternalInv.java +++ b/src/main/java/appeng/client/me/ClientDCInternalInv.java @@ -55,6 +55,10 @@ public String getName() { return s; } + public String getUnlocalizedName() { + return this.unlocalizedName; + } + @Override public int compareTo(@Nonnull final ClientDCInternalInv o) { return Long.compare(this.sortBy, o.sortBy); diff --git a/src/main/java/appeng/helpers/DualityInterface.java b/src/main/java/appeng/helpers/DualityInterface.java index 1501b5addf6..2afadf01cb8 100644 --- a/src/main/java/appeng/helpers/DualityInterface.java +++ b/src/main/java/appeng/helpers/DualityInterface.java @@ -1455,7 +1455,13 @@ public String getTermName() { } if (what.getItem() != Items.AIR) { - return what.getItem().getTranslationKey(what); + /* If use getTranslationKey(), it will return incomplete translationKey sometimes. + * Such as small item output of a formed machine in mod Modular Machinery Community Edition. + * getTranslationKey() returns tile.modularmachinery.blockinputbus + * getUnlocalizedNameInefficiently() return tile.modularmachinery.blockinputbus.small + * I don't know why they return different result. + */ + return what.getItem().getUnlocalizedNameInefficiently(what); } final Item item = Item.getItemFromBlock(directedBlock); From f8c1ccbc8f48fcb912437830f0421fa76db013c1 Mon Sep 17 00:00:00 2001 From: Forever_178 Date: Wed, 18 Dec 2024 17:59:23 +0800 Subject: [PATCH 3/4] This fix is invalid to Thermal Expansion Added the reason why it is invalid to Thermal Expansion --- .../java/appeng/helpers/DualityInterface.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/appeng/helpers/DualityInterface.java b/src/main/java/appeng/helpers/DualityInterface.java index 2afadf01cb8..ab851cff65e 100644 --- a/src/main/java/appeng/helpers/DualityInterface.java +++ b/src/main/java/appeng/helpers/DualityInterface.java @@ -1455,11 +1455,20 @@ public String getTermName() { } if (what.getItem() != Items.AIR) { - /* If use getTranslationKey(), it will return incomplete translationKey sometimes. - * Such as small item output of a formed machine in mod Modular Machinery Community Edition. - * getTranslationKey() returns tile.modularmachinery.blockinputbus - * getUnlocalizedNameInefficiently() return tile.modularmachinery.blockinputbus.small - * I don't know why they return different result. + /* FIX ME: + * getTranslationKey() and getUnlocalizedNameInefficiently() have different return values in some mod + * + * For small item output of a formed machine in mod Modular Machinery Community Edition. + * getTranslationKey() returns "tile.modularmachinery.blockinputbus" + * getUnlocalizedNameInefficiently() return "tile.modularmachinery.blockinputbus.small" + * Because modular machinery community edition overides getUnlocalizedNameInefficiently() + * + * For the Thermal Expansion + * getTranslationKey() returns complete key ending with ".name". + * getUnlocalizedNameInefficiently() returns localized name + * Because CoFH Core overrides method getTranslationKey() + * + * So is code is invalid to Thermal Expansion. */ return what.getItem().getUnlocalizedNameInefficiently(what); } From 27e48e52ef542d0fc808cbfb22fe00af0afdf7d9 Mon Sep 17 00:00:00 2001 From: Forever_178 Date: Fri, 20 Dec 2024 14:22:09 +0800 Subject: [PATCH 4/4] This fix is not completely effective for mmce. Wait MMCE overrides method getTranslationKey --- src/main/java/appeng/helpers/DualityInterface.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/appeng/helpers/DualityInterface.java b/src/main/java/appeng/helpers/DualityInterface.java index ab851cff65e..d7c6d14d67e 100644 --- a/src/main/java/appeng/helpers/DualityInterface.java +++ b/src/main/java/appeng/helpers/DualityInterface.java @@ -1455,8 +1455,7 @@ public String getTermName() { } if (what.getItem() != Items.AIR) { - /* FIX ME: - * getTranslationKey() and getUnlocalizedNameInefficiently() have different return values in some mod + /* getTranslationKey() and getUnlocalizedNameInefficiently() have different return values in some mod * * For small item output of a formed machine in mod Modular Machinery Community Edition. * getTranslationKey() returns "tile.modularmachinery.blockinputbus" @@ -1468,9 +1467,9 @@ public String getTermName() { * getUnlocalizedNameInefficiently() returns localized name * Because CoFH Core overrides method getTranslationKey() * - * So is code is invalid to Thermal Expansion. + * Waiting MMCE overrides getTranslationKey */ - return what.getItem().getUnlocalizedNameInefficiently(what); + return what.getItem().getTranslationKey(what); } final Item item = Item.getItemFromBlock(directedBlock);