Skip to content

Commit

Permalink
Fix drums that are not acid proof allows to fill acid (#2784)
Browse files Browse the repository at this point in the history
Co-authored-by: YoungOnion <[email protected]>
  • Loading branch information
DiFFoZ and YoungOnionMC authored Mar 2, 2025
1 parent 287c92b commit 7a19165
Showing 1 changed file with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package com.gregtechceu.gtceu.api.capability;

import com.gregtechceu.gtceu.api.fluids.FluidConstants;
import com.gregtechceu.gtceu.api.fluids.FluidState;
import com.gregtechceu.gtceu.api.fluids.attribute.FluidAttribute;
import com.gregtechceu.gtceu.api.fluids.attribute.FluidAttributes;
import com.gregtechceu.gtceu.api.fluids.attribute.IAttributedFluid;

import net.minecraft.world.level.material.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidType;

import java.util.Collection;

/**
* Interface for FluidHandlerItemStacks which handle GT's unique fluid mechanics
*
Expand All @@ -24,22 +29,24 @@ public interface IThermalFluidHandlerItemStack {
default boolean canFillFluidType(FluidStack stack) {
if (stack == null || stack.getFluid() == null) return false;

FluidType fluidType = stack.getFluid().getFluidType();
var temp = fluidType.getTemperature();
if (temp > getMaxFluidTemperature()) return false;
// fluids less than 120K are cryogenic
if (temp < 120 && !isCryoProof()) return false;
Fluid fluid = stack.getFluid();

FluidType fluidType = fluid.getFluidType();
if (fluidType.isLighterThanAir() && !isGasProof()) return false;

// TODO custom fluid
// for (RegistryEntry<Fluid> entry : GTRegistries.REGISTRATE.getAll(Registry.FLUID_REGISTRY)) {
// if (entry.get() == fluid) {
// FluidType fluidType = ((MaterialFluid) fluid).getFluidType();
// if (fluidType == FluidTypes.ACID && !isAcidProof()) return false;
// if (fluidType == FluidTypes.PLASMA && !isPlasmaProof()) return false;
// }
// }
return true;
if (fluid instanceof IAttributedFluid attributedFluid) {
Collection<FluidAttribute> attributes = attributedFluid.getAttributes();
if (attributes.contains(FluidAttributes.ACID) && !isAcidProof()) return false;

FluidState fluidState = attributedFluid.getState();
if (fluidState == FluidState.PLASMA && !isPlasmaProof()) return false;
if (fluidState == FluidState.GAS && !isGasProof()) return false;
}

int temperature = fluidType.getTemperature(stack);
if (temperature < FluidConstants.CRYOGENIC_FLUID_THRESHOLD && !isCryoProof()) return false;

return temperature <= getMaxFluidTemperature();
}

/**
Expand All @@ -54,6 +61,7 @@ default boolean canFillFluidType(FluidStack stack) {
*
* @return true if this fluid container allows gases, otherwise false
*/
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
boolean isGasProof();

/**
Expand Down

0 comments on commit 7a19165

Please sign in to comment.