Example usage for org.lwjgl.opengl GL11 glTranslated

List of usage examples for org.lwjgl.opengl GL11 glTranslated

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glTranslated.

Prototype

public static native void glTranslated(@NativeType("GLdouble") double x, @NativeType("GLdouble") double y,
        @NativeType("GLdouble") double z);

Source Link

Document

Double version of #glTranslatef Translatef .

Usage

From source file:butchery.client.TubRenderer.java

License:Minecraft Mod Public

public void renderTubModelAt(TileEntityTub entity, double x, double y, double z, float var8) {
    GL11.glPushMatrix();/*  w  w w.  j a v a 2 s.  c o  m*/
    GL11.glTranslated(x - 0.5, y - 0.3125F, z - 0.44);
    GL11.glPushMatrix();
    bindTextureByName(TUB_TEXTURE);
    Model.renderModel(0.0625F);
    Model.renderWater(entity, 0.0625F, x, y, z);
    GL11.glPopMatrix();
    GL11.glPopMatrix();
}

From source file:ccm.burialservices.client.renderers.GraveRenderer.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float tickTime) {
    GraveTE te = (GraveTE) tileentity;//from  ww  w. j a v  a2s  .  c o m

    GL11.glPushMatrix();
    GL11.glTranslated(x, y, z); //Center to block

    ResourceLocation skin = te.getLocationSkin();

    float f5 = 0.9F;
    float f6 = 0.0625F;

    switch (te.getBlockMetadata()) {
    case 0:
        break;
    case 1:
        GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
        GL11.glTranslated(-1, 0, 0);
        break;
    case 2:
        GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F);
        GL11.glTranslated(-1, 0, -1);
        break;
    case 3:
        GL11.glRotatef(-90F, 0.0F, 1.0F, 0.0F);
        GL11.glTranslated(0, 0, -1);
        break;
    }

    GL11.glTranslated(0.5, 0.1d, 0.5);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glScalef(f6, f6, f6);

    Minecraft.getMinecraft().renderEngine.bindTexture(skin);

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F);

    MODEL_BIPED.bipedHead.rotateAngleX = (float) Math.toRadians(15F);
    MODEL_BIPED.bipedHead.render(f5);
    MODEL_BIPED.bipedBody.render(f5);
    MODEL_BIPED.bipedRightArm.render(f5);
    MODEL_BIPED.bipedLeftArm.render(f5);
    MODEL_BIPED.bipedRightLeg.render(f5);
    MODEL_BIPED.bipedLeftLeg.render(f5);

    GL11.glPopMatrix();

    ItemStack is = te.getHolding();
    if (is != null) {
        renderItemHolding(0, te.getBlockMetadata(), is, x, y, z, tickTime);
        if (is.getItem().requiresMultipleRenderPasses()) {
            for (int i = 1; i < is.getItem().getRenderPasses(is.getItemDamage()); i++) {
                renderItemHolding(i, te.getBlockMetadata(), is, x, y, z, tickTime);
            }
        }
    }

    renderSign(x, y, z, tickTime, te.text, te.getBlockMetadata(), is != null);
}

From source file:ccm.burialservices.client.renderers.GraveRenderer.java

License:Open Source License

private void renderSign(double x, double y, double z, float tickTime, String[] signText, int meta,
        boolean renderingItem) {
    if (signText.length == 0)
        return;/*w  ww  .j  a  va2s . c  om*/
    int i = 0;
    for (String line : signText)
        if (!Strings.isNullOrEmpty(line)) {
            i++;
        }
    if (i == 0)
        return;

    GL11.glPushMatrix();
    float f1 = 0.6666667F;
    GL11.glTranslatef((float) x + 0.5F, (float) y + 0.75F * f1, (float) z + 0.5F);
    float f2 = 0.0F;

    switch (meta) {
    case 0:
        break;
    case 1:
        f2 = 90f;
        break;
    case 2:
        f2 = 180f;
        break;
    case 3:
        f2 = -90f;

    }
    GL11.glTranslated(0, -0.3, 0);
    if (renderingItem)
        GL11.glTranslated(0, 0.03, 0);

    GL11.glRotatef(f2, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(-90F, 1.0F, 0.0F, 0.0F);
    GL11.glTranslated(0, -1.2, 0);

    GL11.glTranslatef(0.0F, -0.3125F, -0.4375F);
    GL11.glTranslatef(0f, 0.8F, 0.5f);
    MODEL_SIGN.signStick.showModel = false;

    this.bindTexture(SIGN_TEXTURE);
    GL11.glPushMatrix();
    GL11.glScalef(f1, -f1, -f1);
    MODEL_SIGN.renderSign();
    GL11.glPopMatrix();
    FontRenderer fontrenderer = this.getFontRenderer();
    f2 = 0.016666668F * f1;
    GL11.glTranslatef(0.0F, 0.5F * f1, 0.07F * f1);
    GL11.glScalef(f2, -f2, f2);
    GL11.glNormal3f(0.0F, 0.0F, -1.0F * f2);
    GL11.glDepthMask(false);
    byte b0 = 0;

    for (int j = 0; j < signText.length; ++j) {
        GL11.glPushMatrix();
        String s = signText[j];
        int width = fontrenderer.getStringWidth(s);
        if (width > 95) {
            float f = 1f - ((width) * 0.0015f);
            GL11.glScalef(f, f, f);
        }
        fontrenderer.drawString(s, -width / 2, j * 10 - 20, b0);
        GL11.glPopMatrix();
    }

    GL11.glDepthMask(true);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glPopMatrix();
}

From source file:ccm.burialservices.client.renderers.GraveRenderer.java

License:Open Source License

private static void renderItemHolding(int i, int meta, ItemStack stack, double x, double y, double z,
        float tickTime) {
    Icon icon = stack.getItem().getIcon(stack, i);

    if (icon == null)
        return;/*ww w.ja v  a2  s  .  c  o m*/

    GL11.glPushMatrix();
    GL11.glTranslated(x, y, z); //Center to block

    switch (meta) {
    case 0:
        break;
    case 1:
        GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
        GL11.glTranslated(-1, 0, 0);
        break;
    case 2:
        GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F);
        GL11.glTranslated(-1, 0, -1);
        break;
    case 3:
        GL11.glRotatef(-90F, 0.0F, 1.0F, 0.0F);
        GL11.glTranslated(0, 0, -1);
        break;
    }

    if (stack.getItem() instanceof ItemSword) {
        GL11.glTranslated(0.44, 0.1d, 1.85);
        GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F);
    } else {
        GL11.glTranslated(0.5, 0.1d, 0.5);
    }
    GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F);

    TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
    texturemanager.bindTexture(texturemanager.getResourceLocation(stack.getItemSpriteNumber()));
    Tessellator tessellator = Tessellator.instance;

    GL11.glEnable(GL12.GL_RESCALE_NORMAL);

    GL11.glTranslatef(0.65f, 0.6f, -0.1f); // Center on block
    GL11.glRotatef(135f, 0, 0, 1);

    ItemRenderer.renderItemIn2D(tessellator, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(),
            icon.getIconWidth(), icon.getIconHeight(), 0.06F);

    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
}

From source file:ccm.pay2spawn.util.Helper.java

License:Open Source License

public static void renderPoint(Tessellator tess, int x, int y, int z) {
    GL11.glPushMatrix();//from  ww w.j av a 2  s.com
    GL11.glTranslated(x, y, z);
    GL11.glScalef(1.01f, 1.01f, 1.01f);
    tess.startDrawing(GL11.GL_LINES);

    // FRONT
    tess.addVertex(0, 0, 0);
    tess.addVertex(0, 1, 0);

    tess.addVertex(0, 1, 0);
    tess.addVertex(1, 1, 0);

    tess.addVertex(1, 1, 0);
    tess.addVertex(1, 0, 0);

    tess.addVertex(1, 0, 0);
    tess.addVertex(0, 0, 0);

    // BACK
    tess.addVertex(0, 0, -1);
    tess.addVertex(0, 1, -1);
    tess.addVertex(0, 0, -1);
    tess.addVertex(1, 0, -1);
    tess.addVertex(1, 0, -1);
    tess.addVertex(1, 1, -1);
    tess.addVertex(0, 1, -1);
    tess.addVertex(1, 1, -1);

    // betweens.
    tess.addVertex(0, 0, 0);
    tess.addVertex(0, 0, -1);

    tess.addVertex(0, 1, 0);
    tess.addVertex(0, 1, -1);

    tess.addVertex(1, 0, 0);
    tess.addVertex(1, 0, -1);

    tess.addVertex(1, 1, 0);
    tess.addVertex(1, 1, -1);

    tess.draw();
    GL11.glPopMatrix();
}

From source file:ccm.placeableTools.client.ToolRenderer.java

License:Open Source License

private void renderSign(double x, double y, double z, float tickTime, int facing, String[] signText, int meta) {
    GL11.glPushMatrix();//  w w  w .ja v  a 2s .  c om
    float f1 = 0.6666667F;
    float f2 = 0.0F;

    switch (facing) {
    case 0:
    case 8:
        f2 = -90f;
        break;
    case 1:
    case 7:
        f2 = 90f;
        break;
    case 2:
    case 5:
        f2 = 180f;
    }

    if (meta >= 2) {
        GL11.glTranslated(0, -1.2, 0);
    }

    GL11.glTranslatef((float) x + 0.5F, (float) y + 0.75F * f1, (float) z + 0.5F);
    GL11.glRotatef(-f2, 0.0F, 1.0F, 0.0F);

    GL11.glTranslatef(0.0F, -0.3125F, -0.4375F);
    GL11.glTranslatef(0f, 0.8F, 0.5f);
    MODEL_SIGN.signStick.showModel = false;

    if (facing > 4) {
        if (meta >= 2)
            GL11.glTranslated(-0.6, 0, 0);
        //GL11.glTranslated(b ? -0.4 : -0.6, 0, 0);

        if (meta == 2 && facing == 7)
            GL11.glTranslated(1.2, 0, 0);
        else if (meta == 3 && facing == 8)
            GL11.glTranslated(1.2, 0, 0);
        else if (meta == 4 && facing == 6)
            GL11.glTranslated(1.2, 0, 0);
        else if (meta == 5 && facing == 5)
            GL11.glTranslated(1.2, 0, 0);
    }

    this.bindTexture(SIGN_TEXTURE);
    GL11.glPushMatrix();
    GL11.glScalef(f1, -f1, -f1);
    MODEL_SIGN.renderSign();
    GL11.glPopMatrix();
    FontRenderer fontrenderer = this.getFontRenderer();
    f2 = 0.016666668F * f1;
    GL11.glTranslatef(0.0F, 0.5F * f1, 0.07F * f1);
    GL11.glScalef(f2, -f2, f2);
    GL11.glNormal3f(0.0F, 0.0F, -1.0F * f2);
    GL11.glDepthMask(false);
    byte b0 = 0;

    for (int j = 0; j < signText.length; ++j) {
        GL11.glPushMatrix();
        String s = signText[j];
        int width = fontrenderer.getStringWidth(s);
        if (width > 95) {
            float f = 1f - ((width) * 0.0015f);
            GL11.glScalef(f, f, f);
        }
        fontrenderer.drawString(s, -width / 2, j * 10 - signText.length * 5, b0);
        GL11.glPopMatrix();
    }

    GL11.glDepthMask(true);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glPopMatrix();
}

From source file:ccm.placeableTools.client.ToolRenderer.java

License:Open Source License

public static void doRenderPass(int i, int meta, ItemStack stack, double x, double y, double z) {
    Icon icon = stack.getItem().getIcon(stack, i);

    if (icon == null)
        return;//w w w . j  a va 2  s .  co  m

    GL11.glPushMatrix();
    TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
    texturemanager.bindTexture(texturemanager.getResourceLocation(stack.getItemSpriteNumber()));
    Tessellator tessellator = Tessellator.instance;

    GL11.glTranslated(x, y, z); //Center to block
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);

    GL11.glTranslatef(-0.5f, .5f, 0.5f); // Center on block

    if (stack.getItem() instanceof ItemSpade || stack.getItem() instanceof ItemHoe) {
        float shift = 0.3f;
        switch (ForgeDirection.values()[meta]) {
        case NORTH:
            GL11.glTranslatef(0, 0, -shift);
            GL11.glRotatef(15f, -0.5f, 0, 0);
            break;
        case SOUTH:
            GL11.glTranslatef(0, 0, shift);
            GL11.glRotatef(-15f, -0.5f, 0, 0);
            break;
        case EAST:
            GL11.glRotatef(90f, 0, 1, 0);
            GL11.glTranslatef(-1, 0, 1);
            GL11.glTranslatef(0, 0, shift);
            GL11.glRotatef(-15f, -0.5f, 0, 0);
            break;
        case WEST:
            GL11.glRotatef(90f, 0, 1, 0);
            GL11.glTranslatef(-1, 0, 1);
            GL11.glTranslatef(0, 0, -shift);
            GL11.glRotatef(15f, -0.5f, 0, 0);
            break;
        case DOWN:
            GL11.glRotatef(90f, 0, 1, 0);
            GL11.glTranslatef(-1, 0, 1);
            break;
        }
        GL11.glTranslatef(0, 0, -0.03f); //Icon depth of the shovel
        GL11.glRotatef(180f, 1, 0, 0);
    } else if (stack.getItem() instanceof ItemAxe || stack.getItem() instanceof ItemPickaxe) {
        float shift = 0.15f;
        switch (ForgeDirection.values()[meta]) {
        case NORTH:
            GL11.glRotatef(90f, 0, 1, 0);
            GL11.glTranslatef(-1, 0, 1);
            GL11.glTranslatef(shift, 0, 0);
            GL11.glRotatef(-10f, 0, 0, 1);
            break;
        case SOUTH:
            GL11.glRotatef(-90f, 0, 1, 0);
            GL11.glTranslatef(-1, 0, -1);
            GL11.glTranslatef(shift, 0, 0);
            GL11.glRotatef(-10f, 0, 0, 1);
            break;
        case EAST:
            GL11.glTranslatef(shift, 0, 0);
            GL11.glRotatef(-10f, 0, 0, 1);
            break;
        case WEST:
            GL11.glRotatef(180f, 0, 1, 0);
            GL11.glTranslatef(-2, 0, 0);
            GL11.glTranslatef(shift, 0, 0);
            GL11.glRotatef(-10f, 0, 0, 1);
            break;
        }
        GL11.glTranslatef(0, 0, 0.03F);
    } else if (stack.getItem() instanceof ItemSword) {
        float shift = 0.15f;
        switch (ForgeDirection.values()[meta]) {
        case NORTH:
            GL11.glRotatef(90f, 0, 1, 0);
            GL11.glTranslatef(shift, 0, 0);
            GL11.glRotatef(-90f, 0, 0, 1);
            GL11.glTranslatef(-1, 0, 1);
            break;
        case SOUTH:
            GL11.glRotatef(-90f, 0, 1, 0);
            GL11.glTranslatef(shift, 0, 0);
            GL11.glRotatef(-90f, 0, 0, 1);
            GL11.glTranslatef(-1, 0, -1);
            break;
        case EAST:
            GL11.glTranslatef(shift, 0, 0);
            GL11.glRotatef(-90f, 0, 0, 1);
            GL11.glTranslatef(-1, 1, 0);
            break;
        case WEST:
            GL11.glRotatef(180f, 0, 1, 0);
            GL11.glTranslatef(-1, 1, 0);
            GL11.glTranslatef(shift, 0, 0);
            GL11.glRotatef(-90f, 0, 0, 1);
            break;
        case UP:
            GL11.glRotatef(180f, 1, 0, 0);
            GL11.glTranslatef(1, 0, 1);
            GL11.glRotatef(90f, 0, 1, 0);
            break;
        case DOWN:
            GL11.glRotatef(180f, 1, 0, 0);
            break;
        }
        GL11.glTranslatef(-0.05f, 0, 0.03F);
    }
    GL11.glRotatef(-45f, 0, 0, 1);
    GL11.glScalef(1.5f, 1.5f, 1.5f);
    ItemRenderer.renderItemIn2D(tessellator, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(),
            icon.getIconWidth(), icon.getIconHeight(), 0.06F / 1.5f);

    if (stack.hasEffect(i)) {
        GL11.glDepthFunc(GL11.GL_EQUAL);
        GL11.glDisable(GL11.GL_LIGHTING);
        texturemanager.bindTexture(RES_ITEM_GLINT);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
        float f7 = 0.76F;
        GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F);
        GL11.glMatrixMode(GL11.GL_TEXTURE);
        GL11.glPushMatrix();
        float f8 = 0.125F;
        GL11.glScalef(f8, f8, f8);
        float f9 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F;
        GL11.glTranslatef(f9, 0.0F, 0.0F);
        GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
        ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.06F / 1.5f);
        GL11.glPopMatrix();
        GL11.glPushMatrix();
        GL11.glScalef(f8, f8, f8);
        f9 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F;
        GL11.glTranslatef(-f9, 0.0F, 0.0F);
        GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
        ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.06F / 1.5f);
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
    }

    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
}

From source file:chessMod.client.ChessModDrawBlockHighlightHandler.java

License:LGPL

public static void highlightTile(EntityPlayer player, double x, double y, double z, float partialTicks) {

    x += 0.5D;/*w w w  .ja v a2 s  . c o  m*/
    y += 0.5D;
    z += 0.5D;
    double iPX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks;
    double iPY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks;
    double iPZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks;

    float xScale = 1.0F;
    float yScale = 1;
    float zScale = 1.0F;
    float xShift = 0.0F;
    float yShift = 0.01F;
    float zShift = 0.0F;

    GL11.glDepthMask(false);
    GL11.glDisable(GL11.GL_CULL_FACE);

    for (int i = 4; i < 5; i++) {
        ForgeDirection forgeDir = ForgeDirection.getOrientation(i);
        int zCorrection = i == 2 ? -1 : 1;
        GL11.glPushMatrix();
        GL11.glTranslated(-iPX + x + xShift, -iPY + y + yShift, -iPZ + z + zShift);
        GL11.glScalef(1F * xScale, 1F * yScale, 1F * zScale);
        GL11.glRotatef(90, forgeDir.offsetX, forgeDir.offsetY, forgeDir.offsetZ);
        GL11.glTranslated(0, 0, 0.5f * zCorrection);
        GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
        drawQuad(-0.5F, -0.5F, 1F, 1F, 0F);
        GL11.glPopMatrix();
    }

    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glDepthMask(true);
}

From source file:cn.academy.ability.client.ui.CPBar.java

License:GNU General Public License

private void initEvents() {
    listen(FrameEvent.class, (w, e) -> {
        EntityPlayer player = Minecraft.getMinecraft().thePlayer;
        CPData cpData = CPData.get(player);
        AbilityData aData = AbilityData.get(player);
        if (!aData.hasCategory())
            return;

        Category c = aData.getCategory();
        overlayTexture = c.getOverlayIcon();

        boolean active = cpData.isActivated();

        // Calculate alpha
        long time = GameTimer.getTime();
        if (!lastFrameActive && active) {
            showTime = time;// w  w w. ja v  a  2 s  .  c o  m
        }

        // Takes account of interference
        long deltaTime = Math.min(100L, time - lastDrawTime);

        final long BLENDIN_TIME = 200L;
        mAlpha = (time - showTime < BLENDIN_TIME) ? (float) (time - showTime) / BLENDIN_TIME
                : (active ? 1.0f : Math.max(0.0f, 1 - (time - lastDrawTime) / 200.0f));

        boolean interf = cpData.isInterfering();
        boolean overloadRecovering = cpData.isOverloadRecovering();

        if (interf) {
            OffsetKeyframe frame = int_get();
            GL11.glTranslated(frame.direction.x, frame.direction.y, 0);
            long timeInput = GameTimer.getAbsTime() % maxtime;
            timeInput = (timeInput / 10) * 10; // Lower the precision to produce 'jagged' effect
            mAlpha *= alphaCurve.valueAt(timeInput);
        }

        GL11.glPushMatrix(); // PUSH 1

        float poverload = mAlpha > 0 ? cpData.getOverload() / cpData.getMaxOverload() : 0;
        bufferedOverload = balance(bufferedOverload, poverload, deltaTime * 1E-3f * O_BALANCE_SPEED);

        float pcp = mAlpha > 0 ? cpData.getCP() / cpData.getMaxCP() : 0;
        bufferedCP = balance(bufferedCP, pcp, deltaTime * 1E-3f * CP_BALANCE_SPEED);

        if (mAlpha > 0) {
            /* Draw CPBar */ {
                if (!cpData.isOverloaded()) {
                    drawNormal(bufferedOverload);
                } else {
                    drawOverload(bufferedOverload);
                }

                if (chProvider != null && !chProvider.alive())
                    chProvider = null;

                float estmCons = getConsumptionHint();
                boolean low = interf || overloadRecovering;

                if (estmCons != 0) {
                    float ncp = Math.max(0, cpData.getCP() - estmCons);

                    float oldAlpha = mAlpha;
                    mAlpha *= 0.2f + 0.1f * (1 + Math.sin(time / 80.0f));

                    drawCPBar(pcp, low);

                    mAlpha = oldAlpha;

                    drawCPBar(ncp / cpData.getMaxCP(), low);
                } else {
                    drawCPBar(bufferedCP, low);
                }
            }

            /* Draw Preset Hint */ {
                final long preset_wait = 2000L;
                if (time - presetChangeTime < preset_wait)
                    drawPresetHint((double) (time - presetChangeTime) / preset_wait, time - lastPresetTime);
            }

            // Draw data
            {
                float alpha;
                long dt = lastShowValueChange == 0 ? Long.MAX_VALUE : time - lastShowValueChange;

                if (cpData.isOverloaded()) {
                    alpha = 0.0f;
                } else if (showingNumbers) {
                    alpha = MathUtils.clampf(0, 1, (dt - 200) / 400f); // Delay display by 200ms for visual pleasure
                } else if (dt < 300f) {
                    alpha = 1 - dt / 300f;
                } else {
                    alpha = 0.0f;
                }

                if (alpha > 0) {
                    final double x0 = 110;

                    IFont font = Resources.font();
                    FontOption option = new FontOption(40);
                    option.color.a = 0.6f * mAlpha * alpha;

                    String str10 = "CP ";
                    String str11 = String.format("%.0f", cpData.getCP());
                    String str12 = String.format("/%.0f", cpData.getMaxCP());

                    String str20 = "OL ";
                    String str21 = String.format("%.0f", cpData.getOverload());
                    String str22 = String.format("/%.0f", cpData.getMaxOverload());

                    double len10 = font.getTextWidth(str10, option), len11 = font.getTextWidth(str11, option),
                            len20 = font.getTextWidth(str20, option), len21 = font.getTextWidth(str21, option);

                    double len0 = Math.max(len10, len20);
                    double len1 = len0 + Math.max(len11, len21);

                    font.draw(str10, x0, 55, option);
                    font.draw(str12, x0 + len1, 55, option);
                    font.draw(str20, x0, 85, option);
                    font.draw(str22, x0 + len1, 85, option);

                    option.align = FontAlign.RIGHT;
                    font.draw(str11, x0 + len1, 55, option);
                    font.draw(str21, x0 + len1, 85, option);
                }
            }

            drawActivateKeyHint();
        }

        if (active) {
            lastDrawTime = time;
        }

        lastFrameActive = active;

        GL11.glColor4d(1, 1, 1, 1);
        GL11.glPopMatrix(); // Pop 1
    });
}

From source file:cn.academy.ability.client.ui.KeyHintUI.java

License:GNU General Public License

private void addDrawing() {
    listen(FrameEvent.class, (w, e) -> {
        EntityPlayer player = Minecraft.getMinecraft().thePlayer;

        CPData cpData = CPData.get(player);

        canUseAbility = cpData.canUseAbility();

        long time = GameTimer.getTime();
        if (time - lastFrameTime > 300L) {
            showTime = time;//  w  ww .  ja  va  2 s.c  o  m
        }

        if ((time - showTime) < 300L) {
            mAlpha = (time - showTime) / 300.0;
        } else {
            mAlpha = 1.0;
        }

        sinAlpha = 0.6f + (1 + MathHelper.sin((time % 100000) / 50.0f)) * 0.2f;

        if (cpData.isActivated()) {
            ClientRuntime rt = ClientRuntime.instance();
            CooldownData cd = CooldownData.of(rt.getEntity());

            Multimap<String, DelegateNode> map = rt.getDelegateRawData();
            List<String> groups = new ArrayList<>(map.keySet());
            groups.sort((s1, s2) -> {
                if (s1.equals(ClientRuntime.DEFAULT_GROUP))
                    return -1;
                else if (s2.equals(ClientRuntime.DEFAULT_GROUP))
                    return 1;
                else
                    return s1.compareTo(s2);
            });

            int availIdx = 0;
            for (int i = 0; i < groups.size(); ++i) {
                Collection<DelegateNode> nodes = map.get(groups.get(i));
                if (!nodes.isEmpty()) {
                    final double x = -200 - availIdx * 200;
                    double y = 0;
                    for (DelegateNode node : nodes) {
                        GL11.glPushMatrix();
                        GL11.glTranslated(x, y, 0);
                        drawSingle(node.keyID, node.delegate,
                                cd.getSub(node.delegate.getSkill(), node.delegate.getIdentifier()));
                        GL11.glPopMatrix();
                        y += 92;
                    }
                    availIdx++;
                }
            }
        }

        lastFrameTime = time;
        GL11.glColor4d(1, 1, 1, 1);
    });
}