Package mods.railcraft.api.carts

Examples of mods.railcraft.api.carts.IEnergyTransfer


            if (CartTools.cartVelocityIsLessThan(cart, STOP_VELOCITY))
                setPowered(true);
            return;
        }

        IEnergyTransfer energyCart = (IEnergyTransfer) cart;

        if (!energyCart.canInjectEnergy() || energyCart.getTier() > getTier()) {
            if (CartTools.cartVelocityIsLessThan(cart, STOP_VELOCITY))
                setPowered(true);
            return;
        }

        if (isPaused())
            return;

        if (energy > 0 && energyCart.getEnergy() < energyCart.getCapacity()) {
            double usage = (int) (energyCart.getTransferLimit() * Math.pow(1.5, overclockerUpgrades));
            double injection = (int) (energyCart.getTransferLimit() * Math.pow(1.3, overclockerUpgrades));
            if (usage > energy) {
                double ratio = (double) energy / (double) usage;
                usage = energy;
                injection = (int) (injection * ratio);
            }

            transferRate = (int) injection;
            double extra = energyCart.injectEnergy(this, injection, getTier(), true, false, false);
            energy -= usage - extra;
            transferedEnergy = extra != injection;
        }

        if (!transferedEnergy && !isPowered() && CartTools.cartVelocityIsLessThan(cart, STOP_VELOCITY))
            if (!waitTillFull && energyCart.getEnergy() > 0)
                setPowered(true);
            else if (!waitIfEmpty && !waitTillFull && energyCart.getEnergy() == 0)
                setPowered(true);
            else if (energyCart.getEnergy() >= energyCart.getCapacity())
                setPowered(true);
    }
View Full Code Here


            if (CartTools.cartVelocityIsLessThan(cart, STOP_VELOCITY))
                setPowered(true);
            return;
        }

        IEnergyTransfer energyCart = (IEnergyTransfer) cart;

        if (!energyCart.canExtractEnergy() || energyCart.getTier() > getTier()) {
            if (CartTools.cartVelocityIsLessThan(cart, STOP_VELOCITY))
                setPowered(true);
            return;
        }

        if (isPaused())
            return;

        if (energy < getCapacity() && energyCart.getEnergy() > 0) {
            double usage = (energyCart.getTransferLimit() * Math.pow(1.5, overclockerUpgrades));
            double injection = (energyCart.getTransferLimit() * Math.pow(1.3, overclockerUpgrades));

            double room = getCapacity() - getEnergy();
            if (room < injection) {
                double ratio = room / injection;
                injection = room;
                usage = usage * ratio;
            }

            double extract = energyCart.extractEnergy(this, usage, getTier(), true, false, false);

            if (extract < usage) {
                double ratio = extract / usage;
                usage = extract;
                injection = injection * ratio;
            }

            transferRate = (int) injection;
            energy += injection;
            transferedEnergy = extract > 0;
        }

        if (!transferedEnergy && !isPowered() && CartTools.cartVelocityIsLessThan(cart, STOP_VELOCITY))
            if (!waitTillEmpty)
                setPowered(true);
            else if (energyCart.getEnergy() == 0)
                setPowered(true);
    }
View Full Code Here

TOP

Related Classes of mods.railcraft.api.carts.IEnergyTransfer

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.