Search in sources :

Example 1 with CoverSides

use of logisticspipes.renderer.newpipe.LogisticsNewSolidBlockWorldRenderer.CoverSides in project LogisticsPipes by RS485.

the class LogisticsNewPipeItemRenderer method renderBlockItem.

private void renderBlockItem(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) {
    //don't break other mods' guis when holding a pipe
    GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT);
    //force transparency
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glTranslatef(translateX, translateY, translateZ);
    Block block = LogisticsPipes.LogisticsPipeBlock;
    Tessellator tess = Tessellator.instance;
    BlockRotation rotation = BlockRotation.ZERO;
    tess.startDrawingQuads();
    IIconTransformation icon = SimpleServiceLocator.cclProxy.createIconTransformer(Textures.LOGISTICS_REQUEST_TABLE_NEW);
    //Draw
    LogisticsNewSolidBlockWorldRenderer.block.get(rotation).render(new I3DOperation[] { icon });
    for (CoverSides side : CoverSides.values()) {
        LogisticsNewSolidBlockWorldRenderer.texturePlate_Outer.get(side).get(rotation).render(new I3DOperation[] { icon });
    }
    tess.draw();
    block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    // nicely leave the rendering how it was
    GL11.glPopAttrib();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) CoverSides(logisticspipes.renderer.newpipe.LogisticsNewSolidBlockWorldRenderer.CoverSides) Block(net.minecraft.block.Block) IIconTransformation(logisticspipes.proxy.object3d.interfaces.IIconTransformation) BlockRotation(logisticspipes.renderer.newpipe.LogisticsNewSolidBlockWorldRenderer.BlockRotation)

Example 2 with CoverSides

use of logisticspipes.renderer.newpipe.LogisticsNewSolidBlockWorldRenderer.CoverSides in project LogisticsPipes by RS485.

the class LogisticsNewPipeWorldRenderer method renderWorldBlock.

@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
    Tessellator tess = Tessellator.instance;
    TileEntity tile = world.getTileEntity(x, y, z);
    LogisticsTileGenericPipe pipeTile = (LogisticsTileGenericPipe) tile;
    PipeRenderState renderState = pipeTile.renderState;
    if (pipeTile.pipe instanceof PipeBlockRequestTable) {
        if (LogisticsPipeWorldRenderer.renderPass != 0) {
            return false;
        }
        IIconProvider icons = pipeTile.getPipeIcons();
        if (icons == null) {
            return false;
        }
        if (requestBlock == null || true) {
            requestBlock = new HashMap<>();
            for (BlockRotation rot : BlockRotation.values()) {
                requestBlock.put(rot, LogisticsNewSolidBlockWorldRenderer.block.get(rot).copy().apply(new LPScale(0.999)).apply(new LPTranslation(0.0005, 0.0005, 0.0005)));
            }
        }
        SimpleServiceLocator.cclProxy.getRenderState().reset();
        SimpleServiceLocator.cclProxy.getRenderState().setUseNormals(true);
        SimpleServiceLocator.cclProxy.getRenderState().setAlphaOverride(0xff);
        BlockRotation rotation = BlockRotation.getRotation(((PipeBlockRequestTable) pipeTile.pipe).getRotation());
        int brightness = new DoubleCoordinates(x, y, z).getBlock(world).getMixedBrightnessForBlock(world, x, y, z);
        tess.setColorOpaque_F(1F, 1F, 1F);
        tess.setBrightness(brightness);
        IIconTransformation icon = SimpleServiceLocator.cclProxy.createIconTransformer(Textures.LOGISTICS_REQUEST_TABLE_NEW);
        requestBlock.get(rotation).render(new LPTranslation(x, y, z), icon);
        for (CoverSides side : CoverSides.values()) {
            if (!pipeTile.renderState.pipeConnectionMatrix.isConnected(side.getDir(rotation))) {
                LogisticsNewSolidBlockWorldRenderer.texturePlate_Outer.get(side).get(rotation).render(new LPTranslation(x, y, z), icon);
                LogisticsNewSolidBlockWorldRenderer.texturePlate_Inner.get(side).get(rotation).render(new LPTranslation(x, y, z), icon);
            }
        }
        return true;
    }
    boolean hasRendered = false;
    tess.addTranslation(0.00002F, 0.00002F, 0.00002F);
    renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
        if (pipeTile.tilePart.hasPipePluggable(dir)) {
            IBCPipePluggable p = pipeTile.tilePart.getBCPipePluggable(dir);
            p.renderPluggable(renderer, dir, LogisticsPipeWorldRenderer.renderPass, x, y, z);
            hasRendered = true;
        }
    }
    tess.addTranslation(-0.00002F, -0.00002F, -0.00002F);
    boolean[] solidSides = new boolean[6];
    for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
        DoubleCoordinates pos = CoordinateUtils.add(new DoubleCoordinates((TileEntity) pipeTile), dir);
        Block blockSide = pos.getBlock(pipeTile.getWorldObj());
        if (blockSide != null && blockSide.isSideSolid(pipeTile.getWorldObj(), pos.getXInt(), pos.getYInt(), pos.getZInt(), dir.getOpposite()) && !renderState.pipeConnectionMatrix.isConnected(dir)) {
            solidSides[dir.ordinal()] = true;
        }
    }
    if (!Arrays.equals(solidSides, renderState.solidSidesCache)) {
        renderState.solidSidesCache = solidSides.clone();
        renderState.cachedRenderer = null;
    }
    if (hasRendered) {
        block.setBlockBounds(0, 0, 0, 0, 0, 0);
        renderer.setRenderBoundsFromBlock(block);
        renderer.renderStandardBlock(block, x, y, z);
        block.setBlockBounds(0, 0, 0, 1, 1, 1);
    }
    return hasRendered;
}
Also used : PipeRenderState(logisticspipes.renderer.state.PipeRenderState) Tessellator(net.minecraft.client.renderer.Tessellator) PipeBlockRequestTable(logisticspipes.pipes.PipeBlockRequestTable) IIconProvider(logisticspipes.renderer.IIconProvider) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) TileEntity(net.minecraft.tileentity.TileEntity) LPTranslation(logisticspipes.proxy.object3d.operation.LPTranslation) CoverSides(logisticspipes.renderer.newpipe.LogisticsNewSolidBlockWorldRenderer.CoverSides) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IBCPipePluggable(logisticspipes.proxy.buildcraft.subproxies.IBCPipePluggable) IIconTransformation(logisticspipes.proxy.object3d.interfaces.IIconTransformation) Block(net.minecraft.block.Block) LPScale(logisticspipes.proxy.object3d.operation.LPScale) BlockRotation(logisticspipes.renderer.newpipe.LogisticsNewSolidBlockWorldRenderer.BlockRotation)

Aggregations

IIconTransformation (logisticspipes.proxy.object3d.interfaces.IIconTransformation)2 BlockRotation (logisticspipes.renderer.newpipe.LogisticsNewSolidBlockWorldRenderer.BlockRotation)2 CoverSides (logisticspipes.renderer.newpipe.LogisticsNewSolidBlockWorldRenderer.CoverSides)2 Block (net.minecraft.block.Block)2 Tessellator (net.minecraft.client.renderer.Tessellator)2 PipeBlockRequestTable (logisticspipes.pipes.PipeBlockRequestTable)1 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)1 IBCPipePluggable (logisticspipes.proxy.buildcraft.subproxies.IBCPipePluggable)1 LPScale (logisticspipes.proxy.object3d.operation.LPScale)1 LPTranslation (logisticspipes.proxy.object3d.operation.LPTranslation)1 IIconProvider (logisticspipes.renderer.IIconProvider)1 PipeRenderState (logisticspipes.renderer.state.PipeRenderState)1 TileEntity (net.minecraft.tileentity.TileEntity)1 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)1 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)1