|
17 | 17 | import com.gregtechceu.gtceu.api.machine.feature.multiblock.IMultiPart; |
18 | 18 | import com.gregtechceu.gtceu.api.machine.multiblock.PartAbility; |
19 | 19 | import com.gregtechceu.gtceu.api.machine.multiblock.WorkableElectricMultiblockMachine; |
| 20 | +import com.gregtechceu.gtceu.api.machine.trait.NotifiableFluidTank; |
20 | 21 | import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic; |
21 | 22 | import com.gregtechceu.gtceu.api.misc.EnergyContainerList; |
22 | 23 | import com.gregtechceu.gtceu.api.pattern.TraceabilityPredicate; |
23 | 24 | import com.gregtechceu.gtceu.api.recipe.ingredient.FluidIngredient; |
24 | 25 | import com.gregtechceu.gtceu.common.data.GTItems; |
| 26 | +import com.gregtechceu.gtceu.common.machine.multiblock.part.DualHatchPartMachine; |
25 | 27 | import com.gregtechceu.gtceu.common.machine.multiblock.part.FluidHatchPartMachine; |
26 | 28 | import com.gregtechceu.gtceu.config.ConfigHolder; |
27 | 29 | import com.gregtechceu.gtceu.utils.FormattingUtil; |
|
41 | 43 | import net.minecraft.server.level.ServerLevel; |
42 | 44 | import net.minecraft.world.entity.player.Player; |
43 | 45 | import net.minecraft.world.level.block.Block; |
44 | | -import net.minecraftforge.fluids.FluidStack; |
45 | 46 | import net.neganote.gtutilities.common.materials.UtilMaterials; |
46 | 47 | import net.neganote.gtutilities.config.UtilConfig; |
47 | 48 | import net.neganote.gtutilities.saveddata.PTERBSavedData; |
@@ -129,15 +130,22 @@ public void convertEnergyTick() { |
129 | 130 | if (isWorkingEnabled() && getRecipeLogic().getStatus() == RecipeLogic.Status.WORKING && |
130 | 131 | UtilConfig.coolantEnabled() && coolantTimer == 0 && frequency != 0) { |
131 | 132 |
|
132 | | - FluidHatchPartMachine coolantHatch = Objects.requireNonNull( |
133 | | - (FluidHatchPartMachine) getMachine(Objects.requireNonNull(getLevel()), coolantHatchPos)); |
| 133 | + MetaMachine coolantHatch = Objects |
| 134 | + .requireNonNull(getMachine(Objects.requireNonNull(getLevel()), coolantHatchPos)); |
134 | 135 |
|
135 | | - FluidStack coolant = coolantHatch.tank.getFluidInTank(0); |
136 | | - if (coolant.getFluid() == UtilMaterials.QuantumCoolant.getFluid() && coolant.getAmount() >= coolantDrain) { |
137 | | - coolantHatch.tank.handleRecipe(IO.IN, null, |
138 | | - List.of(FluidIngredient.of(coolantDrain, UtilMaterials.QuantumCoolant.getFluid())), null, |
139 | | - false); |
| 136 | + NotifiableFluidTank tank; |
| 137 | + |
| 138 | + if (coolantHatch instanceof FluidHatchPartMachine fluidHatch) { |
| 139 | + tank = fluidHatch.tank; |
| 140 | + } else if (coolantHatch instanceof DualHatchPartMachine dualHatch) { |
| 141 | + tank = dualHatch.tank; |
140 | 142 | } else { |
| 143 | + throw new IllegalStateException("Tank must be a valid fluid or dual input hatch"); |
| 144 | + } |
| 145 | + |
| 146 | + var ingredient = FluidIngredient.of(coolantDrain, UtilMaterials.QuantumCoolant.getFluid()); |
| 147 | + List<FluidIngredient> left = tank.handleRecipe(IO.IN, null, List.of(ingredient), null, false); |
| 148 | + if (left != null && !left.isEmpty()) { |
141 | 149 | if (!ConfigHolder.INSTANCE.machines.harmlessActiveTransformers) { |
142 | 150 | explode(); |
143 | 151 | } else { |
@@ -225,6 +233,9 @@ public void onStructureFormed() { |
225 | 233 | if (part instanceof FluidHatchPartMachine machine) { |
226 | 234 | this.coolantHatchPos = machine.getPos(); |
227 | 235 | continue; |
| 236 | + } else if (part instanceof DualHatchPartMachine machine) { |
| 237 | + this.coolantHatchPos = machine.getPos(); |
| 238 | + continue; |
228 | 239 | } |
229 | 240 | IO io = ioMap.getOrDefault(part.self().getPos().asLong(), IO.BOTH); |
230 | 241 | if (io == IO.NONE) continue; |
|
0 commit comments