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);
}
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);
}
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;
}
Aggregations