Search in sources :

Example 1 with TileTankIronValve

use of mods.railcraft.common.blocks.machine.beta.TileTankIronValve in project Railcraft by Railcraft.

the class TESRHollowTank method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileTankBase tile, double x, double y, double z, float partialTicks, int destroyStage) {
    if (!tile.isStructureValid())
        return;
    if (tile instanceof TileTankIronValve) {
        TileTankIronValve valve = (TileTankIronValve) tile;
        StandardTank fillTank = valve.getFillTank();
        FluidStack fillStack = fillTank.getFluid();
        if (fillStack != null && fillStack.amount > 0) {
            OpenGL.glPushMatrix();
            if (valve.getPattern().getPatternMarkerChecked(valve.getPatternPosition()) == 'A') {
                prepFillTexture(fillStack);
                int height = getTankHeight(valve);
                float yOffset = height / 2f;
                float vScale = height - 2f;
                OpenGL.glTranslatef((float) x + 0.5F, (float) y + yOffset - height + 1, (float) z + 0.5F);
                OpenGL.glScalef(1f, vScale, 1f);
                draw(fillStack);
            } else if (valve.getPattern().getPatternMarkerChecked(valve.getPatternPosition().add(-1, 0, 0)) == 'A') {
                prepFillTexture(fillStack);
                float vScale = getVerticalScaleSide(valve);
                float yOffset = 0.5f - vScale / 2f + RenderTools.PIXEL * 3;
                OpenGL.glTranslatef((float) x - 0.5F + RenderTools.PIXEL * 5, (float) y + yOffset, (float) z + 0.5F);
                OpenGL.glScalef(1f, vScale, 1f);
                draw(fillStack);
            } else if (valve.getPattern().getPatternMarkerChecked(valve.getPatternPosition().add(1, 0, 0)) == 'A') {
                prepFillTexture(fillStack);
                float vScale = getVerticalScaleSide(valve);
                float yOffset = 0.5f - vScale / 2f + RenderTools.PIXEL * 3;
                OpenGL.glTranslatef((float) x + 1.5F - RenderTools.PIXEL * 5, (float) y + yOffset, (float) z + 0.5F);
                OpenGL.glScalef(1f, vScale, 1f);
                draw(fillStack);
            } else if (valve.getPattern().getPatternMarkerChecked(valve.getPatternPosition().add(0, 0, -1)) == 'A') {
                prepFillTexture(fillStack);
                float vScale = getVerticalScaleSide(valve);
                float yOffset = 0.5f - vScale / 2f + RenderTools.PIXEL * 3;
                OpenGL.glTranslatef((float) x + 0.5F, (float) y + yOffset, (float) z - 0.5F + RenderTools.PIXEL * 5);
                OpenGL.glScalef(1f, vScale, 1f);
                draw(fillStack);
            } else if (valve.getPattern().getPatternMarkerChecked(valve.getPatternPosition().add(0, 0, 1)) == 'A') {
                prepFillTexture(fillStack);
                float vScale = getVerticalScaleSide(valve);
                float yOffset = 0.5f - vScale / 2f + RenderTools.PIXEL * 3;
                OpenGL.glTranslatef((float) x + 0.5F, (float) y + yOffset, (float) z + 1.5F - RenderTools.PIXEL * 5);
                OpenGL.glScalef(1f, vScale, 1f);
                draw(fillStack);
            }
            OpenGL.glPopMatrix();
        }
    }
    if (!tile.isMaster() || tile.isInvalid())
        return;
    int height = getTankHeight(tile);
    float yOffset = height / 2f;
    float vScale = height - 2;
    float hScale = tile.getPattern().getPatternWidthX() - 2;
    TankManager tankManager = tile.getTankManager();
    if (tankManager == null)
        return;
    StandardTank tank = tankManager.get(0);
    if (tank == null)
        return;
    FluidStack fluidStack = tank.getFluid();
    if (fluidStack != null && fluidStack.amount > 0) {
        preGL();
        OpenGL.glTranslatef((float) x + 0.5F, (float) y + yOffset + 0.01f, (float) z + 0.5F);
        OpenGL.glScalef(hScale, vScale, hScale);
        //        OpenGL.glScalef(0.999f, 1, 0.999f);
        int[] displayLists = FluidRenderer.getLiquidDisplayLists(fluidStack);
        OpenGL.glPushMatrix();
        float cap = tank.getCapacity();
        float level = Math.min(fluidStack.amount, cap) / cap;
        bindTexture(FluidRenderer.getFluidSheet(fluidStack));
        FluidRenderer.setColorForFluid(fluidStack);
        OpenGL.glCallList(displayLists[(int) (level * (float) (FluidRenderer.DISPLAY_STAGES - 1))]);
        OpenGL.glPopMatrix();
        postGL();
    }
}
Also used : TileTankIronValve(mods.railcraft.common.blocks.machine.beta.TileTankIronValve) FluidStack(net.minecraftforge.fluids.FluidStack) TankManager(mods.railcraft.common.fluids.TankManager) StandardTank(mods.railcraft.common.fluids.tanks.StandardTank)

Aggregations

TileTankIronValve (mods.railcraft.common.blocks.machine.beta.TileTankIronValve)1 TankManager (mods.railcraft.common.fluids.TankManager)1 StandardTank (mods.railcraft.common.fluids.tanks.StandardTank)1 FluidStack (net.minecraftforge.fluids.FluidStack)1