diff --git a/src/dark/core/prefab/fluids/FilteredTank.java b/src/dark/core/prefab/fluids/FilteredTank.java new file mode 100644 index 00000000..16154bb1 --- /dev/null +++ b/src/dark/core/prefab/fluids/FilteredTank.java @@ -0,0 +1,58 @@ +package dark.core.prefab.fluids; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTank; + +/** Tank that has a filter on the fluid ids it will accept + * + * @author DarkGuardsman */ +public class FilteredTank extends FluidTank +{ + private List fluidIds = new ArrayList(); + boolean gas = true; + boolean liquid = true; + + public FilteredTank(int capacity, int... fluidIds) + { + this(capacity, true, true, fluidIds); + } + + public FilteredTank(int capacity, boolean gas, boolean liquid, int... fluidIds) + { + super(capacity); + this.gas = gas; + this.liquid = liquid; + for (int id : fluidIds) + { + this.fluidIds.add(id); + } + } + + public FilteredTank(FluidStack stack, int capacity) + { + super(stack, capacity); + } + + public FilteredTank(Fluid fluid, int amount, int capacity) + { + super(fluid, amount, capacity); + } + + @Override + public int fill(FluidStack resource, boolean doFill) + { + if (resource != null && resource.getFluid() != null && (!gas || gas && resource.getFluid().isGaseous()) && (!liquid || liquid && !resource.getFluid().isGaseous())) + { + if (fluidIds.contains(resource.fluidID)) + { + return super.fill(resource, doFill); + } + } + return 0; + } + +} diff --git a/src/dark/core/prefab/fluids/LiquidTank.java b/src/dark/core/prefab/fluids/LiquidTank.java new file mode 100644 index 00000000..c1490c2b --- /dev/null +++ b/src/dark/core/prefab/fluids/LiquidTank.java @@ -0,0 +1,38 @@ +package dark.core.prefab.fluids; + +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTank; + +/** Version of the fluid tank that only supports liquids + * + * @author DarkGuardsman */ +public class LiquidTank extends FluidTank +{ + + public LiquidTank(int capacity) + { + super(capacity); + } + + public LiquidTank(FluidStack stack, int capacity) + { + super(stack, capacity); + } + + public LiquidTank(Fluid fluid, int amount, int capacity) + { + super(fluid, amount, capacity); + } + + @Override + public int fill(FluidStack resource, boolean doFill) + { + if (resource != null && resource.getFluid() != null && !resource.getFluid().isGaseous()) + { + return super.fill(resource, doFill); + } + return 0; + } + +}