use of gregtech.client.renderer.CubeRendererState in project GregTech by GregTechCEu.
the class MetaTileEntityRenderer method renderBlock.
@Override
public boolean renderBlock(IBlockAccess world, BlockPos pos, IBlockState state, BufferBuilder buffer) {
MetaTileEntity metaTileEntity = BlockMachine.getMetaTileEntity(world, pos);
if (metaTileEntity == null) {
return false;
}
CCRenderState renderState = CCRenderState.instance();
renderState.reset();
renderState.bind(buffer);
Matrix4 translation = new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ());
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 (metaTileEntity.canRenderInLayer(renderLayer)) {
renderState.lightMatrix.locate(world, pos);
IVertexOperation[] pipeline = new IVertexOperation[] { renderState.lightMatrix };
metaTileEntity.renderMetaTileEntity(renderState, translation.copy(), pipeline);
}
metaTileEntity.renderCovers(renderState, translation.copy(), renderLayer);
if (metaTileEntity.isFragile() && renderLayer == BlockRenderLayer.CUTOUT) {
TextureMap textureMap = Minecraft.getMinecraft().getTextureMapBlocks();
Random posRand = new Random(MathHelper.getPositionRandom(pos));
int destroyStage = posRand.nextInt(10);
TextureAtlasSprite atlasSprite = textureMap.getAtlasSprite("minecraft:blocks/destroy_stage_" + destroyStage);
for (EnumFacing face : EnumFacing.VALUES) {
Textures.renderFace(renderState, translation, new IVertexOperation[0], face, Cuboid6.full, atlasSprite, null);
}
}
Textures.RENDER_STATE.set(null);
return true;
}
use of gregtech.client.renderer.CubeRendererState in project GregTech by GregTechCEu.
the class MetaTileEntityPrimitiveBlastFurnace method renderMetaTileEntity.
@Override
public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) {
super.renderMetaTileEntity(renderState, translation, pipeline);
getFrontOverlay().renderOrientedState(renderState, translation, pipeline, getFrontFacing(), recipeMapWorkable.isActive(), recipeMapWorkable.isWorkingEnabled());
if (recipeMapWorkable.isActive() && isStructureFormed()) {
EnumFacing back = getFrontFacing().getOpposite();
Matrix4 offset = translation.copy().translate(back.getXOffset(), -0.3, back.getZOffset());
CubeRendererState op = Textures.RENDER_STATE.get();
Textures.RENDER_STATE.set(new CubeRendererState(op.layer, CubeRendererState.PASS_MASK, op.world));
Textures.renderFace(renderState, offset, ArrayUtils.addAll(pipeline, new LightMapOperation(240, 240), new ColourOperation(0xFFFFFFFF)), EnumFacing.UP, Cuboid6.full, TextureUtils.getBlockTexture("lava_still"), BloomEffectUtil.getRealBloomLayer());
Textures.RENDER_STATE.set(op);
}
}
use of gregtech.client.renderer.CubeRendererState 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.client.renderer.CubeRendererState in project GregTech by GregTechCEu.
the class Textures method renderFace.
@SideOnly(Side.CLIENT)
public static void renderFace(CCRenderState renderState, Matrix4 translation, IVertexOperation[] ops, EnumFacing face, Cuboid6 bounds, TextureAtlasSprite sprite, BlockRenderLayer layer) {
CubeRendererState op = RENDER_STATE.get();
if (layer != null && op != null && op.layer != null && (op.layer != layer || !op.shouldSideBeRendered(face, bounds))) {
return;
}
BlockFace blockFace = blockFaces.get();
blockFace.loadCuboidFace(bounds, face.getIndex());
UVTransformationList uvList = new UVTransformationList(new IconTransformation(sprite));
if (face.getIndex() == 0) {
uvList.prepend(new UVMirror(0, 0, bounds.min.z, bounds.max.z));
}
renderState.setPipeline(blockFace, 0, blockFace.verts.length, ArrayUtils.addAll(ops, new TransformationList(translation), uvList));
renderState.render();
}
Aggregations