33import com .gregtechceu .gtceu .api .capability .IControllable ;
44import com .gregtechceu .gtceu .api .capability .IEnergyContainer ;
55import com .gregtechceu .gtceu .api .capability .recipe .EURecipeCapability ;
6+ import com .gregtechceu .gtceu .api .capability .recipe .FluidRecipeCapability ;
67import com .gregtechceu .gtceu .api .capability .recipe .IO ;
78import com .gregtechceu .gtceu .api .gui .GuiTextures ;
89import com .gregtechceu .gtceu .api .gui .fancy .ConfiguratorPanel ;
2324import com .gregtechceu .gtceu .api .pattern .TraceabilityPredicate ;
2425import com .gregtechceu .gtceu .api .recipe .ingredient .FluidIngredient ;
2526import com .gregtechceu .gtceu .common .data .GTItems ;
26- import com .gregtechceu .gtceu .common .machine .multiblock .part .DualHatchPartMachine ;
27- import com .gregtechceu .gtceu .common .machine .multiblock .part .FluidHatchPartMachine ;
2827import com .gregtechceu .gtceu .config .ConfigHolder ;
2928import com .gregtechceu .gtceu .utils .FormattingUtil ;
3029import com .gregtechceu .gtceu .utils .GTUtil ;
@@ -130,19 +129,19 @@ public void convertEnergyTick() {
130129 if (isWorkingEnabled () && getRecipeLogic ().getStatus () == RecipeLogic .Status .WORKING &&
131130 UtilConfig .coolantEnabled () && coolantTimer == 0 && frequency != 0 ) {
132131
133- MetaMachine coolantHatch = Objects
134- .requireNonNull (getMachine (Objects .requireNonNull (getLevel ()), coolantHatchPos ));
132+ IMultiPart coolantHatch = Objects
133+ .requireNonNull (( IMultiPart ) getMachine (Objects .requireNonNull (getLevel ()), coolantHatchPos ));
135134
136- NotifiableFluidTank tank ;
135+ NotifiableFluidTank tank = null ;
137136
138- if (coolantHatch instanceof FluidHatchPartMachine fluidHatch ) {
139- tank = fluidHatch .tank ;
140- } else if (coolantHatch instanceof DualHatchPartMachine dualHatch ) {
141- tank = dualHatch .tank ;
142- } else {
143- throw new IllegalStateException ("Tank must be a valid fluid or dual input hatch" );
137+ for (var handler : coolantHatch .getRecipeHandlers ()) {
138+ if (handler instanceof NotifiableFluidTank notifiableFluidTank ) {
139+ tank = notifiableFluidTank ;
140+ }
144141 }
145142
143+ assert tank != null ;
144+
146145 var ingredient = FluidIngredient .of (coolantDrain , UtilMaterials .QuantumCoolant .getFluid ());
147146 List <FluidIngredient > left = tank .handleRecipe (IO .IN , null , List .of (ingredient ), null , false );
148147 if (left != null && !left .isEmpty ()) {
@@ -230,13 +229,6 @@ public void onStructureFormed() {
230229 Map <Long , IO > ioMap = getMultiblockState ().getMatchContext ().getOrCreate ("ioMap" , Long2ObjectMaps ::emptyMap );
231230
232231 for (IMultiPart part : getPrioritySortedParts ()) {
233- if (part instanceof FluidHatchPartMachine machine ) {
234- this .coolantHatchPos = machine .getPos ();
235- continue ;
236- } else if (part instanceof DualHatchPartMachine machine ) {
237- this .coolantHatchPos = machine .getPos ();
238- continue ;
239- }
240232 IO io = ioMap .getOrDefault (part .self ().getPos ().asLong (), IO .BOTH );
241233 if (io == IO .NONE ) continue ;
242234 for (var handler : part .getRecipeHandlers ()) {
@@ -252,6 +244,9 @@ public void onStructureFormed() {
252244 }
253245 traitSubscriptions .add (handler .addChangedListener (converterSubscription ::updateSubscription ));
254246 }
247+ if (handler .getCapability () == FluidRecipeCapability .CAP && handler instanceof NotifiableFluidTank ) {
248+ this .coolantHatchPos = part .self ().getPos ();
249+ }
255250 }
256251 }
257252
@@ -436,6 +431,9 @@ public void setWorkingEnabled(boolean isWorkingAllowed) {
436431 removeWirelessEnergy ();
437432 }
438433 }
434+ if (!isWorkingAllowed ) {
435+ coolantTimer = 0 ;
436+ }
439437 }
440438
441439 @ Override
0 commit comments