Search in sources :

Example 1 with RenderInfo

use of logisticspipes.renderer.CustomBlockRenderer.RenderInfo in project LogisticsPipes by RS485.

the class LogisticsRenderPipe method getDisplayFluidLists.

// BC copy
private DisplayFluidList getDisplayFluidLists(int liquidId, int skylight, int blocklight, int flags, World world) {
    int finalBlockLight = Math.max(flags & 31, blocklight);
    int listId = (liquidId & 0x3FFFF) << 13 | (flags & 0xE0 | finalBlockLight) << 5 | (skylight & 31);
    if (displayFluidLists.containsItem(listId)) {
        return (DisplayFluidList) displayFluidLists.lookup(listId);
    }
    Fluid fluid = FluidRegistry.getFluid(liquidId);
    if (fluid == null) {
        return null;
    }
    DisplayFluidList d = new DisplayFluidList();
    displayFluidLists.addKey(listId, d);
    RenderInfo block = new RenderInfo();
    if (fluid.getBlock() != null) {
        block.baseBlock = fluid.getBlock();
    } else {
        block.baseBlock = Blocks.water;
    }
    block.texture = fluid.getStillIcon();
    block.brightness = skylight << 16 | finalBlockLight;
    float size = LPConstants.BC_PIPE_MAX_POS - LPConstants.BC_PIPE_MIN_POS;
    for (int s = 0; s < LogisticsRenderPipe.LIQUID_STAGES; ++s) {
        float ratio = (float) s / (float) LogisticsRenderPipe.LIQUID_STAGES;
        // SIDE HORIZONTAL
        d.sideHorizontal[s] = GLAllocation.generateDisplayLists(1);
        GL11.glNewList(d.sideHorizontal[s], GL11.GL_COMPILE);
        block.minX = 0.0F;
        block.minZ = LPConstants.BC_PIPE_MIN_POS + 0.01F;
        block.maxX = block.minX + size / 2F + 0.01F;
        block.maxZ = block.minZ + size - 0.02F;
        block.minY = LPConstants.BC_PIPE_MIN_POS + 0.01F;
        block.maxY = block.minY + (size - 0.02F) * ratio;
        CustomBlockRenderer.INSTANCE.renderBlock(block, world, 0, 0, 0, false, true);
        GL11.glEndList();
        // SIDE VERTICAL
        d.sideVertical[s] = GLAllocation.generateDisplayLists(1);
        GL11.glNewList(d.sideVertical[s], GL11.GL_COMPILE);
        block.minY = LPConstants.BC_PIPE_MAX_POS - 0.01;
        block.maxY = 1;
        block.minX = 0.5 - (size / 2 - 0.01) * ratio;
        block.maxX = 0.5 + (size / 2 - 0.01) * ratio;
        block.minZ = 0.5 - (size / 2 - 0.01) * ratio;
        block.maxZ = 0.5 + (size / 2 - 0.01) * ratio;
        CustomBlockRenderer.INSTANCE.renderBlock(block, world, 0, 0, 0, false, true);
        GL11.glEndList();
        // CENTER HORIZONTAL
        d.centerHorizontal[s] = GLAllocation.generateDisplayLists(1);
        GL11.glNewList(d.centerHorizontal[s], GL11.GL_COMPILE);
        block.minX = LPConstants.BC_PIPE_MIN_POS + 0.01;
        block.minZ = LPConstants.BC_PIPE_MIN_POS + 0.01;
        block.maxX = block.minX + size - 0.02;
        block.maxZ = block.minZ + size - 0.02;
        block.minY = LPConstants.BC_PIPE_MIN_POS + 0.01;
        block.maxY = block.minY + (size - 0.02F) * ratio;
        CustomBlockRenderer.INSTANCE.renderBlock(block, world, 0, 0, 0, false, true);
        GL11.glEndList();
        // CENTER VERTICAL
        d.centerVertical[s] = GLAllocation.generateDisplayLists(1);
        GL11.glNewList(d.centerVertical[s], GL11.GL_COMPILE);
        block.minY = LPConstants.BC_PIPE_MIN_POS + 0.01;
        block.maxY = LPConstants.BC_PIPE_MAX_POS - 0.01;
        block.minX = 0.5 - (size / 2 - 0.02) * ratio;
        block.maxX = 0.5 + (size / 2 - 0.02) * ratio;
        block.minZ = 0.5 - (size / 2 - 0.02) * ratio;
        block.maxZ = 0.5 + (size / 2 - 0.02) * ratio;
        CustomBlockRenderer.INSTANCE.renderBlock(block, world, 0, 0, 0, false, true);
        GL11.glEndList();
    }
    return d;
}
Also used : Fluid(net.minecraftforge.fluids.Fluid) RenderInfo(logisticspipes.renderer.CustomBlockRenderer.RenderInfo)

Example 2 with RenderInfo

use of logisticspipes.renderer.CustomBlockRenderer.RenderInfo in project LogisticsPipes by RS485.

the class LogisticsNewPipeItemBoxRenderer method getRenderListFor.

private int getRenderListFor(FluidStack fluid) {
    FluidIdentifier ident = FluidIdentifier.get(fluid);
    int[] array = LogisticsNewPipeItemBoxRenderer.renderLists.get(fluid);
    if (array == null) {
        array = new int[LogisticsNewPipeItemBoxRenderer.RENDER_SIZE];
        LogisticsNewPipeItemBoxRenderer.renderLists.put(ident, array);
    }
    int pos = Math.min((int) (((Math.min(fluid.amount, 5000) * 1.0F) * LogisticsNewPipeItemBoxRenderer.RENDER_SIZE) / 5000), LogisticsNewPipeItemBoxRenderer.RENDER_SIZE - 1);
    if (array[pos] != 0) {
        return array[pos];
    }
    RenderInfo block = new RenderInfo();
    block.baseBlock = fluid.getFluid().getBlock();
    block.texture = fluid.getFluid().getStillIcon();
    float ratio = pos * 1.0F / (LogisticsNewPipeItemBoxRenderer.RENDER_SIZE - 1);
    // CENTER HORIZONTAL
    array[pos] = GLAllocation.generateDisplayLists(1);
    GL11.glNewList(array[pos], 4864);
    block.minX = 0.32;
    block.maxX = 0.68;
    block.minY = 0.32;
    block.maxY = 0.32 + (0.68 - 0.32) * ratio;
    block.minZ = 0.32;
    block.maxZ = 0.68;
    CustomBlockRenderer.INSTANCE.renderBlock(block, Minecraft.getMinecraft().theWorld, 0, 0, 0, false, true);
    GL11.glEndList();
    return array[pos];
}
Also used : FluidIdentifier(logisticspipes.utils.FluidIdentifier) RenderInfo(logisticspipes.renderer.CustomBlockRenderer.RenderInfo)

Aggregations

RenderInfo (logisticspipes.renderer.CustomBlockRenderer.RenderInfo)2 FluidIdentifier (logisticspipes.utils.FluidIdentifier)1 Fluid (net.minecraftforge.fluids.Fluid)1