Search in sources :

Example 1 with ItemBlockPipe

use of gregtech.api.pipenet.block.ItemBlockPipe in project GregTech by GregTechCEu.

the class PipeRenderer method renderItem.

@Override
public void renderItem(ItemStack rawItemStack, TransformType transformType) {
    ItemStack stack = ModCompatibility.getRealItemStack(rawItemStack);
    if (!(stack.getItem() instanceof ItemBlockPipe)) {
        return;
    }
    CCRenderState renderState = CCRenderState.instance();
    GlStateManager.enableBlend();
    renderState.reset();
    renderState.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
    BlockPipe<?, ?, ?> blockFluidPipe = (BlockPipe<?, ?, ?>) ((ItemBlockPipe<?, ?>) stack.getItem()).getBlock();
    IPipeType<?> pipeType = blockFluidPipe.getItemPipeType(stack);
    Material material = blockFluidPipe instanceof BlockMaterialPipe ? ((BlockMaterialPipe<?, ?, ?>) blockFluidPipe).getItemMaterial(stack) : null;
    if (pipeType != null) {
        // 12 == 0b1100 is North and South connection (index 2 & 3)
        PipeRenderContext renderContext = new PipeRenderContext(12, 0, pipeType.getThickness());
        renderContext.color = GTUtility.convertRGBtoOpaqueRGBA_CL(getPipeColor(material, -1));
        buildRenderer(renderContext, blockFluidPipe, null, pipeType, material);
        renderPipeBlock(renderState, renderContext);
    }
    renderState.draw();
    GlStateManager.disableBlend();
}
Also used : BlockMaterialPipe(gregtech.api.pipenet.block.material.BlockMaterialPipe) ItemBlockPipe(gregtech.api.pipenet.block.ItemBlockPipe) Material(gregtech.api.unification.material.Material) BlockPipe(gregtech.api.pipenet.block.BlockPipe) ItemBlockPipe(gregtech.api.pipenet.block.ItemBlockPipe) ItemStack(net.minecraft.item.ItemStack) CCRenderState(codechicken.lib.render.CCRenderState)

Aggregations

CCRenderState (codechicken.lib.render.CCRenderState)1 BlockPipe (gregtech.api.pipenet.block.BlockPipe)1 ItemBlockPipe (gregtech.api.pipenet.block.ItemBlockPipe)1 BlockMaterialPipe (gregtech.api.pipenet.block.material.BlockMaterialPipe)1 Material (gregtech.api.unification.material.Material)1 ItemStack (net.minecraft.item.ItemStack)1