From 9414fc9625f2a9a854f59d19bdcc2eaa10af3048 Mon Sep 17 00:00:00 2001 From: Yang Xizhi <60341015+GlodBlock@users.noreply.github.com> Date: Tue, 14 Dec 2021 06:32:11 +0800 Subject: add unlocalizedname fluid map (#796) * add unlocalizedname fluid map * change the lock name into fluid name --- src/main/java/gregtech/api/util/GT_Utility.java | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/main/java/gregtech/api/util') diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 07e5fcec73..742ae656cf 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -152,6 +152,7 @@ public class GT_Utility { private static final Map sFilledContainerToData = new /*Concurrent*/HashMap<>(); private static final Map> sEmptyContainerToFluidToData = new /*Concurrent*/HashMap<>(); private static final Map> sFluidToContainers = new HashMap<>(); + private static final Map sFluidUnlocalizedNameToFluid = new HashMap<>(); /** Must use {@code Supplier} here because the ore prefixes have not yet been registered at class load time. */ private static final Map> sOreToCobble = new HashMap<>(); public static volatile int VERSION = 509; @@ -1015,6 +1016,7 @@ public class GT_Utility { sFilledContainerToData.clear(); sEmptyContainerToFluidToData.clear(); sFluidToContainers.clear(); + sFluidUnlocalizedNameToFluid.clear(); for (FluidContainerData tData : sFluidContainerList) { sFilledContainerToData.put(new GT_ItemStack(tData.filledContainer), tData); Map tFluidToContainer = sEmptyContainerToFluidToData.get(new GT_ItemStack(tData.emptyContainer)); @@ -1031,6 +1033,13 @@ public class GT_Utility { } else tContainers.add(tData.filledContainer); } + for (Fluid tFluid : FluidRegistry.getRegisteredFluids().values()) { + sFluidUnlocalizedNameToFluid.put(tFluid.getUnlocalizedName(), tFluid); + } + } + + public static Fluid getFluidFromUnlocalizedName(String aUnlocalizedName) { + return sFluidUnlocalizedNameToFluid.get(aUnlocalizedName); } public static void addFluidContainerData(FluidContainerData aData) { -- cgit