Skip to content

Commit 7a19165

Browse files
DiFFoZYoungOnionMC
andauthored
Fix drums that are not acid proof allows to fill acid (GregTechCEu#2784)
Co-authored-by: YoungOnion <[email protected]>
1 parent 287c92b commit 7a19165

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

src/main/java/com/gregtechceu/gtceu/api/capability/IThermalFluidHandlerItemStack.java

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
package com.gregtechceu.gtceu.api.capability;
22

3+
import com.gregtechceu.gtceu.api.fluids.FluidConstants;
4+
import com.gregtechceu.gtceu.api.fluids.FluidState;
35
import com.gregtechceu.gtceu.api.fluids.attribute.FluidAttribute;
46
import com.gregtechceu.gtceu.api.fluids.attribute.FluidAttributes;
57
import com.gregtechceu.gtceu.api.fluids.attribute.IAttributedFluid;
68

9+
import net.minecraft.world.level.material.Fluid;
710
import net.minecraftforge.fluids.FluidStack;
811
import net.minecraftforge.fluids.FluidType;
912

13+
import java.util.Collection;
14+
1015
/**
1116
* Interface for FluidHandlerItemStacks which handle GT's unique fluid mechanics
1217
*
@@ -24,22 +29,24 @@ public interface IThermalFluidHandlerItemStack {
2429
default boolean canFillFluidType(FluidStack stack) {
2530
if (stack == null || stack.getFluid() == null) return false;
2631

27-
FluidType fluidType = stack.getFluid().getFluidType();
28-
var temp = fluidType.getTemperature();
29-
if (temp > getMaxFluidTemperature()) return false;
30-
// fluids less than 120K are cryogenic
31-
if (temp < 120 && !isCryoProof()) return false;
32+
Fluid fluid = stack.getFluid();
33+
34+
FluidType fluidType = fluid.getFluidType();
3235
if (fluidType.isLighterThanAir() && !isGasProof()) return false;
3336

34-
// TODO custom fluid
35-
// for (RegistryEntry<Fluid> entry : GTRegistries.REGISTRATE.getAll(Registry.FLUID_REGISTRY)) {
36-
// if (entry.get() == fluid) {
37-
// FluidType fluidType = ((MaterialFluid) fluid).getFluidType();
38-
// if (fluidType == FluidTypes.ACID && !isAcidProof()) return false;
39-
// if (fluidType == FluidTypes.PLASMA && !isPlasmaProof()) return false;
40-
// }
41-
// }
42-
return true;
37+
if (fluid instanceof IAttributedFluid attributedFluid) {
38+
Collection<FluidAttribute> attributes = attributedFluid.getAttributes();
39+
if (attributes.contains(FluidAttributes.ACID) && !isAcidProof()) return false;
40+
41+
FluidState fluidState = attributedFluid.getState();
42+
if (fluidState == FluidState.PLASMA && !isPlasmaProof()) return false;
43+
if (fluidState == FluidState.GAS && !isGasProof()) return false;
44+
}
45+
46+
int temperature = fluidType.getTemperature(stack);
47+
if (temperature < FluidConstants.CRYOGENIC_FLUID_THRESHOLD && !isCryoProof()) return false;
48+
49+
return temperature <= getMaxFluidTemperature();
4350
}
4451

4552
/**
@@ -54,6 +61,7 @@ default boolean canFillFluidType(FluidStack stack) {
5461
*
5562
* @return true if this fluid container allows gases, otherwise false
5663
*/
64+
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
5765
boolean isGasProof();
5866

5967
/**

0 commit comments

Comments
 (0)