Package mods.railcraft.common.fluids

Examples of mods.railcraft.common.fluids.TankToolkit


    @Override
    public int testCarts(List<EntityMinecart> carts) {
        for (EntityMinecart cart : carts) {
            if (cart instanceof IFluidHandler) {
                TankToolkit tank = new TankToolkit((IFluidHandler) cart);
                boolean liquidMatches = false;
                Fluid filterFluid = getFilterLiquid();
                FluidStack tankLiquid = tank.drain(ForgeDirection.UNKNOWN, 1, false);
                if (filterFluid == null)
                    liquidMatches = true;
                else if (Fluids.areEqual(filterFluid, tankLiquid))
                    liquidMatches = true;
                else if (tank.canPutFluid(ForgeDirection.UNKNOWN, new FluidStack(filterFluid, 1)))
                    liquidMatches = true;
                boolean quantityMatches = false;
                ButtonState state = buttonController.getButtonState();
                switch (state) {
                    case VOID:
                        quantityMatches = true;
                        break;
                    case EMPTY:
                        if (filterFluid != null && tank.isTankEmpty(filterFluid))
                            quantityMatches = true;
                        else if (filterFluid == null && tank.areTanksEmpty())
                            quantityMatches = true;
                        break;
                    case NOT_EMPTY:
                        if (filterFluid != null && tank.getFluidQty(filterFluid) > 0)
                            quantityMatches = true;
                        else if (filterFluid == null && tank.isFluidInTank())
                            quantityMatches = true;
                        break;
                    case FULL:
                        if (filterFluid != null && tank.isTankFull(filterFluid))
                            quantityMatches = true;
                        else if (filterFluid == null && tank.areTanksFull())
                            quantityMatches = true;
                        break;
                    default:
                        float level = filterFluid != null ? tank.getFluidLevel(filterFluid) : tank.getFluidLevel();
                        switch (state) {
                            case ANALOG:
                                return (int) (FULL_POWER * level);
                            case QUARTER:
                                quantityMatches = level >= 0.25f;
View Full Code Here


        }

        if (isPaused())
            return;

        TankToolkit tankCart = new TankToolkit((IFluidHandler) cart);
        boolean cartNeedsFilling = cartNeedsFilling(tankCart);

        if (cartNeedsFilling && needsPipe) {
            extendPipe();
        } else {
            retractPipe();
        }

        flow = 0;
        if (cartNeedsFilling && (!needsPipe || pipeIsExtended())) {
            FluidStack drained = tankManager.drain(0, RailcraftConfig.getTankCartFillRate(), false);
            if (drained != null) {
                flow = tankCart.fill(ForgeDirection.UP, drained, true);
                tankManager.drain(0, flow, true);
            }
        }

        if (flow > 0) {
            if (cart instanceof ILiquidTransfer) {
                ((ILiquidTransfer) cart).setFilling(true);
            }
            setPowered(false);
        } else {
            if (cart instanceof ILiquidTransfer) {
                ((ILiquidTransfer) cart).setFilling(false);
            }
        }

        if (tankCart.isTankFull(tank.getFluidType())) {
            waitForReset = RESET_WAIT;
        }

        if (stateController.getButtonState() != ButtonState.MANUAL
                && pipeIsRetracted() && flow <= 0 && shouldCartLeave(cart, tankCart)) {
View Full Code Here

            }

        if (isPaused())
            return;

        TankToolkit tankCart = new TankToolkit((IFluidHandler) cart);

        flow = 0;
        FluidStack drained = tankCart.drain(ForgeDirection.DOWN, RailcraftConfig.getTankCartFillRate(), false);
        if (getFilterFluid() == null || Fluids.areEqual(getFilterFluid(), drained)) {
            flow = tankManager.get(0).fill(drained, true);
            tankCart.drain(ForgeDirection.DOWN, flow, true);
        }

        if (flow > 0)
            setPowered(false);
View Full Code Here

TOP

Related Classes of mods.railcraft.common.fluids.TankToolkit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.