From a579d5eefc4af9cdb6f83fdd3ab8e16ed569633b Mon Sep 17 00:00:00 2001 From: Matej Dipčár <492666@mail.muni.cz> Date: Thu, 22 Sep 2022 02:43:17 +0200 Subject: Make `GT_GuiShortTextBox` able to map values to different display strings --- .../GT_Cover_AdvancedWirelessRedstoneBase.java | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'src/main/java/gregtech') diff --git a/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedWirelessRedstoneBase.java b/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedWirelessRedstoneBase.java index 1633b2f05e..2e73ae2094 100644 --- a/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedWirelessRedstoneBase.java +++ b/src/main/java/gregtech/common/covers/redstone/GT_Cover_AdvancedWirelessRedstoneBase.java @@ -24,9 +24,11 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.Fluid; import javax.annotation.Nonnull; +import java.util.HashMap; import java.util.Map; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; public abstract class GT_Cover_AdvancedWirelessRedstoneBase extends GT_CoverBehaviorBase { @@ -323,7 +325,7 @@ public abstract class GT_Cover_AdvancedWirelessRedstoneBase translation; + private final Map inverseTranslation; - public GT_GuiShortTextBox(IGuiScreen gui, int id, int x, int y, int width, int height, int min, int max) { + public GT_GuiShortTextBox(IGuiScreen gui, int id, int x, int y, int width, int height, int min, int max, + Map translate) { super(gui, id, x, y, width, height); this.min = min; this.max = max; + this.translation = translate; + this.inverseTranslation = translate.entrySet().stream() + .collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey)); + } + + public GT_GuiShortTextBox(IGuiScreen gui, int id, int x, int y, int width, int height, int min, int max) { + this(gui, id, x, y, width, height, min, max, new HashMap<>()); } public GT_GuiShortTextBox(IGuiScreen gui, int id, int x, int y, int width, int height) { @@ -354,6 +366,17 @@ public abstract class GT_Cover_AdvancedWirelessRedstoneBase