Search in sources :

Example 1 with IOxygenReceiver

use of micdoodle8.mods.galacticraft.api.transmission.tile.IOxygenReceiver in project Galacticraft by micdoodle8.

the class TileEntityElectrolyzer method produceOxygen.

private boolean produceOxygen(EnumFacing outputDirection) {
    int provide = this.getOxygenProvide(outputDirection);
    if (provide > 0) {
        TileEntity outputTile = new BlockVec3(this).modifyPositionFromSide(outputDirection).getTileEntity(this.worldObj);
        FluidNetwork outputNetwork = NetworkHelper.getFluidNetworkFromTile(outputTile, outputDirection);
        if (outputNetwork != null) {
            int gasRequested = outputNetwork.getRequest();
            if (gasRequested > 0) {
                int usedGas = outputNetwork.emitToBuffer(new FluidStack(GCFluids.fluidOxygenGas, Math.min(gasRequested, provide)), true);
                this.drawOxygen(usedGas, true);
                return true;
            }
        } else if (outputTile instanceof IOxygenReceiver) {
            float requestedOxygen = ((IOxygenReceiver) outputTile).getOxygenRequest(outputDirection.getOpposite());
            if (requestedOxygen > 0) {
                int toSend = Math.min(this.getOxygenStored(), provide);
                int acceptedOxygen = ((IOxygenReceiver) outputTile).receiveOxygen(outputDirection.getOpposite(), toSend, true);
                this.drawOxygen(acceptedOxygen, true);
                return true;
            }
        }
    // else if (EnergyConfigHandler.isMekanismLoaded())
    // {
    // //TODO Oxygen item handling - internal tank (IGasItem)
    // //int acceptedOxygen = GasTransmission.addGas(itemStack, type, amount);
    // //this.drawOxygen(acceptedOxygen, true);
    // 
    // if (outputTile instanceof IGasHandler && ((IGasHandler) outputTile).canReceiveGas(outputDirection.getOpposite(), (Gas) EnergyConfigHandler.gasOxygen))
    // {
    // GasStack toSend = new GasStack((Gas) EnergyConfigHandler.gasOxygen, (int) Math.floor(Math.min(this.getOxygenStored(), provide)));
    // int acceptedOxygen = 0;
    // try {
    // acceptedOxygen = ((IGasHandler) outputTile).receiveGas(outputDirection.getOpposite(), toSend);
    // } catch (Exception e) { }
    // this.drawOxygen(acceptedOxygen, true);
    // return true;
    // }
    // }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FluidNetwork(micdoodle8.mods.galacticraft.core.fluid.FluidNetwork) IOxygenReceiver(micdoodle8.mods.galacticraft.api.transmission.tile.IOxygenReceiver) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 2 with IOxygenReceiver

use of micdoodle8.mods.galacticraft.api.transmission.tile.IOxygenReceiver in project Galacticraft by micdoodle8.

the class TileEntityOxygen method produceOxygen.

public boolean produceOxygen(EnumFacing outputDirection) {
    int provide = this.getOxygenProvide(outputDirection);
    if (provide > 0) {
        TileEntity outputTile = new BlockVec3(this).getTileEntityOnSide(this.worldObj, outputDirection);
        FluidNetwork outputNetwork = NetworkHelper.getFluidNetworkFromTile(outputTile, outputDirection);
        if (outputNetwork != null) {
            int gasRequested = outputNetwork.getRequest();
            if (gasRequested > 0) {
                int usedGas = outputNetwork.emitToBuffer(new FluidStack(GCFluids.fluidOxygenGas, Math.min(gasRequested, provide)), true);
                this.drawOxygen(usedGas, true);
                return true;
            }
        } else if (outputTile instanceof IOxygenReceiver) {
            float requestedOxygen = ((IOxygenReceiver) outputTile).getOxygenRequest(outputDirection.getOpposite());
            if (requestedOxygen > 0) {
                int acceptedOxygen = ((IOxygenReceiver) outputTile).receiveOxygen(outputDirection.getOpposite(), provide, true);
                this.drawOxygen(acceptedOxygen, true);
                return true;
            }
        }
    // else if (EnergyConfigHandler.isMekanismLoaded())
    // {
    // //TODO Oxygen item handling - internal tank (IGasItem)
    // //int acceptedOxygen = GasTransmission.addGas(itemStack, type, amount);
    // //this.drawOxygen(acceptedOxygen, true);
    // 
    // if (outputTile instanceof IGasHandler && ((IGasHandler) outputTile).canReceiveGas(outputDirection.getOpposite(), (Gas) EnergyConfigHandler.gasOxygen))
    // {
    // GasStack toSend = new GasStack((Gas) EnergyConfigHandler.gasOxygen, (int) Math.floor(provide));
    // int acceptedOxygen = 0;
    // try {
    // acceptedOxygen = ((IGasHandler) outputTile).receiveGas(outputDirection.getOpposite(), toSend);
    // } catch (Exception e) { }
    // this.drawOxygen(acceptedOxygen, true);
    // return true;
    // }
    // }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FluidNetwork(micdoodle8.mods.galacticraft.core.fluid.FluidNetwork) FluidStack(net.minecraftforge.fluids.FluidStack) IOxygenReceiver(micdoodle8.mods.galacticraft.api.transmission.tile.IOxygenReceiver) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Aggregations

IOxygenReceiver (micdoodle8.mods.galacticraft.api.transmission.tile.IOxygenReceiver)2 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)2 FluidNetwork (micdoodle8.mods.galacticraft.core.fluid.FluidNetwork)2 TileEntity (net.minecraft.tileentity.TileEntity)2 FluidStack (net.minecraftforge.fluids.FluidStack)1