Search in sources :

Example 1 with TileEntityMaterialPipeBase

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

the class CableRenderer method getParticleTexture.

@Override
public Pair<TextureAtlasSprite, Integer> getParticleTexture(IPipeTile<?, ?> pipeTile) {
    if (pipeTile == null) {
        return Pair.of(TextureUtils.getMissingSprite(), 0xFFFFFF);
    }
    IPipeType<?> pipeType = pipeTile.getPipeType();
    if (!(pipeType instanceof Insulation)) {
        return Pair.of(TextureUtils.getMissingSprite(), 0xFFFFFF);
    }
    Material material = pipeTile instanceof TileEntityMaterialPipeBase ? ((TileEntityMaterialPipeBase<?, ?>) pipeTile).getPipeMaterial() : null;
    TextureAtlasSprite atlasSprite;
    int particleColor;
    int insulationLevel = ((Insulation) pipeType).insulationLevel;
    if (insulationLevel == -1) {
        atlasSprite = wireTexture;
        particleColor = material == null ? 0xFFFFFF : material.getMaterialRGB();
    } else {
        atlasSprite = insulationTextures[5];
        particleColor = pipeTile.getPaintingColor();
    }
    return Pair.of(atlasSprite, particleColor);
}
Also used : Insulation(gregtech.common.pipelike.cable.Insulation) TileEntityMaterialPipeBase(gregtech.api.pipenet.block.material.TileEntityMaterialPipeBase) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) Material(gregtech.api.unification.material.Material)

Example 2 with TileEntityMaterialPipeBase

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

the class PipeRenderer method getParticleTexture.

public Pair<TextureAtlasSprite, Integer> getParticleTexture(IPipeTile<?, ?> pipeTile) {
    if (pipeTile == null) {
        return Pair.of(TextureUtils.getMissingSprite(), 0xFFFFFF);
    }
    IPipeType<?> pipeType = pipeTile.getPipeType();
    Material material = pipeTile instanceof TileEntityMaterialPipeBase ? ((TileEntityMaterialPipeBase<?, ?>) pipeTile).getPipeMaterial() : null;
    if (pipeType == null) {
        return Pair.of(TextureUtils.getMissingSprite(), 0xFFFFFF);
    }
    TextureAtlasSprite atlasSprite = getParticleTexture(pipeType, material);
    int pipeColor = getPipeColor(material, pipeTile.getPaintingColor());
    return Pair.of(atlasSprite, pipeColor);
}
Also used : TileEntityMaterialPipeBase(gregtech.api.pipenet.block.material.TileEntityMaterialPipeBase) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) Material(gregtech.api.unification.material.Material)

Example 3 with TileEntityMaterialPipeBase

use of gregtech.api.pipenet.block.material.TileEntityMaterialPipeBase 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)

Aggregations

TileEntityMaterialPipeBase (gregtech.api.pipenet.block.material.TileEntityMaterialPipeBase)3 Material (gregtech.api.unification.material.Material)3 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 CCRenderState (codechicken.lib.render.CCRenderState)1 Matrix4 (codechicken.lib.vec.Matrix4)1 ICoverable (gregtech.api.cover.ICoverable)1 BlockPipe (gregtech.api.pipenet.block.BlockPipe)1 ItemBlockPipe (gregtech.api.pipenet.block.ItemBlockPipe)1 CubeRendererState (gregtech.client.renderer.CubeRendererState)1 Insulation (gregtech.common.pipelike.cable.Insulation)1 BlockRenderLayer (net.minecraft.util.BlockRenderLayer)1 EnumFacing (net.minecraft.util.EnumFacing)1