use of micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityMethaneSynthesizer in project Galacticraft by micdoodle8.
the class BlockMachineMarsT2 method createTileEntity.
@Override
public TileEntity createTileEntity(World world, IBlockState state) {
int metadata = state.getBlock().getMetaFromState(state);
metadata &= 12;
if (metadata == BlockMachineMarsT2.GAS_LIQUEFIER_META) {
return new TileEntityGasLiquefier();
} else if (metadata == BlockMachineMarsT2.METHANE_SYNTHESIZER_META) {
return new TileEntityMethaneSynthesizer();
} else if (metadata == BlockMachineMarsT2.ELECTROLYZER_META) {
return new TileEntityElectrolyzer();
}
return null;
}
use of micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityMethaneSynthesizer in project Galacticraft by micdoodle8.
the class TileEntityElectrolyzer method produceHydrogen.
private boolean produceHydrogen(EnumFacing outputDirection) {
int provide = this.getHydrogenProvide(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(FluidRegistry.getFluid("hydrogen"), Math.min(gasRequested, provide)), true);
this.drawHydrogen(usedGas, true);
return true;
}
} else if (outputTile instanceof TileEntityMethaneSynthesizer) {
float requestedHydrogen = ((TileEntityMethaneSynthesizer) outputTile).getHydrogenRequest(outputDirection.getOpposite());
if (requestedHydrogen > 0) {
int toSend = Math.min(this.getHydrogenStored(), provide);
int acceptedHydrogen = ((TileEntityMethaneSynthesizer) outputTile).receiveHydrogen(outputDirection.getOpposite(), toSend, true);
this.drawHydrogen(acceptedHydrogen, true);
return true;
}
}
// else if (EnergyConfigHandler.isMekanismLoaded())
// {
// //TODO Gas item handling - internal tank (IGasItem)
// //int acceptedHydrogen = GasTransmission.addGas(itemStack, type, amount);
// //this.drawHydrogen(acceptedHydrogen, true);
//
// if (outputTile instanceof IGasHandler && ((IGasHandler) outputTile).canReceiveGas(outputDirection.getOpposite(), (Gas) EnergyConfigHandler.gasHydrogen))
// {
// GasStack toSend = new GasStack((Gas) EnergyConfigHandler.gasHydrogen, (int) Math.floor(Math.min(this.getHydrogenStored(), provide)));
// int acceptedHydrogen = 0;
// try {
// acceptedHydrogen = ((IGasHandler) outputTile).receiveGas(outputDirection.getOpposite(), toSend);
// } catch (Exception e) { }
// this.drawHydrogen(acceptedHydrogen, true);
// return true;
// }
// }
}
return false;
}
Aggregations