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;
}
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;
}
Aggregations