Make it easier to use FluidTanks that have input/output restrictions (#2945)
These internal function should NOT be used by anything except the owner of the tank.
This commit is contained in:
parent
13b820fde2
commit
14ee316d06
1 changed files with 44 additions and 4 deletions
|
@ -122,7 +122,21 @@ public class FluidTank implements IFluidTank, IFluidHandler
|
||||||
@Override
|
@Override
|
||||||
public int fill(FluidStack resource, boolean doFill)
|
public int fill(FluidStack resource, boolean doFill)
|
||||||
{
|
{
|
||||||
if (resource == null || resource.amount <= 0 || !canFillFluidType(resource))
|
if (!canFillFluidType(resource))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fillInternal(resource, doFill);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to bypass the restrictions from {@link #canFillFluidType(FluidStack)}
|
||||||
|
* Meant for use by the owner of the tank when they have {@link #canFill() set to false}.
|
||||||
|
*/
|
||||||
|
public int fillInternal(FluidStack resource, boolean doFill)
|
||||||
|
{
|
||||||
|
if (resource == null || resource.amount <= 0)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -183,17 +197,43 @@ public class FluidTank implements IFluidTank, IFluidHandler
|
||||||
@Override
|
@Override
|
||||||
public FluidStack drain(FluidStack resource, boolean doDrain)
|
public FluidStack drain(FluidStack resource, boolean doDrain)
|
||||||
{
|
{
|
||||||
if (resource == null || !resource.isFluidEqual(getFluid()))
|
if (!canDrainFluidType(getFluid()))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return drain(resource.amount, doDrain);
|
return drainInternal(resource, doDrain);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FluidStack drain(int maxDrain, boolean doDrain)
|
public FluidStack drain(int maxDrain, boolean doDrain)
|
||||||
{
|
{
|
||||||
if (fluid == null || maxDrain <= 0 || !canDrainFluidType(fluid))
|
if (!canDrainFluidType(fluid))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return drainInternal(maxDrain, doDrain);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to bypass the restrictions from {@link #canDrainFluidType(FluidStack)}
|
||||||
|
* Meant for use by the owner of the tank when they have {@link #canDrain()} set to false}.
|
||||||
|
*/
|
||||||
|
public FluidStack drainInternal(FluidStack resource, boolean doDrain)
|
||||||
|
{
|
||||||
|
if (resource == null || !resource.isFluidEqual(getFluid()))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return drainInternal(resource.amount, doDrain);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to bypass the restrictions from {@link #canDrainFluidType(FluidStack)}
|
||||||
|
* Meant for use by the owner of the tank when they have {@link #canDrain()} set to false}.
|
||||||
|
*/
|
||||||
|
public FluidStack drainInternal(int maxDrain, boolean doDrain)
|
||||||
|
{
|
||||||
|
if (fluid == null || maxDrain <= 0)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue