aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorGlodBlock <60341015+GlodBlock@users.noreply.github.com>2021-09-26 21:02:11 +0800
committerGitHub <noreply@github.com>2021-09-26 21:02:11 +0800
commite40d83562bd80e57c567fd1f11f0b28108368e7f (patch)
treec44da2bd69d5a4f8f1559d57e81ce4ae71f1364b /src/main
parent36b96ffcafde06601e3458eb8a41781abfe6f0b1 (diff)
downloadGT5-Unofficial-e40d83562bd80e57c567fd1f11f0b28108368e7f.tar.gz
GT5-Unofficial-e40d83562bd80e57c567fd1f11f0b28108368e7f.tar.bz2
GT5-Unofficial-e40d83562bd80e57c567fd1f11f0b28108368e7f.zip
preload all FluidContainerData
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/gregtech/api/util/GT_Utility.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java
index be5f978d6e..64a60e8630 100644
--- a/src/main/java/gregtech/api/util/GT_Utility.java
+++ b/src/main/java/gregtech/api/util/GT_Utility.java
@@ -102,6 +102,7 @@ public class GT_Utility {
private static final List<FluidContainerData> sFluidContainerList = new ArrayList<>();
private static final Map<GT_ItemStack, FluidContainerData> sFilledContainerToData = new /*Concurrent*/HashMap<>();
private static final Map<GT_ItemStack, Map<Fluid, FluidContainerData>> sEmptyContainerToFluidToData = new /*Concurrent*/HashMap<>();
+ private static final Map<Fluid, List<ItemStack>> sFluidToContainers = new HashMap<>();
public static volatile int VERSION = 509;
public static boolean TE_CHECK = false, BC_CHECK = false, CHECK_ALL = true, RF_CHECK = false;
public static Map<GT_PlayedSound, Integer> sPlayedSoundMap = new /*Concurrent*/HashMap<>();
@@ -918,14 +919,22 @@ public class GT_Utility {
public static void reInit() {
sFilledContainerToData.clear();
sEmptyContainerToFluidToData.clear();
+ sFluidToContainers.clear();
for (FluidContainerData tData : sFluidContainerList) {
sFilledContainerToData.put(new GT_ItemStack(tData.filledContainer), tData);
Map<Fluid, FluidContainerData> tFluidToContainer = sEmptyContainerToFluidToData.get(new GT_ItemStack(tData.emptyContainer));
+ List<ItemStack> tContainers = sFluidToContainers.get(tData.fluid.getFluid());
if (tFluidToContainer == null) {
sEmptyContainerToFluidToData.put(new GT_ItemStack(tData.emptyContainer), tFluidToContainer = new /*Concurrent*/HashMap<>());
GregTech_API.sFluidMappings.add(tFluidToContainer);
}
tFluidToContainer.put(tData.fluid.getFluid(), tData);
+ if (tContainers == null) {
+ tContainers = new ArrayList<>();
+ tContainers.add(tData.filledContainer);
+ sFluidToContainers.put(tData.fluid.getFluid(), tContainers);
+ }
+ else tContainers.add(tData.filledContainer);
}
}
@@ -933,11 +942,27 @@ public class GT_Utility {
sFluidContainerList.add(aData);
sFilledContainerToData.put(new GT_ItemStack(aData.filledContainer), aData);
Map<Fluid, FluidContainerData> tFluidToContainer = sEmptyContainerToFluidToData.get(new GT_ItemStack(aData.emptyContainer));
+ List<ItemStack> tContainers = sFluidToContainers.get(aData.fluid.getFluid());
if (tFluidToContainer == null) {
sEmptyContainerToFluidToData.put(new GT_ItemStack(aData.emptyContainer), tFluidToContainer = new /*Concurrent*/HashMap<>());
GregTech_API.sFluidMappings.add(tFluidToContainer);
}
tFluidToContainer.put(aData.fluid.getFluid(), aData);
+ if (tContainers == null) {
+ tContainers = new ArrayList<>();
+ tContainers.add(aData.filledContainer);
+ sFluidToContainers.put(aData.fluid.getFluid(), tContainers);
+ }
+ else tContainers.add(aData.filledContainer);
+ }
+
+ public static List<ItemStack> getContainersFromFluid(FluidStack tFluidStack) {
+ if (tFluidStack != null) {
+ List<ItemStack> tContainers = sFluidToContainers.get(tFluidStack.getFluid());
+ if (tContainers == null) return new ArrayList<>();
+ return tContainers;
+ }
+ return new ArrayList<>();
}
public static ItemStack fillFluidContainer(FluidStack aFluid, ItemStack aStack, boolean aRemoveFluidDirectly, boolean aCheckIFluidContainerItems) {