use of gregtech.api.pipenet.block.BlockPipe in project GregTech by GregTechCEu.
the class PipeRenderer method renderBlock.
@Override
public boolean renderBlock(IBlockAccess world, BlockPos pos, IBlockState state, BufferBuilder buffer) {
CCRenderState renderState = CCRenderState.instance();
renderState.reset();
renderState.bind(buffer);
renderState.setBrightness(world, pos);
BlockPipe<?, ?, ?> blockPipe = (BlockPipe<?, ?, ?>) state.getBlock();
IPipeTile<?, ?> pipeTile = blockPipe.getPipeTileEntity(world, pos);
if (pipeTile == null) {
return false;
}
IPipeType<?> pipeType = pipeTile.getPipeType();
Material pipeMaterial = pipeTile instanceof TileEntityMaterialPipeBase ? ((TileEntityMaterialPipeBase<?, ?>) pipeTile).getPipeMaterial() : null;
int paintingColor = pipeTile.getPaintingColor();
int connectedSidesMap = pipeTile.getVisualConnections();
int blockedConnections = pipeTile.getBlockedConnections();
if (pipeType != null) {
BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer();
boolean[] sideMask = new boolean[EnumFacing.VALUES.length];
for (EnumFacing side : EnumFacing.VALUES) {
sideMask[side.getIndex()] = state.shouldSideBeRendered(world, pos, side);
}
Textures.RENDER_STATE.set(new CubeRendererState(renderLayer, sideMask, world));
if (renderLayer == BlockRenderLayer.CUTOUT) {
renderState.lightMatrix.locate(world, pos);
PipeRenderContext renderContext = new PipeRenderContext(pos, renderState.lightMatrix, connectedSidesMap, blockedConnections, pipeType.getThickness());
renderContext.color = GTUtility.convertRGBtoOpaqueRGBA_CL(getPipeColor(pipeMaterial, paintingColor));
buildRenderer(renderContext, blockPipe, pipeTile, pipeType, pipeMaterial);
renderPipeBlock(renderState, renderContext);
}
ICoverable coverable = pipeTile.getCoverableImplementation();
coverable.renderCovers(renderState, new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ()), renderLayer);
Textures.RENDER_STATE.set(null);
}
return true;
}
use of gregtech.api.pipenet.block.BlockPipe in project GregTech by GregTechCEu.
the class PipeRenderer method renderItem.
@Override
public void renderItem(ItemStack rawItemStack, TransformType transformType) {
ItemStack stack = ModCompatibility.getRealItemStack(rawItemStack);
if (!(stack.getItem() instanceof ItemBlockPipe)) {
return;
}
CCRenderState renderState = CCRenderState.instance();
GlStateManager.enableBlend();
renderState.reset();
renderState.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
BlockPipe<?, ?, ?> blockFluidPipe = (BlockPipe<?, ?, ?>) ((ItemBlockPipe<?, ?>) stack.getItem()).getBlock();
IPipeType<?> pipeType = blockFluidPipe.getItemPipeType(stack);
Material material = blockFluidPipe instanceof BlockMaterialPipe ? ((BlockMaterialPipe<?, ?, ?>) blockFluidPipe).getItemMaterial(stack) : null;
if (pipeType != null) {
// 12 == 0b1100 is North and South connection (index 2 & 3)
PipeRenderContext renderContext = new PipeRenderContext(12, 0, pipeType.getThickness());
renderContext.color = GTUtility.convertRGBtoOpaqueRGBA_CL(getPipeColor(material, -1));
buildRenderer(renderContext, blockFluidPipe, null, pipeType, material);
renderPipeBlock(renderState, renderContext);
}
renderState.draw();
GlStateManager.disableBlend();
}
use of gregtech.api.pipenet.block.BlockPipe in project GregTech by GregTechCEu.
the class PipeRenderer method handleRenderBlockDamage.
@Override
public void handleRenderBlockDamage(IBlockAccess world, BlockPos pos, IBlockState state, TextureAtlasSprite sprite, BufferBuilder buffer) {
CCRenderState renderState = CCRenderState.instance();
renderState.reset();
renderState.bind(buffer);
renderState.setPipeline(new Vector3(new Vec3d(pos)).translation(), new IconTransformation(sprite));
BlockPipe<?, ?, ?> blockPipe = (BlockPipe<?, ?, ?>) state.getBlock();
IPipeTile<?, ?> pipeTile = blockPipe.getPipeTileEntity(world, pos);
if (pipeTile == null) {
return;
}
IPipeType<?> pipeType = pipeTile.getPipeType();
if (pipeType == null) {
return;
}
float thickness = pipeType.getThickness();
int connectedSidesMask = pipeTile.getConnections();
Cuboid6 baseBox = BlockItemPipe.getSideBox(null, thickness);
BlockRenderer.renderCuboid(renderState, baseBox, 0);
for (EnumFacing renderSide : EnumFacing.VALUES) {
if ((connectedSidesMask & (1 << renderSide.getIndex())) > 0) {
Cuboid6 sideBox = BlockItemPipe.getSideBox(renderSide, thickness);
BlockRenderer.renderCuboid(renderState, sideBox, 0);
}
}
}
Aggregations