Search in sources :

Example 1 with CubeRendererState

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;
}
Also used : IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EnumFacing(net.minecraft.util.EnumFacing) Matrix4(codechicken.lib.vec.Matrix4) CubeRendererState(gregtech.client.renderer.CubeRendererState) TextureMap(net.minecraft.client.renderer.texture.TextureMap) Random(java.util.Random) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) IFastRenderMetaTileEntity(gregtech.api.metatileentity.IFastRenderMetaTileEntity) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) CCRenderState(codechicken.lib.render.CCRenderState)

Example 2 with CubeRendererState

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);
    }
}
Also used : ColourOperation(gregtech.client.renderer.cclop.ColourOperation) CubeRendererState(gregtech.client.renderer.CubeRendererState) LightMapOperation(gregtech.client.renderer.cclop.LightMapOperation) EnumFacing(net.minecraft.util.EnumFacing) Matrix4(codechicken.lib.vec.Matrix4)

Example 3 with CubeRendererState

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;
}
Also used : ICoverable(gregtech.api.cover.ICoverable) EnumFacing(net.minecraft.util.EnumFacing) Material(gregtech.api.unification.material.Material) BlockPipe(gregtech.api.pipenet.block.BlockPipe) ItemBlockPipe(gregtech.api.pipenet.block.ItemBlockPipe) Matrix4(codechicken.lib.vec.Matrix4) CubeRendererState(gregtech.client.renderer.CubeRendererState) TileEntityMaterialPipeBase(gregtech.api.pipenet.block.material.TileEntityMaterialPipeBase) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) CCRenderState(codechicken.lib.render.CCRenderState)

Example 4 with CubeRendererState

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();
}
Also used : CubeRendererState(gregtech.client.renderer.CubeRendererState) BlockFace(codechicken.lib.render.BlockRenderer.BlockFace) UVTransformationList(codechicken.lib.vec.uv.UVTransformationList) TransformationList(codechicken.lib.vec.TransformationList) UVTransformationList(codechicken.lib.vec.uv.UVTransformationList) UVMirror(gregtech.client.renderer.cclop.UVMirror) IconTransformation(codechicken.lib.vec.uv.IconTransformation) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

CubeRendererState (gregtech.client.renderer.CubeRendererState)4 Matrix4 (codechicken.lib.vec.Matrix4)3 EnumFacing (net.minecraft.util.EnumFacing)3 CCRenderState (codechicken.lib.render.CCRenderState)2 BlockRenderLayer (net.minecraft.util.BlockRenderLayer)2 BlockFace (codechicken.lib.render.BlockRenderer.BlockFace)1 IVertexOperation (codechicken.lib.render.pipeline.IVertexOperation)1 TransformationList (codechicken.lib.vec.TransformationList)1 IconTransformation (codechicken.lib.vec.uv.IconTransformation)1 UVTransformationList (codechicken.lib.vec.uv.UVTransformationList)1 ICoverable (gregtech.api.cover.ICoverable)1 IFastRenderMetaTileEntity (gregtech.api.metatileentity.IFastRenderMetaTileEntity)1 MetaTileEntity (gregtech.api.metatileentity.MetaTileEntity)1 BlockPipe (gregtech.api.pipenet.block.BlockPipe)1 ItemBlockPipe (gregtech.api.pipenet.block.ItemBlockPipe)1 TileEntityMaterialPipeBase (gregtech.api.pipenet.block.material.TileEntityMaterialPipeBase)1 Material (gregtech.api.unification.material.Material)1 ColourOperation (gregtech.client.renderer.cclop.ColourOperation)1 LightMapOperation (gregtech.client.renderer.cclop.LightMapOperation)1 UVMirror (gregtech.client.renderer.cclop.UVMirror)1