Search in sources :

Example 1 with IFluidCart

use of mods.railcraft.api.carts.IFluidCart in project Railcraft by Railcraft.

the class TileFluidLoader method processCart.

@Override
protected void processCart(EntityMinecart cart) {
    if (cart instanceof EntityLocomotiveSteam) {
        EntityLocomotiveSteam loco = (EntityLocomotiveSteam) cart;
        if (!loco.isSafeToFill()) {
            retractPipe();
            return;
        }
    }
    AdvancedFluidHandler tankCart = getFluidHandler(cart, EnumFacing.UP);
    if (tankCart == null)
        return;
    boolean cartNeedsFilling = cartNeedsFilling(tankCart);
    if (cartNeedsFilling && needsPipe)
        extendPipe();
    else
        retractPipe();
    setProcessing(false);
    if (cartNeedsFilling && (!needsPipe || pipeIsExtended())) {
        FluidStack moved = FluidUtil.tryFluidTransfer(tankCart, tank, RailcraftConfig.getTankCartFillRate(), true);
        setProcessing(Fluids.isNotEmpty(moved));
    }
    if (isProcessing())
        setPowered(false);
    if (cart instanceof IFluidCart)
        ((IFluidCart) cart).setFilling(isProcessing());
    if (tankCart.isTankFull(tank.getFluidType()))
        setResetTimer(RESET_WAIT);
}
Also used : AdvancedFluidHandler(mods.railcraft.common.fluids.AdvancedFluidHandler) FluidStack(net.minecraftforge.fluids.FluidStack) EntityLocomotiveSteam(mods.railcraft.common.carts.EntityLocomotiveSteam) IFluidCart(mods.railcraft.api.carts.IFluidCart)

Example 2 with IFluidCart

use of mods.railcraft.api.carts.IFluidCart in project Railcraft by Railcraft.

the class TrainTransferHelper method canAcceptPushedFluid.

private boolean canAcceptPushedFluid(EntityMinecart requester, EntityMinecart cart, Fluid fluid) {
    IFluidHandler fluidHandler = FluidTools.getFluidHandler(EnumFacing.UP, cart);
    if (fluidHandler == null)
        return false;
    if (cart instanceof IFluidCart)
        return ((IFluidCart) cart).canAcceptPushedFluid(requester, fluid);
    AdvancedFluidHandler advancedFluidHandler = new AdvancedFluidHandler(fluidHandler);
    return advancedFluidHandler.canPutFluid(new FluidStack(fluid, 1));
}
Also used : AdvancedFluidHandler(mods.railcraft.common.fluids.AdvancedFluidHandler) FluidStack(net.minecraftforge.fluids.FluidStack) IFluidCart(mods.railcraft.api.carts.IFluidCart) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler)

Aggregations

IFluidCart (mods.railcraft.api.carts.IFluidCart)2 AdvancedFluidHandler (mods.railcraft.common.fluids.AdvancedFluidHandler)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 EntityLocomotiveSteam (mods.railcraft.common.carts.EntityLocomotiveSteam)1 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)1