use of codechicken.lib.render.pipeline.IVertexOperation in project GregTech by GregTechCE.
the class CableRenderer 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);
IVertexOperation[] pipeline = { new Translation(pos) };
BlockCable blockCable = (BlockCable) state.getBlock();
TileEntityCable tileEntityCable = (TileEntityCable) blockCable.getPipeTileEntity(world, pos);
if (tileEntityCable == null)
return false;
int paintingColor = tileEntityCable.getInsulationColor();
int connectedSidesMask = blockCable.getActualConnections(tileEntityCable, world);
Insulation insulation = tileEntityCable.getPipeType();
Material material = tileEntityCable.getPipeMaterial();
if (insulation != null && material != null) {
BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer();
if (renderLayer == BlockRenderLayer.CUTOUT) {
renderCableBlock(material, insulation, paintingColor, renderState, pipeline, connectedSidesMask);
}
ICoverable coverable = tileEntityCable.getCoverableImplementation();
coverable.renderCovers(renderState, new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ()), renderLayer);
}
return true;
}
use of codechicken.lib.render.pipeline.IVertexOperation in project GregTech by GregTechCE.
the class FluidPipeRenderer 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);
BlockFluidPipe blockPipe = ((BlockFluidPipe) state.getBlock());
TileEntityFluidPipe tileEntityPipe = (TileEntityFluidPipe) blockPipe.getPipeTileEntity(world, pos);
if (tileEntityPipe == null) {
return false;
}
FluidPipeType fluidPipeType = tileEntityPipe.getPipeType();
Material pipeMaterial = tileEntityPipe.getPipeMaterial();
int paintingColor = tileEntityPipe.getInsulationColor();
if (fluidPipeType != null && pipeMaterial != null) {
BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer();
if (renderLayer == BlockRenderLayer.CUTOUT) {
int connectedSidesMask = blockPipe.getActualConnections(tileEntityPipe, world);
IVertexOperation[] pipeline = new IVertexOperation[] { new Translation(pos) };
renderPipeBlock(pipeMaterial, fluidPipeType, paintingColor, renderState, pipeline, connectedSidesMask);
}
ICoverable coverable = tileEntityPipe.getCoverableImplementation();
coverable.renderCovers(renderState, new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ()), renderLayer);
}
return true;
}
use of codechicken.lib.render.pipeline.IVertexOperation in project GregTech by GregTechCE.
the class FluidPipeRenderer method renderPipeBlock.
public boolean renderPipeBlock(Material material, FluidPipeType pipeType, int insulationColor, CCRenderState state, IVertexOperation[] pipeline, int connectMask) {
int pipeColor = GTUtility.convertRGBtoOpaqueRGBA_CL(getPipeColor(material, insulationColor));
ColourMultiplier multiplier = new ColourMultiplier(pipeColor);
PipeTextureInfo textureInfo = this.pipeTextures.get(pipeType);
PipeModelInfo modelInfo = this.pipeModels.get(pipeType);
IVertexOperation[] openingTexture = ArrayUtils.addAll(pipeline, new IconTransformation(textureInfo.inTexture), multiplier);
IVertexOperation[] sideTexture = ArrayUtils.addAll(pipeline, new IconTransformation(textureInfo.sideTexture), multiplier);
int sidedConnMask = connectMask & 0b111111;
CCModel fullBlockModel = null;
if (sidedConnMask == 0b000011) {
fullBlockModel = modelInfo.fullBlockModels[0];
} else if (sidedConnMask == 0b001100) {
fullBlockModel = modelInfo.fullBlockModels[1];
} else if (sidedConnMask == 0b110000) {
fullBlockModel = modelInfo.fullBlockModels[2];
}
if (fullBlockModel != null) {
state.setPipeline(fullBlockModel, 0, fullBlockModel.verts.length, sideTexture);
state.render();
return true;
}
Cuboid6 centerCuboid = BlockFluidPipe.getSideBox(null, pipeType.getThickness());
state.setPipeline(openingTexture);
BlockRenderer.renderCuboid(state, centerCuboid, 0);
for (EnumFacing side : EnumFacing.VALUES) {
if ((connectMask & 1 << side.getIndex()) > 0) {
CCModel model = modelInfo.connectionModels[side.getIndex()];
state.setPipeline(model, 0, model.verts.length, sideTexture);
state.render();
}
}
return true;
}
use of codechicken.lib.render.pipeline.IVertexOperation in project GregTech by GregTechCE.
the class StoneRenderer method renderBlock.
@Override
public boolean renderBlock(IBlockAccess world, BlockPos pos, IBlockState state, BufferBuilder buffer) {
// otherwise, we are in solid rendering layer and render primary stone
CCRenderState renderState = CCRenderState.instance();
renderState.reset();
renderState.bind(buffer);
Matrix4 translation = new Matrix4();
translation.translate(pos.getX(), pos.getY(), pos.getZ());
TextureAtlasSprite stoneSprite = TextureUtils.getBlockTexture("stone");
Material material = ((BlockSurfaceRock) state.getBlock()).getStoneMaterial(world, pos, state);
int renderingColor = GTUtility.convertRGBtoOpaqueRGBA_CL(material.materialRGB);
IVertexOperation[] operations = new IVertexOperation[] { new IconTransformation(stoneSprite), new ColourMultiplier(renderingColor), new TransformationList(translation) };
if (world != null) {
renderState.setBrightness(world, pos);
}
renderState.setPipeline(operations);
CCModel actualModel = getActualModel(world, pos);
renderState.setModel(actualModel);
renderState.render();
return true;
}
use of codechicken.lib.render.pipeline.IVertexOperation in project GregTech by GregTechCE.
the class MetaTileEntity method renderMetaTileEntity.
/**
* Renders this meta tile entity
* Note that you shouldn't refer to world-related information in this method, because it
* will be called on ItemStacks too
* @param renderState render state (either chunk batched or item)
* @param pipeline default set of pipeline transformations
*/
@SideOnly(Side.CLIENT)
public void renderMetaTileEntity(CCRenderState renderState, IVertexOperation[] pipeline) {
TextureAtlasSprite atlasSprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/stone");
IVertexOperation[] renderPipeline = ArrayUtils.add(pipeline, new ColourMultiplier(paintingColor));
for (EnumFacing face : EnumFacing.VALUES) {
renderFace(renderState, face, Cuboid6.full, atlasSprite, renderPipeline);
}
}
Aggregations