Java Code Examples for codechicken.lib.render.CCRenderState#setPipeline()

The following examples show how to use codechicken.lib.render.CCRenderState#setPipeline() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetaTileEntityRenderer.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void handleRenderBlockDamage(IBlockAccess world, BlockPos pos, IBlockState state, TextureAtlasSprite sprite, BufferBuilder buffer) {
    MetaTileEntity metaTileEntity = BlockMachine.getMetaTileEntity(world, pos);
    ArrayList<IndexedCuboid6> boundingBox = new ArrayList<>();
    if (metaTileEntity != null) {
        metaTileEntity.addCollisionBoundingBox(boundingBox);
        metaTileEntity.addCoverCollisionBoundingBox(boundingBox);
    }
    CCRenderState renderState = CCRenderState.instance();
    renderState.reset();
    renderState.bind(buffer);
    renderState.setPipeline(new Vector3(new Vec3d(pos)).translation(), new IconTransformation(sprite));
    for (Cuboid6 cuboid : boundingBox) {
        BlockRenderer.renderCuboid(renderState, cuboid, 0);
    }
}
 
Example 2
Source File: FluidPipeRenderer.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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));
    BlockFluidPipe blockFluidPipe = (BlockFluidPipe) state.getBlock();
    IPipeTile<FluidPipeType, FluidPipeProperties> tileEntityPipe = blockFluidPipe.getPipeTileEntity(world, pos);
    if (tileEntityPipe == null) {
        return;
    }
    FluidPipeType fluidPipeType = tileEntityPipe.getPipeType();
    if (fluidPipeType == null) {
        return;
    }
    float thickness = fluidPipeType.getThickness();
    int connectedSidesMask = blockFluidPipe.getActualConnections(tileEntityPipe, world);
    Cuboid6 baseBox = BlockFluidPipe.getSideBox(null, thickness);
    BlockRenderer.renderCuboid(renderState, baseBox, 0);
    for (EnumFacing renderSide : EnumFacing.VALUES) {
        if ((connectedSidesMask & (1 << renderSide.getIndex())) > 0) {
            Cuboid6 sideBox = BlockFluidPipe.getSideBox(renderSide, thickness);
            BlockRenderer.renderCuboid(renderState, sideBox, 0);
        }
    }
}
 
Example 3
Source File: InvPipeRenderer.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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));
    BlockInventoryPipe block = (BlockInventoryPipe) state.getBlock();
    TileEntityInventoryPipe tileEntity = (TileEntityInventoryPipe) block.getPipeTileEntity(world, pos);
    if (tileEntity == null) {
        return;
    }
    InventoryPipeType pipeType = tileEntity.getPipeType();
    if (pipeType == null) {
        return;
    }
    float thickness = pipeType.getThickness();
    int connectedSidesMask = block.getActualConnections(tileEntity, world);
    Cuboid6 baseBox = BlockPipe.getSideBox(null, thickness);
    BlockRenderer.renderCuboid(renderState, baseBox, 0);
    for (EnumFacing renderSide : EnumFacing.VALUES) {
        if ((connectedSidesMask & (1 << renderSide.getIndex())) > 0) {
            Cuboid6 sideBox = BlockPipe.getSideBox(renderSide, thickness);
            BlockRenderer.renderCuboid(renderState, sideBox, 0);
        }
    }
}
 
Example 4
Source File: CableRenderer.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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));
    BlockCable blockCable = (BlockCable) state.getBlock();
    IPipeTile<Insulation, WireProperties> tileEntityCable = blockCable.getPipeTileEntity(world, pos);
    if (tileEntityCable == null) {
        return;
    }
    Insulation insulation = tileEntityCable.getPipeType();
    if (insulation == null) {
        return;
    }
    float thickness = insulation.getThickness();
    int connectedSidesMask = blockCable.getActualConnections(tileEntityCable, world);
    Cuboid6 baseBox = BlockCable.getSideBox(null, thickness);
    BlockRenderer.renderCuboid(renderState, baseBox, 0);
    for (EnumFacing renderSide : EnumFacing.VALUES) {
        if ((connectedSidesMask & (1 << renderSide.getIndex())) > 0) {
            Cuboid6 sideBox = BlockCable.getSideBox(renderSide, thickness);
            BlockRenderer.renderCuboid(renderState, sideBox, 0);
        }
    }
}
 
Example 5
Source File: StoneRenderer.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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;
}
 
Example 6
Source File: Textures.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
public static void renderFace(CCRenderState renderState, Matrix4 translation, IVertexOperation[] ops, EnumFacing face, Cuboid6 bounds, TextureAtlasSprite sprite) {
    BlockFace blockFace = blockFaces.get();
    blockFace.loadCuboidFace(bounds, face.getIndex());
    renderState.setPipeline(blockFace, 0, blockFace.verts.length,
        ArrayUtils.addAll(ops, new TransformationList(translation), new IconTransformation(sprite)));
    renderState.render();
}
 
Example 7
Source File: StoneRenderer.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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));
    Cuboid6 baseBox = new Cuboid6(state.getBoundingBox(world, pos));
    BlockRenderer.renderCuboid(renderState, baseBox, 0);
}
 
Example 8
Source File: WorldSceneRenderer.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Renders scene on given coordinates with given width and height, and RGB background color
 * Note that this will ignore any transformations applied currently to projection/view matrix,
 * so specified coordinates are scaled MC gui coordinates.
 * It will return matrices of projection and view in previous state after rendering
 */
public void render(int x, int y, int width, int height, int backgroundColor) {
    Vec2f mousePosition = setupCamera(x, y, width, height, backgroundColor);
    if (renderCallback != null) {
        renderCallback.preRenderScene(this);
    }
    Minecraft minecraft = Minecraft.getMinecraft();
    minecraft.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    BlockRendererDispatcher dispatcher = minecraft.getBlockRendererDispatcher();
    BlockRenderLayer oldRenderLayer = MinecraftForgeClient.getRenderLayer();
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferBuilder = tessellator.getBuffer();

    bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    for (BlockPos pos : renderedBlocks) {
        if (renderFilter != null && !renderFilter.test(pos))
            continue; //do not render if position is skipped
        IBlockState blockState = world.getBlockState(pos);
        for(BlockRenderLayer renderLayer : BlockRenderLayer.values()) {
            if (!blockState.getBlock().canRenderInLayer(blockState, renderLayer)) continue;
            ForgeHooksClient.setRenderLayer(renderLayer);
            dispatcher.renderBlock(blockState, pos, world, bufferBuilder);
        }
    }
    tessellator.draw();
    ForgeHooksClient.setRenderLayer(oldRenderLayer);

    if (mousePosition != null) {
        this.lastHitBlock = handleMouseHit(mousePosition);
    } else {
        this.lastHitBlock = null;
    }

    if (lastHitBlock != null) {
        GlStateManager.disableTexture2D();
        CCRenderState renderState = CCRenderState.instance();
        renderState.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR, tessellator.getBuffer());
        ColourMultiplier multiplier = new ColourMultiplier(0);
        renderState.setPipeline(new Translation(lastHitBlock), multiplier);
        BlockFace blockFace = new BlockFace();
        renderState.setModel(blockFace);
        for (EnumFacing renderSide : EnumFacing.VALUES) {
            float diffuse = LightUtil.diffuseLight(renderSide);
            int color = (int) (255 * diffuse);
            multiplier.colour = RenderUtil.packColor(color, color, color, 100);
            blockFace.loadCuboidFace(Cuboid6.full, renderSide.getIndex());
            renderState.render();
        }
        renderState.draw();
        GlStateManager.enableTexture2D();
    }

    resetCamera();
}
 
Example 9
Source File: CableRenderer.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
private static void renderCableSide(CCRenderState renderState, IVertexOperation[] pipeline, EnumFacing side, Cuboid6 cuboid6) {
    BlockFace blockFace = blockFaces.get();
    blockFace.loadCuboidFace(cuboid6, side.getIndex());
    renderState.setPipeline(blockFace, 0, blockFace.verts.length, pipeline);
    renderState.render();
}