11package mekanism .common .inventory .slot ;
22
3- import java .util .HashMap ;
3+ import it .unimi .dsi .fastutil .objects .Object2ObjectOpenCustomHashMap ;
4+ import java .util .Collection ;
45import java .util .Map ;
5- import java .util .Set ;
66import mekanism .api .Action ;
77import mekanism .api .AutomationType ;
88import mekanism .api .fluid .IExtendedFluidTank ;
99import mekanism .api .inventory .IInventorySlot ;
1010import mekanism .common .capabilities .Capabilities ;
11+ import mekanism .common .lib .collection .FluidHashStrategy ;
1112import mekanism .common .tile .interfaces .IFluidContainerManager .ContainerEditMode ;
1213import mekanism .common .util .MekanismUtils ;
1314import net .minecraft .world .item .ItemStack ;
1415import net .neoforged .neoforge .fluids .FluidStack ;
1516import net .neoforged .neoforge .fluids .capability .IFluidHandler ;
1617import net .neoforged .neoforge .fluids .capability .IFluidHandler .FluidAction ;
1718import net .neoforged .neoforge .fluids .capability .IFluidHandlerItem ;
18- import net .neoforged .neoforge .items .ItemHandlerHelper ;
1919
2020public interface IFluidHandlerSlot extends IInventorySlot {
2121
@@ -88,9 +88,8 @@ default void fillTank(IInventorySlot outputSlot) {
8888 //If we have more than one tank in our item then handle calculating the different drains that will occur for filling our fluid handler
8989 // We start by gathering all the fluids in the item that we are able to drain and are valid for the tank,
9090 // combining same fluid types into a single fluid stack
91- Set <FluidStack > knownFluids = gatherKnownFluids (itemFluidHandler , itemTanks );
9291 //If we found any fluids that we can drain, attempt to drain them into our item
93- for (FluidStack knownFluid : knownFluids ) {
92+ for (FluidStack knownFluid : gatherKnownFluids ( itemFluidHandler , itemTanks ) ) {
9493 if (drainItemAndMove (outputSlot , knownFluid ) && isEmpty ()) {
9594 //If we moved the item after draining it and we now don't have an item to try and fill
9695 // then just exit instead of checking the other types of fluids
@@ -261,7 +260,7 @@ default boolean fillTank() {
261260 //If we have more than one tank in our item then handle calculating the different drains that will occur for filling our fluid handler
262261 // We start by gathering all the fluids in the item that we are able to drain and are valid for the tank,
263262 // combining same fluid types into a single fluid stack
264- Set <FluidStack > knownFluids = gatherKnownFluids (itemFluidHandler , tanks );
263+ Collection <FluidStack > knownFluids = gatherKnownFluids (itemFluidHandler , tanks );
265264 if (!knownFluids .isEmpty ()) {
266265 //If we found any fluids that we can drain, attempt to drain them into our item
267266 boolean changed = false ;
@@ -282,8 +281,8 @@ default boolean fillTank() {
282281 return false ;
283282 }
284283
285- private Set <FluidStack > gatherKnownFluids (IFluidHandlerItem itemFluidHandler , int tanks ) {
286- Map <FluidStack , FluidStack > knownFluids = new HashMap <>();
284+ private Collection <FluidStack > gatherKnownFluids (IFluidHandlerItem itemFluidHandler , int tanks ) {
285+ Map <FluidStack , FluidStack > knownFluids = new Object2ObjectOpenCustomHashMap <>(FluidHashStrategy . INSTANCE );
287286 for (int tank = 0 ; tank < tanks ; tank ++) {
288287 FluidStack fluidInItem = itemFluidHandler .getFluidInTank (tank );
289288 if (!fluidInItem .isEmpty ()) {
0 commit comments