Search in sources :

Example 1 with ITankAccess

use of com.enderio.core.api.common.util.ITankAccess in project EnderIO by SleepyTrousers.

the class ReservoirTankWrapper method setTanksDirty.

@Override
public void setTanksDirty() {
    if (tank != null) {
        FluidStack stack = tank.getFluid();
        if (stack != null && stack.amount > 0) {
            for (ITankAccess parent : parents) {
                FluidTank ptank = parent.getInputTank(stack);
                if (ptank != null) {
                    stack.amount -= ptank.fill(stack, true);
                    parent.setTanksDirty();
                    if (stack.amount <= 0) {
                        return;
                    }
                }
            }
        }
        tank.setCapacity(0);
    }
}
Also used : FluidTank(net.minecraftforge.fluids.FluidTank) ITankAccess(com.enderio.core.api.common.util.ITankAccess) FluidStack(net.minecraftforge.fluids.FluidStack)

Example 2 with ITankAccess

use of com.enderio.core.api.common.util.ITankAccess in project EnderIO by SleepyTrousers.

the class ReservoirTankWrapper method getInputTank.

@Override
public FluidTank getInputTank(FluidStack forFluidType) {
    FluidTank parentTank = parents.get(0).getInputTank(forFluidType);
    if (parentTank == null) {
        return null;
    }
    int free = parentTank.getCapacity() - parentTank.getFluidAmount();
    for (NNIterator<EnumFacing> itr = NNList.FACING.fastIterator(); itr.hasNext(); ) {
        TileEntity neighbor = world.getTileEntity(pos.offset(itr.next()));
        if (neighbor instanceof ITankAccess) {
            FluidTank tank2 = ((ITankAccess) neighbor).getInputTank(forFluidType);
            if (tank2 != null) {
                free += tank2.getCapacity() - tank2.getFluidAmount();
                parents.add(((ITankAccess) neighbor));
            }
        }
    }
    if (free < Fluid.BUCKET_VOLUME) {
        free = Fluid.BUCKET_VOLUME;
    }
    return tank = new SmartTank(parentTank.getFluid(), free);
}
Also used : FluidTank(net.minecraftforge.fluids.FluidTank) TileEntity(net.minecraft.tileentity.TileEntity) ITankAccess(com.enderio.core.api.common.util.ITankAccess) EnumFacing(net.minecraft.util.EnumFacing) SmartTank(com.enderio.core.common.fluid.SmartTank)

Aggregations

ITankAccess (com.enderio.core.api.common.util.ITankAccess)2 FluidTank (net.minecraftforge.fluids.FluidTank)2 SmartTank (com.enderio.core.common.fluid.SmartTank)1 TileEntity (net.minecraft.tileentity.TileEntity)1 EnumFacing (net.minecraft.util.EnumFacing)1 FluidStack (net.minecraftforge.fluids.FluidStack)1