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