diff options
author | GlodBlock <1356392126@qq.com> | 2021-09-26 22:36:32 +0800 |
---|---|---|
committer | GlodBlock <1356392126@qq.com> | 2021-09-26 22:36:32 +0800 |
commit | 92433a5b85bb2fcca541ac25ca4033fac24f841e (patch) | |
tree | 90f26b34d5059eb9858d9c82aabbd5373638acfa /src/main/java/gregtech/api | |
parent | c82b604a02d6d5aab7e63ca5ea9337ae6552f513 (diff) | |
parent | bb392ea9d1e837e849a05507e72b63c4bca3f5b2 (diff) | |
download | GT5-Unofficial-92433a5b85bb2fcca541ac25ca4033fac24f841e.tar.gz GT5-Unofficial-92433a5b85bb2fcca541ac25ca4033fac24f841e.tar.bz2 GT5-Unofficial-92433a5b85bb2fcca541ac25ca4033fac24f841e.zip |
Merge branch 'experimental' of https://github.com/GTNewHorizons/GT5-Unofficial into fix-crack-recipe-check
Diffstat (limited to 'src/main/java/gregtech/api')
-rw-r--r-- | src/main/java/gregtech/api/util/GT_Utility.java | 25 |
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) { |