Search in sources :

Example 6 with Matrix4

use of codechicken.lib.vec.Matrix4 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;
}
Also used : IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) ICoverable(gregtech.api.cover.ICoverable) Translation(codechicken.lib.vec.Translation) ItemBlockFluidPipe(gregtech.common.pipelike.fluidpipe.ItemBlockFluidPipe) BlockFluidPipe(gregtech.common.pipelike.fluidpipe.BlockFluidPipe) FluidPipeType(gregtech.common.pipelike.fluidpipe.FluidPipeType) Material(gregtech.api.unification.material.type.Material) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) CCRenderState(codechicken.lib.render.CCRenderState) TileEntityFluidPipe(gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipe) Matrix4(codechicken.lib.vec.Matrix4)

Example 7 with Matrix4

use of codechicken.lib.vec.Matrix4 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;
}
Also used : IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) BlockSurfaceRock(gregtech.common.blocks.surfacerock.BlockSurfaceRock) Material(gregtech.api.unification.material.type.Material) CCRenderState(codechicken.lib.render.CCRenderState) TransformationList(codechicken.lib.vec.TransformationList) Matrix4(codechicken.lib.vec.Matrix4) CCModel(codechicken.lib.render.CCModel) IconTransformation(codechicken.lib.vec.uv.IconTransformation) ColourMultiplier(codechicken.lib.render.pipeline.ColourMultiplier)

Example 8 with Matrix4

use of codechicken.lib.vec.Matrix4 in project GregTech by GregTechCE.

the class MetaTileEntityPrimitiveBlastFurnace method renderMetaTileEntity.

@Override
public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) {
    super.renderMetaTileEntity(renderState, translation, pipeline);
    Textures.PRIMITIVE_BLAST_FURNACE_OVERLAY.render(renderState, translation, pipeline, getFrontFacing(), isActive());
    if (isActive() && isStructureFormed()) {
        EnumFacing back = getFrontFacing().getOpposite();
        Matrix4 offset = translation.copy().translate(back.getXOffset(), -0.3, back.getZOffset());
        TextureAtlasSprite sprite = TextureUtils.getBlockTexture("lava_still");
        renderState.brightness = 0xF000F0;
        renderState.colour = 0xFFFFFFFF;
        Textures.renderFace(renderState, offset, new IVertexOperation[0], EnumFacing.UP, Cuboid6.full, sprite);
    }
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EnumFacing(net.minecraft.util.EnumFacing) Matrix4(codechicken.lib.vec.Matrix4)

Example 9 with Matrix4

use of codechicken.lib.vec.Matrix4 in project GregTech by GregTechCE.

the class FacadeRenderer method renderItemCover.

public static void renderItemCover(CCRenderState ccrs, int side, ItemStack renderStack, Cuboid6 bounds) {
    Minecraft minecraft = Minecraft.getMinecraft();
    RenderItem renderItem = minecraft.getRenderItem();
    IBakedModel model = renderItem.getItemModelWithOverrides(renderStack, null, null);
    IBlockState state = FacadeHelper.lookupBlockForItem(renderStack);
    String cacheKey = state.getBlock().getRegistryName() + "|" + state.getBlock().getMetaFromState(state);
    List<CCQuad> renderQuads = itemQuadCache.getIfPresent(cacheKey);
    if (renderQuads == null) {
        List<BakedQuad> quads = new ArrayList<>(model.getQuads(null, null, 0));
        for (EnumFacing face : EnumFacing.VALUES) {
            quads.addAll(model.getQuads(null, face, 0));
        }
        renderQuads = applyItemTint(sliceQuads(CCQuad.fromArray(quads), side, bounds), renderStack);
        itemQuadCache.put(cacheKey, renderQuads);
    }
    AdvCCRSConsumer consumer = new AdvCCRSConsumer(ccrs);
    consumer.setTranslation(new Matrix4().translate(Vector3.center.copy().subtract(bounds.center())).scale(1.05, 1.05, 1.05));
    for (CCQuad quad : renderQuads) {
        quad.pipe(consumer);
    }
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) IBlockState(net.minecraft.block.state.IBlockState) EnumFacing(net.minecraft.util.EnumFacing) ArrayList(java.util.ArrayList) CCQuad(codechicken.lib.render.CCQuad) Minecraft(net.minecraft.client.Minecraft) Matrix4(codechicken.lib.vec.Matrix4) RenderItem(net.minecraft.client.renderer.RenderItem) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel)

Example 10 with Matrix4

use of codechicken.lib.vec.Matrix4 in project GregTech by GregTechCE.

the class MetaTileEntityRenderer method renderItem.

@Override
public void renderItem(ItemStack rawStack, TransformType transformType) {
    ItemStack stack = ModCompatibility.getRealItemStack(rawStack);
    if (!(stack.getItem() instanceof MachineItemBlock)) {
        return;
    }
    MetaTileEntity metaTileEntity = MachineItemBlock.getMetaTileEntity(stack);
    if (metaTileEntity == null) {
        return;
    }
    GlStateManager.enableBlend();
    CCRenderState renderState = CCRenderState.instance();
    renderState.reset();
    renderState.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
    metaTileEntity.setRenderContextStack(stack);
    metaTileEntity.renderMetaTileEntity(renderState, new Matrix4(), new IVertexOperation[0]);
    if (metaTileEntity instanceof IFastRenderMetaTileEntity) {
        ((IFastRenderMetaTileEntity) metaTileEntity).renderMetaTileEntityFast(renderState, new Matrix4(), 0.0f);
    }
    metaTileEntity.setRenderContextStack(null);
    renderState.draw();
    if (metaTileEntity instanceof IRenderMetaTileEntity) {
        ((IRenderMetaTileEntity) metaTileEntity).renderMetaTileEntityDynamic(0.0, 0.0, 0.0, 0.0f);
    }
    GlStateManager.disableBlend();
}
Also used : MachineItemBlock(gregtech.api.block.machines.MachineItemBlock) IRenderMetaTileEntity(gregtech.api.metatileentity.IRenderMetaTileEntity) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) IFastRenderMetaTileEntity(gregtech.api.metatileentity.IFastRenderMetaTileEntity) IFastRenderMetaTileEntity(gregtech.api.metatileentity.IFastRenderMetaTileEntity) ItemStack(net.minecraft.item.ItemStack) CCRenderState(codechicken.lib.render.CCRenderState) IRenderMetaTileEntity(gregtech.api.metatileentity.IRenderMetaTileEntity) Matrix4(codechicken.lib.vec.Matrix4)

Aggregations

Matrix4 (codechicken.lib.vec.Matrix4)13 CCRenderState (codechicken.lib.render.CCRenderState)9 IVertexOperation (codechicken.lib.render.pipeline.IVertexOperation)6 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)5 EnumFacing (net.minecraft.util.EnumFacing)5 IFastRenderMetaTileEntity (gregtech.api.metatileentity.IFastRenderMetaTileEntity)4 BlockRenderLayer (net.minecraft.util.BlockRenderLayer)4 Translation (codechicken.lib.vec.Translation)3 ICoverable (gregtech.api.cover.ICoverable)3 IRenderMetaTileEntity (gregtech.api.metatileentity.IRenderMetaTileEntity)3 MetaTileEntity (gregtech.api.metatileentity.MetaTileEntity)3 Material (gregtech.api.unification.material.type.Material)3 ColourMultiplier (codechicken.lib.render.pipeline.ColourMultiplier)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 CCModel (codechicken.lib.render.CCModel)1 CCQuad (codechicken.lib.render.CCQuad)1 TransformationList (codechicken.lib.vec.TransformationList)1 IconTransformation (codechicken.lib.vec.uv.IconTransformation)1 MachineItemBlock (gregtech.api.block.machines.MachineItemBlock)1 BlockSurfaceRock (gregtech.common.blocks.surfacerock.BlockSurfaceRock)1