Search in sources :

Example 6 with StandardTank

use of mods.railcraft.common.fluids.tanks.StandardTank 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)

Example 7 with StandardTank

use of mods.railcraft.common.fluids.tanks.StandardTank in project Railcraft by Railcraft.

the class TESRManipulatorFluid method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileFluidManipulator tile, double x, double y, double z, float partialTicks, int destroyStage) {
    StandardTank tank = tile.getTankManager().get(0);
    FluidStack fluidStack = tank.getFluid();
    if (fluidStack != null && fluidStack.amount > 0) {
        OpenGL.glPushAttrib();
        OpenGL.glPushMatrix();
        OpenGL.glTranslatef((float) x + 0.5F, (float) y + 0.06256F * 4, (float) z + 0.5F);
        OpenGL.glScalef(0.95f, 1f, 0.95f);
        OpenGL.glTranslatef(-0.5F, 0, -0.5F);
        float cap = tank.getCapacity();
        float level = Math.min(fluidStack.amount, cap) / cap;
        OpenGL.glEnable(GL11.GL_CULL_FACE);
        OpenGL.glDisable(GL11.GL_LIGHTING);
        //                OpenGL.glEnable(GL11.GL_BLEND);
        //                OpenGL.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        FluidModelRenderer.INSTANCE.renderFluid(fluidStack, Math.min(8, (int) Math.ceil(level * 8F)));
        //                OpenGL.glDisable(GL11.GL_BLEND);
        OpenGL.glEnable(GL11.GL_LIGHTING);
        OpenGL.glPopMatrix();
        OpenGL.glPopAttrib();
    }
    if (tile.getClass() == TileFluidLoader.class) {
        TileFluidLoader loader = (TileFluidLoader) tile;
        OpenGL.glPushMatrix();
        OpenGL.glTranslatef((float) x, (float) y - loader.getPipeLength(), (float) z);
        //            OpenGL.glEnable(GL11.GL_LIGHTING);
        //            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 255F , 255F );
        //            pipe.boundingBox = AABBFactory.start().fromAABB(pipe.boundingBox).setMinY(RenderTools.PIXEL - loader.getPipeLength()).build();
        JSONModelRenderer.INSTANCE.renderModel(PIPE_MODEL);
        OpenGL.glPopMatrix();
    }
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) TileFluidLoader(mods.railcraft.common.blocks.machine.manipulator.TileFluidLoader) StandardTank(mods.railcraft.common.fluids.tanks.StandardTank)

Aggregations

StandardTank (mods.railcraft.common.fluids.tanks.StandardTank)7 FluidStack (net.minecraftforge.fluids.FluidStack)6 TankManager (mods.railcraft.common.fluids.TankManager)2 TileMultiBlock (mods.railcraft.common.blocks.machine.TileMultiBlock)1 TileTankIronValve (mods.railcraft.common.blocks.machine.beta.TileTankIronValve)1 TileFluidLoader (mods.railcraft.common.blocks.machine.manipulator.TileFluidLoader)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 NBTTagList (net.minecraft.nbt.NBTTagList)1 TileEntity (net.minecraft.tileentity.TileEntity)1