Example usage for org.lwjgl.opengl GL11 glGetBoolean

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

Introduction

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

Prototype

@NativeType("void")
public static boolean glGetBoolean(@NativeType("GLenum") int pname) 

Source Link

Document

Returns the current boolean value of the specified state variable.

Usage

From source file:com.badlogic.gdx.backends.lwjgl3.Lwjgl3GL20.java

License:Apache License

public void glGetBooleanv(int pname, Buffer params) {
    ((ByteBuffer) params).put(GL11.glGetBoolean(pname) ? (byte) 1 : (byte) 0);
}

From source file:com.bluepowermod.client.render.RenderPartItem.java

License:Open Source License

private void render(float x, float y, float z, float scale, ItemRenderType type, ItemStack item,
        Object... data) {/*from  w ww.  j av a2s .c  om*/

    boolean blend = GL11.glGetBoolean(GL11.GL_BLEND);
    boolean alpha = GL11.glGetBoolean(GL11.GL_ALPHA_TEST);

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_ALPHA_TEST);

    GL11.glPushMatrix();
    GL11.glScalef(scale, scale, scale);
    GL11.glTranslatef(x, y, z);
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
    try {
        BPPart part = PartManager.getExample(item);
        part.renderItem(type, item, data);
    } catch (Exception ex) {
    }
    GL11.glPopMatrix();

    if (!blend)
        GL11.glDisable(GL11.GL_BLEND);
    if (!alpha)
        GL11.glDisable(GL11.GL_ALPHA_TEST);
}

From source file:com.professorvennie.machinerycraft.core.helpers.RenderHelper.java

License:Creative Commons License

public static void renderTooltip(int x, int y, List<String> tooltipData, int color, int color2) {
    boolean lighting = GL11.glGetBoolean(GL11.GL_LIGHTING);
    if (lighting)
        net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();

    if (!tooltipData.isEmpty()) {
        int var5 = 0;
        int var6;
        int var7;
        FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
        for (var6 = 0; var6 < tooltipData.size(); ++var6) {
            var7 = fontRenderer.getStringWidth(tooltipData.get(var6));
            if (var7 > var5)
                var5 = var7;
        }//  w w  w .  ja v a 2  s .co  m
        var6 = x + 12;
        var7 = y - 12;
        int var9 = 8;
        if (tooltipData.size() > 1)
            var9 += 2 + (tooltipData.size() - 1) * 10;
        float z = 300F;
        drawGradientRect(var6 - 3, var7 - 4, z, var6 + var5 + 3, var7 - 3, color2, color2);
        drawGradientRect(var6 - 3, var7 + var9 + 3, z, var6 + var5 + 3, var7 + var9 + 4, color2, color2);
        drawGradientRect(var6 - 3, var7 - 3, z, var6 + var5 + 3, var7 + var9 + 3, color2, color2);
        drawGradientRect(var6 - 4, var7 - 3, z, var6 - 3, var7 + var9 + 3, color2, color2);
        drawGradientRect(var6 + var5 + 3, var7 - 3, z, var6 + var5 + 4, var7 + var9 + 3, color2, color2);
        int var12 = (color & 0xFFFFFF) >> 1 | color & -16777216;
        drawGradientRect(var6 - 3, var7 - 3 + 1, z, var6 - 3 + 1, var7 + var9 + 3 - 1, color, var12);
        drawGradientRect(var6 + var5 + 2, var7 - 3 + 1, z, var6 + var5 + 3, var7 + var9 + 3 - 1, color, var12);
        drawGradientRect(var6 - 3, var7 - 3, z, var6 + var5 + 3, var7 - 3 + 1, color, color);
        drawGradientRect(var6 - 3, var7 + var9 + 2, z, var6 + var5 + 3, var7 + var9 + 3, var12, var12);

        GL11.glDisable(GL11.GL_DEPTH_TEST);
        for (int var13 = 0; var13 < tooltipData.size(); ++var13) {
            String var14 = tooltipData.get(var13);
            fontRenderer.drawStringWithShadow(var14, var6, var7, -1);
            if (var13 == 0)
                var7 += 2;
            var7 += 10;
        }
        GL11.glEnable(GL11.GL_DEPTH_TEST);
    }
    if (!lighting)
        net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
    GL11.glColor4f(1F, 1F, 1F, 1F);
}

From source file:com.sr2610.steampunkd.client.TooltipHelper.java

License:Creative Commons License

public static void renderTooltip(int x, int y, List<String> tooltipData) {
    int color = 0x505000ff;
    int color2 = 0xf0100010;
    boolean lighting = GL11.glGetBoolean(GL11.GL_LIGHTING);
    if (lighting)
        net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();

    if (!tooltipData.isEmpty()) {
        int var5 = 0;
        int var6;
        int var7;
        FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj;
        for (var6 = 0; var6 < tooltipData.size(); ++var6) {
            var7 = fontRenderer.getStringWidth(tooltipData.get(var6));
            if (var7 > var5)
                var5 = var7;
        }//w  w  w .j  ava  2  s. c  o  m
        var6 = x + 12;
        var7 = y - 12;
        int var9 = 8;
        if (tooltipData.size() > 1)
            var9 += 2 + ((tooltipData.size() - 1) * 10);
        float z = 300F;
        drawGradientRect(var6 - 3, var7 - 4, z, var6 + var5 + 3, var7 - 3, color2, color2);
        drawGradientRect(var6 - 3, var7 + var9 + 3, z, var6 + var5 + 3, var7 + var9 + 4, color2, color2);
        drawGradientRect(var6 - 3, var7 - 3, z, var6 + var5 + 3, var7 + var9 + 3, color2, color2);
        drawGradientRect(var6 - 4, var7 - 3, z, var6 - 3, var7 + var9 + 3, color2, color2);
        drawGradientRect(var6 + var5 + 3, var7 - 3, z, var6 + var5 + 4, var7 + var9 + 3, color2, color2);
        int var12 = ((color & 0xFFFFFF) >> 1) | (color & -16777216);
        drawGradientRect(var6 - 3, (var7 - 3) + 1, z, (var6 - 3) + 1, (var7 + var9 + 3) - 1, color, var12);
        drawGradientRect(var6 + var5 + 2, (var7 - 3) + 1, z, var6 + var5 + 3, (var7 + var9 + 3) - 1, color,
                var12);
        drawGradientRect(var6 - 3, var7 - 3, z, var6 + var5 + 3, (var7 - 3) + 1, color, color);
        drawGradientRect(var6 - 3, var7 + var9 + 2, z, var6 + var5 + 3, var7 + var9 + 3, var12, var12);

        GlStateManager.disableDepth();
        for (int var13 = 0; var13 < tooltipData.size(); ++var13) {
            String var14 = tooltipData.get(var13);
            fontRenderer.drawStringWithShadow(var14, var6, var7, -1);
            if (var13 == 0)
                var7 += 2;
            var7 += 10;
        }
        GlStateManager.enableDepth();
    }
    if (!lighting)
        net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
    GlStateManager.color(1F, 1F, 1F, 1F);
}

From source file:de.sanandrew.mods.turretmod.client.render.world.RenderTurretLaser.java

License:Creative Commons License

private static void renderLaser(ITurretInst turret, double renderX, double renderY, double renderZ,
        double partTicks) {
    Entity tgt = turret.getTargetProcessor().getTarget();
    EntityLiving turretL = turret.getEntity();

    double turretX = turretL.lastTickPosX + (turretL.posX - turretL.lastTickPosX) * partTicks;
    double turretY = turretL.lastTickPosY + (turretL.posY - turretL.lastTickPosY) * partTicks
            + turretL.getEyeHeight() - (turret.isUpsideDown() ? 0.95F : 0.13F);
    double turretZ = turretL.lastTickPosZ + (turretL.posZ - turretL.lastTickPosZ) * partTicks;

    double vecX = tgt.lastTickPosX + (tgt.posX - tgt.lastTickPosX) * partTicks - turretX;
    double vecY = tgt.lastTickPosY + (tgt.posY - tgt.lastTickPosY) * partTicks + tgt.height / 1.4F - turretY;
    double vecZ = tgt.lastTickPosZ + (tgt.posZ - tgt.lastTickPosZ) * partTicks - turretZ;

    double dist = Math.sqrt(vecX * vecX + vecY * vecY + vecZ * vecZ);

    double rotYaw = turretL.prevRotationYawHead
            + (turretL.rotationYawHead - turretL.prevRotationYawHead) * partTicks;
    double rotPtc = turretL.prevRotationPitch + (turretL.rotationPitch - turretL.prevRotationPitch) * partTicks;

    final double beamWidth = 0.0125D;

    ColorObj laserClr = new ColorObj(1.0F, 0.0F, 0.0F, 0.25F);
    if (turret.getUpgradeProcessor().hasUpgrade(Upgrades.ENDER_MEDIUM)) {
        laserClr = new ColorObj(0.0F, 0.5F, 1.0F, 0.25F);
    }//from ww w. ja  v a 2s  .  c  o m

    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    boolean prevLightingState = GL11.glGetBoolean(GL11.GL_LIGHTING);

    GlStateManager.pushMatrix();
    GlStateManager.disableLighting();
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA,
            GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
    GlStateManager.disableTexture2D();
    GlStateManager.disableCull();

    GlStateManager.translate(turretX - renderX, turretY - renderY, turretZ - renderZ);
    GlStateManager.rotate(270.0F - (float) rotYaw, 0.0F, (turret.isUpsideDown() ? -1.0F : 1.0F), 0.0F);
    GlStateManager.rotate((float) -rotPtc, 0.0F, 0.0F, (turret.isUpsideDown() ? -1.0F : 1.0F));

    GlStateManager.depthMask(false);
    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
    buffer.pos(0.0D, -beamWidth, -beamWidth)
            .color(laserClr.fRed(), laserClr.fGreen(), laserClr.fBlue(), laserClr.fAlpha()).endVertex();
    buffer.pos(dist, -beamWidth, -beamWidth)
            .color(laserClr.fRed(), laserClr.fGreen(), laserClr.fBlue(), laserClr.fAlpha()).endVertex();
    buffer.pos(dist, beamWidth, beamWidth)
            .color(laserClr.fRed(), laserClr.fGreen(), laserClr.fBlue(), laserClr.fAlpha()).endVertex();
    buffer.pos(0.0D, beamWidth, beamWidth)
            .color(laserClr.fRed(), laserClr.fGreen(), laserClr.fBlue(), laserClr.fAlpha()).endVertex();

    buffer.pos(0.0D, -beamWidth, beamWidth)
            .color(laserClr.fRed(), laserClr.fGreen(), laserClr.fBlue(), laserClr.fAlpha()).endVertex();
    buffer.pos(dist, -beamWidth, beamWidth)
            .color(laserClr.fRed(), laserClr.fGreen(), laserClr.fBlue(), laserClr.fAlpha()).endVertex();
    buffer.pos(dist, beamWidth, -beamWidth)
            .color(laserClr.fRed(), laserClr.fGreen(), laserClr.fBlue(), laserClr.fAlpha()).endVertex();
    buffer.pos(0.0D, beamWidth, -beamWidth)
            .color(laserClr.fRed(), laserClr.fGreen(), laserClr.fBlue(), laserClr.fAlpha()).endVertex();

    buffer.pos(0.0D, -beamWidth, -beamWidth)
            .color(laserClr.fRed(), laserClr.fGreen(), laserClr.fBlue(), laserClr.fAlpha()).endVertex();
    buffer.pos(dist, -beamWidth, -beamWidth)
            .color(laserClr.fRed(), laserClr.fGreen(), laserClr.fBlue(), laserClr.fAlpha()).endVertex();
    buffer.pos(dist, -beamWidth, beamWidth)
            .color(laserClr.fRed(), laserClr.fGreen(), laserClr.fBlue(), laserClr.fAlpha()).endVertex();
    buffer.pos(0.0D, -beamWidth, beamWidth)
            .color(laserClr.fRed(), laserClr.fGreen(), laserClr.fBlue(), laserClr.fAlpha()).endVertex();

    buffer.pos(0.0D, beamWidth, -beamWidth)
            .color(laserClr.fRed(), laserClr.fGreen(), laserClr.fBlue(), laserClr.fAlpha()).endVertex();
    buffer.pos(dist, beamWidth, -beamWidth)
            .color(laserClr.fRed(), laserClr.fGreen(), laserClr.fBlue(), laserClr.fAlpha()).endVertex();
    buffer.pos(dist, beamWidth, beamWidth)
            .color(laserClr.fRed(), laserClr.fGreen(), laserClr.fBlue(), laserClr.fAlpha()).endVertex();
    buffer.pos(0.0D, beamWidth, beamWidth)
            .color(laserClr.fRed(), laserClr.fGreen(), laserClr.fBlue(), laserClr.fAlpha()).endVertex();

    buffer.pos(0.0D, -beamWidth, -beamWidth)
            .color(laserClr.fRed(), laserClr.fGreen(), laserClr.fBlue(), laserClr.fAlpha()).endVertex();
    buffer.pos(dist, -beamWidth, -beamWidth)
            .color(laserClr.fRed(), laserClr.fGreen(), laserClr.fBlue(), laserClr.fAlpha()).endVertex();
    buffer.pos(dist, beamWidth, -beamWidth)
            .color(laserClr.fRed(), laserClr.fGreen(), laserClr.fBlue(), laserClr.fAlpha()).endVertex();
    buffer.pos(0.0D, beamWidth, -beamWidth)
            .color(laserClr.fRed(), laserClr.fGreen(), laserClr.fBlue(), laserClr.fAlpha()).endVertex();

    buffer.pos(0.0D, -beamWidth, beamWidth)
            .color(laserClr.fRed(), laserClr.fGreen(), laserClr.fBlue(), laserClr.fAlpha()).endVertex();
    buffer.pos(dist, -beamWidth, beamWidth)
            .color(laserClr.fRed(), laserClr.fGreen(), laserClr.fBlue(), laserClr.fAlpha()).endVertex();
    buffer.pos(dist, beamWidth, beamWidth)
            .color(laserClr.fRed(), laserClr.fGreen(), laserClr.fBlue(), laserClr.fAlpha()).endVertex();
    buffer.pos(0.0D, beamWidth, beamWidth)
            .color(laserClr.fRed(), laserClr.fGreen(), laserClr.fBlue(), laserClr.fAlpha()).endVertex();
    tessellator.draw();
    GlStateManager.depthMask(true);

    GlStateManager.enableCull();
    GlStateManager.enableTexture2D();

    GlStateManager.disableBlend();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

    if (prevLightingState) {
        GlStateManager.enableLighting();
    }
    GlStateManager.popMatrix();
}

From source file:dracocore.handbook.helpers.RenderHelper.java

License:Creative Commons License

public static void renderTooltip(int x, int y, List<String> tooltipData, int color, int color2) {
    final boolean lighting = GL11.glGetBoolean(GL11.GL_LIGHTING);
    if (lighting)
        net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();

    if (!tooltipData.isEmpty()) {
        int var5 = 0;
        int var6;
        int var7;
        final FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
        for (var6 = 0; var6 < tooltipData.size(); ++var6) {
            var7 = fontRenderer.getStringWidth(tooltipData.get(var6));
            if (var7 > var5)
                var5 = var7;
        }//from   w  w  w . j  a va  2 s . c o m
        var6 = x + 12;
        var7 = y - 12;
        int var9 = 8;
        if (tooltipData.size() > 1)
            var9 += 2 + ((tooltipData.size() - 1) * 10);
        final float z = 300F;
        drawGradientRect(var6 - 3, var7 - 4, z, var6 + var5 + 3, var7 - 3, color2, color2);
        drawGradientRect(var6 - 3, var7 + var9 + 3, z, var6 + var5 + 3, var7 + var9 + 4, color2, color2);
        drawGradientRect(var6 - 3, var7 - 3, z, var6 + var5 + 3, var7 + var9 + 3, color2, color2);
        drawGradientRect(var6 - 4, var7 - 3, z, var6 - 3, var7 + var9 + 3, color2, color2);
        drawGradientRect(var6 + var5 + 3, var7 - 3, z, var6 + var5 + 4, var7 + var9 + 3, color2, color2);
        final int var12 = ((color & 0xFFFFFF) >> 1) | (color & -16777216);
        drawGradientRect(var6 - 3, (var7 - 3) + 1, z, (var6 - 3) + 1, (var7 + var9 + 3) - 1, color, var12);
        drawGradientRect(var6 + var5 + 2, (var7 - 3) + 1, z, var6 + var5 + 3, (var7 + var9 + 3) - 1, color,
                var12);
        drawGradientRect(var6 - 3, var7 - 3, z, var6 + var5 + 3, (var7 - 3) + 1, color, color);
        drawGradientRect(var6 - 3, var7 + var9 + 2, z, var6 + var5 + 3, var7 + var9 + 3, var12, var12);

        GL11.glDisable(GL11.GL_DEPTH_TEST);
        for (int var13 = 0; var13 < tooltipData.size(); ++var13) {
            final String var14 = tooltipData.get(var13);
            fontRenderer.drawStringWithShadow(var14, var6, var7, -1);
            if (var13 == 0)
                var7 += 2;
            var7 += 10;
        }
        GL11.glEnable(GL11.GL_DEPTH_TEST);
    }
    if (!lighting)
        net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
    GL11.glColor4f(1F, 1F, 1F, 1F);
}

From source file:hellfirepvp.astralsorcery.client.effect.light.EffectLightbeam.java

License:Open Source License

@Override
public void render(float pTicks) {
    Entity rView = Minecraft.getMinecraft().getRenderViewEntity();
    if (rView == null)
        rView = Minecraft.getMinecraft().player;
    if (rView.getDistanceSq(from.getX(), from.getY(), from.getZ()) > Config.maxEffectRenderDistanceSq)
        return;/*from www . j  a  va 2 s . c om*/

    float tr = alphaFunction.getAlpha(age, maxAge);
    tr *= 0.6;
    tr *= alphaMultiplier;

    GL11.glPushMatrix();
    removeOldTranslate(rView, pTicks);
    GL11.glColor4f(cR * tr, cG * tr, cB * tr, cA * tr);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glDepthMask(false);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    Blending.PREALPHA.apply();
    boolean lighting = GL11.glGetBoolean(GL11.GL_LIGHTING);
    if (lighting) {
        GL11.glDisable(GL11.GL_LIGHTING);
    }
    SpriteLibrary.spriteLightbeam.getResource().bind();

    renderCurrentTextureAroundAxis(Math.toRadians(0F));
    renderCurrentTextureAroundAxis(Math.toRadians(120F));
    renderCurrentTextureAroundAxis(Math.toRadians(240F));

    if (lighting) {
        GL11.glEnable(GL11.GL_LIGHTING);
    }
    Blending.DEFAULT.apply();
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glColor4f(1F, 1F, 1F, 1F);
    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glPopMatrix();
}

From source file:hellfirepvp.astralsorcery.client.util.RenderingUtils.java

License:Open Source License

public static void renderTooltip(int x, int y, List<String> tooltipData, Color color, Color colorFade,
        Color strColor, FontRenderer fontRenderer) {
    TextureHelper.setActiveTextureToAtlasSprite();
    boolean lighting = GL11.glGetBoolean(GL11.GL_LIGHTING);
    if (lighting)
        RenderHelper.disableStandardItemLighting();

    if (!tooltipData.isEmpty()) {
        int esWidth = 0;
        for (String toolTip : tooltipData) {
            int width = fontRenderer.getStringWidth(toolTip);
            if (width > esWidth)
                esWidth = width;/*from   ww  w.j  a v a2s. c  om*/
        }
        ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
        if (x + 15 + esWidth > sr.getScaledWidth()) {
            x -= esWidth + 24;
        }
        int pX = x + 12;
        int pY = y - 12;
        int sumLineHeight = 8;
        if (tooltipData.size() > 1)
            sumLineHeight += 2 + (tooltipData.size() - 1) * 10;
        float z = 300F;

        drawGradientRect(pX - 3, pY - 4, z, pX + esWidth + 3, pY - 3, color, colorFade);
        drawGradientRect(pX - 3, pY + sumLineHeight + 3, z, pX + esWidth + 3, pY + sumLineHeight + 4, color,
                colorFade);
        drawGradientRect(pX - 3, pY - 3, z, pX + esWidth + 3, pY + sumLineHeight + 3, color, colorFade);
        drawGradientRect(pX - 4, pY - 3, z, pX - 3, pY + sumLineHeight + 3, color, colorFade);
        drawGradientRect(pX + esWidth + 3, pY - 3, z, pX + esWidth + 4, pY + sumLineHeight + 3, color,
                colorFade);

        int rgb = color.getRGB();
        int col = (rgb & 0x00FFFFFF) | rgb & 0xFF000000;
        Color colOp = new Color(col);
        drawGradientRect(pX - 3, pY - 3 + 1, z, pX - 3 + 1, pY + sumLineHeight + 3 - 1, color, colOp);
        drawGradientRect(pX + esWidth + 2, pY - 3 + 1, z, pX + esWidth + 3, pY + sumLineHeight + 3 - 1, color,
                colOp);
        drawGradientRect(pX - 3, pY - 3, z, pX + esWidth + 3, pY - 3 + 1, colOp, colOp);
        drawGradientRect(pX - 3, pY + sumLineHeight + 2, z, pX + esWidth + 3, pY + sumLineHeight + 3, color,
                color);

        GL11.glDisable(GL11.GL_DEPTH_TEST);
        for (int i = 0; i < tooltipData.size(); ++i) {
            String str = tooltipData.get(i);
            fontRenderer.drawString(str, pX, pY, strColor.getRGB());
            if (i == 0)
                pY += 2;
            pY += 10;
        }
        GlStateManager.color(1F, 1F, 1F, 1F);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
    }

    if (lighting)
        RenderHelper.enableStandardItemLighting();
    GL11.glColor4f(1F, 1F, 1F, 1F);
}

From source file:hellfirepvp.astralsorcery.common.item.wand.ItemArchitectWand.java

License:Open Source License

@Override
@SideOnly(Side.CLIENT)//from   w  w w.  jav a2  s. co m
public void onRenderWhileInHand(ItemStack stack, EnumHand hand, float pTicks) {
    IBlockState stored = getStoredState(stack);
    if (stored == null || stored.getBlock().equals(Blocks.AIR))
        return;

    Deque<BlockPos> placeable = filterBlocksToPlace(Minecraft.getMinecraft().player,
            Minecraft.getMinecraft().world, architectRange);
    if (!placeable.isEmpty()) {
        GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
        GL11.glPushMatrix();
        boolean blend = GL11.glGetBoolean(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_BLEND);
        Blending.ADDITIVEDARK.apply();
        GL11.glDisable(GL11.GL_ALPHA_TEST);
        RenderingUtils.removeStandartTranslationFromTESRMatrix(pTicks);
        World w = Minecraft.getMinecraft().world;

        Tessellator tes = Tessellator.getInstance();
        VertexBuffer vb = tes.getBuffer();
        vb.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
        for (BlockPos pos : placeable) {
            Minecraft.getMinecraft().getBlockRendererDispatcher().renderBlock(stored, pos, w, vb);
        }
        vb.sortVertexData((float) TileEntityRendererDispatcher.staticPlayerX,
                (float) TileEntityRendererDispatcher.staticPlayerY,
                (float) TileEntityRendererDispatcher.staticPlayerZ);
        tes.draw();
        Blending.DEFAULT.apply();
        if (!blend) {
            GL11.glDisable(GL11.GL_BLEND);
        }
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glPopMatrix();
        GL11.glPopAttrib();
    }
}

From source file:hellfirepvp.astralsorcery.common.item.wand.ItemExchangeWand.java

License:Open Source License

@Override
@SideOnly(Side.CLIENT)/*from www. j av  a2  s .co m*/
public void onRenderWhileInHand(ItemStack stack, EnumHand hand, float pTicks) {
    IBlockState stored = getStoredState(stack);
    ItemStack matchStack = getStoredStateAsStack(stack);
    if (stored == null || stored.getBlock().equals(Blocks.AIR) || matchStack.isEmpty())
        return;

    EntityPlayer pl = Minecraft.getMinecraft().player;
    PlayerControllerMP ctrl = Minecraft.getMinecraft().playerController;
    if (ctrl == null || pl == null)
        return;
    RayTraceResult rtr = getLookBlock(pl, false, true, ctrl.getBlockReachDistance());
    if (rtr == null)
        return;

    IBlockAccess airWorld = new AirBlockRenderWorld(Biomes.PLAINS,
            Minecraft.getMinecraft().world.getWorldType());
    BlockPos origin = rtr.getBlockPos();
    IBlockState atOrigin = Minecraft.getMinecraft().world.getBlockState(origin);
    if (stored.getBlock().equals(atOrigin.getBlock())
            && stored.getBlock().getMetaFromState(stored) == atOrigin.getBlock().getMetaFromState(atOrigin)) {
        return;
    }
    int amt = 0;
    if (pl.isCreative()) {
        amt = -1;
    } else {
        if (Mods.BOTANIA.isPresent()) {
            amt = ModIntegrationBotania.getItemCount(Minecraft.getMinecraft().player, stack, stored);
        } else {
            for (ItemStack st : ItemUtils.findItemsInPlayerInventory(pl, matchStack, false)) {
                amt += st.getCount();
            }
        }
    }
    BlockArray found = BlockDiscoverer.discoverBlocksWithSameStateAround(Minecraft.getMinecraft().world, origin,
            true, searchDepth, amt, false);
    if (found.isEmpty())
        return;

    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glPushMatrix();
    boolean blend = GL11.glGetBoolean(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_BLEND);
    Blending.ADDITIVEDARK.apply();
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    RenderingUtils.removeStandartTranslationFromTESRMatrix(pTicks);

    Tessellator tes = Tessellator.getInstance();
    VertexBuffer vb = tes.getBuffer();
    vb.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    for (BlockPos pos : found.getPattern().keySet()) {
        Minecraft.getMinecraft().getBlockRendererDispatcher().renderBlock(stored, pos, airWorld, vb);
    }
    vb.sortVertexData((float) TileEntityRendererDispatcher.staticPlayerX,
            (float) TileEntityRendererDispatcher.staticPlayerY,
            (float) TileEntityRendererDispatcher.staticPlayerZ);
    tes.draw();

    Blending.DEFAULT.apply();
    if (!blend) {
        GL11.glDisable(GL11.GL_BLEND);
    }
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glPopMatrix();
    GL11.glPopAttrib();
}