Search in sources :

Example 1 with BlockPipe

use of gregtech.api.pipenet.block.BlockPipe in project GregTech by GregTechCE.

the class TileEntityPipeBase method getPipeBlock.

@Override
public BlockPipe<PipeType, NodeDataType, ?> getPipeBlock() {
    if (pipeBlock == null) {
        Block block = getBlockState().getBlock();
        // noinspection unchecked
        this.pipeBlock = block instanceof BlockPipe ? (BlockPipe<PipeType, NodeDataType, ?>) block : null;
    }
    return pipeBlock;
}
Also used : Block(net.minecraft.block.Block) BlockPipe(gregtech.api.pipenet.block.BlockPipe)

Example 2 with BlockPipe

use of gregtech.api.pipenet.block.BlockPipe in project GregTech by GregTechCEu.

the class MachineItemBlock method placeBlockAt.

@Override
public boolean placeBlockAt(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) {
    MetaTileEntity metaTileEntity = getMetaTileEntity(stack);
    // prevent rendering glitch before meta tile entity sync to client, but after block placement
    // set opaque property on the placing on block, instead during set of meta tile entity
    boolean superVal = super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState.withProperty(BlockMachine.OPAQUE, metaTileEntity != null && metaTileEntity.isOpaqueCube()));
    if (superVal && !world.isRemote) {
        BlockPos possiblePipe = pos.offset(side.getOpposite());
        Block block = world.getBlockState(possiblePipe).getBlock();
        if (block instanceof BlockPipe) {
            IPipeTile pipeTile = ((BlockPipe<?, ?, ?>) block).getPipeTileEntity(world, possiblePipe);
            if (pipeTile != null && ((BlockPipe<?, ?, ?>) block).canPipeConnectToBlock(pipeTile, side.getOpposite(), world.getTileEntity(pos))) {
                pipeTile.setConnection(side, true, false);
            }
        }
    }
    return superVal;
}
Also used : IPipeTile(gregtech.api.pipenet.tile.IPipeTile) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) ITieredMetaTileEntity(gregtech.api.metatileentity.ITieredMetaTileEntity) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) BlockPos(net.minecraft.util.math.BlockPos) BlockPipe(gregtech.api.pipenet.block.BlockPipe)

Example 3 with BlockPipe

use of gregtech.api.pipenet.block.BlockPipe in project GregTech by GregTechCEu.

the class TileEntityPipeBase method getPipeBlock.

@Override
public BlockPipe<PipeType, NodeDataType, ?> getPipeBlock() {
    if (pipeBlock == null) {
        Block block = getBlockState().getBlock();
        // noinspection unchecked
        this.pipeBlock = block instanceof BlockPipe ? (BlockPipe<PipeType, NodeDataType, ?>) block : null;
    }
    return pipeBlock;
}
Also used : Block(net.minecraft.block.Block) BlockPipe(gregtech.api.pipenet.block.BlockPipe)

Example 4 with BlockPipe

use of gregtech.api.pipenet.block.BlockPipe in project GregTech by GregTechCE.

the class TileEntityPipeBase method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound compound) {
    super.readFromNBT(compound);
    if (compound.hasKey("PipeBlock", NBT.TAG_STRING)) {
        Block block = Block.REGISTRY.getObject(new ResourceLocation(compound.getString("PipeBlock")));
        // noinspection unchecked
        this.pipeBlock = block instanceof BlockPipe ? (BlockPipe<PipeType, NodeDataType, ?>) block : null;
    }
    this.pipeType = getPipeTypeClass().getEnumConstants()[compound.getInteger("PipeType")];
    NBTTagCompound blockedConnectionsTag = compound.getCompoundTag("BlockedConnectionsMap");
    this.blockedConnectionsMap.clear();
    for (String attachmentTypeKey : blockedConnectionsTag.getKeySet()) {
        int attachmentType = Integer.parseInt(attachmentTypeKey);
        int blockedConnections = blockedConnectionsTag.getInteger(attachmentTypeKey);
        this.blockedConnectionsMap.put(attachmentType, blockedConnections);
    }
    recomputeBlockedConnections();
    this.insulationColor = compound.getInteger("InsulationColor");
    this.coverableImplementation.readFromNBT(compound);
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Block(net.minecraft.block.Block) BlockPipe(gregtech.api.pipenet.block.BlockPipe)

Example 5 with BlockPipe

use of gregtech.api.pipenet.block.BlockPipe in project GregTech by GregTechCEu.

the class TileEntityPipeBase method readFromNBT.

@Override
public void readFromNBT(@Nonnull NBTTagCompound compound) {
    super.readFromNBT(compound);
    if (compound.hasKey("PipeBlock", NBT.TAG_STRING)) {
        Block block = Block.REGISTRY.getObject(new ResourceLocation(compound.getString("PipeBlock")));
        // noinspection unchecked
        this.pipeBlock = block instanceof BlockPipe ? (BlockPipe<PipeType, NodeDataType, ?>) block : null;
    }
    this.pipeType = getPipeTypeClass().getEnumConstants()[compound.getInteger("PipeType")];
    if (compound.hasKey("Connections")) {
        connections = compound.getInteger("Connections");
    } else if (compound.hasKey("BlockedConnectionsMap")) {
        connections = 0;
        NBTTagCompound blockedConnectionsTag = compound.getCompoundTag("BlockedConnectionsMap");
        for (String attachmentTypeKey : blockedConnectionsTag.getKeySet()) {
            int blockedConnections = blockedConnectionsTag.getInteger(attachmentTypeKey);
            connections |= blockedConnections;
        }
    }
    blockedConnections = compound.getInteger("BlockedConnections");
    if (compound.hasKey("InsulationColor")) {
        this.paintingColor = compound.getInteger("InsulationColor");
    }
    this.coverableImplementation.readFromNBT(compound);
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Block(net.minecraft.block.Block) BlockPipe(gregtech.api.pipenet.block.BlockPipe)

Aggregations

BlockPipe (gregtech.api.pipenet.block.BlockPipe)8 Block (net.minecraft.block.Block)5 CCRenderState (codechicken.lib.render.CCRenderState)3 ItemBlockPipe (gregtech.api.pipenet.block.ItemBlockPipe)3 Material (gregtech.api.unification.material.Material)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 EnumFacing (net.minecraft.util.EnumFacing)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 Cuboid6 (codechicken.lib.vec.Cuboid6)1 Matrix4 (codechicken.lib.vec.Matrix4)1 Vector3 (codechicken.lib.vec.Vector3)1 IconTransformation (codechicken.lib.vec.uv.IconTransformation)1 ICoverable (gregtech.api.cover.ICoverable)1 ITieredMetaTileEntity (gregtech.api.metatileentity.ITieredMetaTileEntity)1 MetaTileEntity (gregtech.api.metatileentity.MetaTileEntity)1 BlockMaterialPipe (gregtech.api.pipenet.block.material.BlockMaterialPipe)1 TileEntityMaterialPipeBase (gregtech.api.pipenet.block.material.TileEntityMaterialPipeBase)1 IPipeTile (gregtech.api.pipenet.tile.IPipeTile)1 CubeRendererState (gregtech.client.renderer.CubeRendererState)1 ItemBlock (net.minecraft.item.ItemBlock)1