Search in sources :

Example 1 with TileEntityMethaneSynthesizer

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;
}
Also used : TileEntityGasLiquefier(micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityGasLiquefier) TileEntityMethaneSynthesizer(micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityMethaneSynthesizer) TileEntityElectrolyzer(micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityElectrolyzer)

Example 2 with TileEntityMethaneSynthesizer

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FluidNetwork(micdoodle8.mods.galacticraft.core.fluid.FluidNetwork) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Aggregations

BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)1 FluidNetwork (micdoodle8.mods.galacticraft.core.fluid.FluidNetwork)1 TileEntityElectrolyzer (micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityElectrolyzer)1 TileEntityGasLiquefier (micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityGasLiquefier)1 TileEntityMethaneSynthesizer (micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityMethaneSynthesizer)1 TileEntity (net.minecraft.tileentity.TileEntity)1