Example usage for org.lwjgl.opengl GL11 glScalef

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

Introduction

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

Prototype

public static native void glScalef(@NativeType("GLfloat") float x, @NativeType("GLfloat") float y,
        @NativeType("GLfloat") float z);

Source Link

Document

Manipulates the current matrix with a general scaling matrix along the x-, y- and z- axes.

Usage

From source file:Robot.java

public void draw() {
    updateAngles();//w  ww.  ja v a2s.  c o  m
    updateLocation();
    GL11.glPushMatrix();
    GL11.glScalef(0.5f, 0.5f, 0.5f);
    // drawing the torso
    GL11.glTranslatef(torsoX, torsoY, 0);
    GL11.glRotatef(torsoAngle[CURRENT_ANGLE], 0, 0, 1);
    drawTorso();

    // drawing the neck
    GL11.glPushMatrix();
    GL11.glTranslatef(0, TORSO_HEIGHT, 0);
    GL11.glRotatef(neckAngle[CURRENT_ANGLE], 0, 0, 1);
    drawNeck();

    // drawing the head
    GL11.glTranslatef(0, NECK_HEIGHT + HEAD_RADIUS, 0);
    GL11.glRotatef(headAngle[CURRENT_ANGLE], 0, 0, 1);
    drawHead();
    GL11.glPopMatrix();

    // drawing the right arms
    GL11.glPushMatrix();
    GL11.glTranslatef(TORSO_WIDTH / 2, TORSO_HEIGHT - UPPER_ARM_HEIGHT, 0);
    GL11.glRotatef(upperRightArmAngle[CURRENT_ANGLE], 0, 0, 1);
    drawUpperRightArm();
    GL11.glTranslatef(UPPER_ARM_WIDTH, LOWER_ARM_HEIGHT, 0);
    GL11.glRotatef(lowerRightArmAngle[CURRENT_ANGLE], 0, 0, 1);
    drawLowerRightArm();
    GL11.glPopMatrix();

    // drawing the left arms
    GL11.glPushMatrix();
    GL11.glScalef(-1, 1, 1); // same as the right arm but on the other side
    GL11.glTranslatef(TORSO_WIDTH / 2, TORSO_HEIGHT - UPPER_ARM_HEIGHT, 0);
    GL11.glRotatef(upperLeftArmAngle[CURRENT_ANGLE], 0, 0, 1);
    drawUpperLeftArm();
    GL11.glTranslatef(UPPER_ARM_WIDTH, LOWER_ARM_HEIGHT, 0);
    GL11.glRotatef(lowerLeftArmAngle[CURRENT_ANGLE], 0, 0, 1);
    drawLowerLeftArm();
    GL11.glPopMatrix();

    // drawing the right leg
    GL11.glPushMatrix();
    GL11.glTranslatef(TORSO_WIDTH / 4 - THIGH_WIDTH / 2, 0, 0);
    GL11.glRotatef(rightThighAngle[CURRENT_ANGLE], 0, 0, 1);
    drawRightThigh();
    GL11.glTranslatef(0, -THIGH_HEIGHT, 0);
    GL11.glRotatef(rightCalfAngle[CURRENT_ANGLE], 0, 0, 1);
    drawRightCalf();
    GL11.glPopMatrix();

    // drawing the left leg
    GL11.glPushMatrix();
    GL11.glScalef(-1, 1, 1); // same as the right arm but on the other side
    GL11.glTranslatef(TORSO_WIDTH / 4 - THIGH_WIDTH / 2, 0, 0);
    GL11.glRotatef(leftThighAngle[CURRENT_ANGLE], 0, 0, 1);
    drawLeftThigh();
    GL11.glTranslatef(0, -THIGH_HEIGHT, 0);
    GL11.glRotatef(leftCalfAngle[CURRENT_ANGLE], 0, 0, 1);
    drawLeftCalf();
    GL11.glPopMatrix();
    GL11.glPopMatrix();
}

From source file:$.DrawSystem.java

License:Open Source License

private void drawSprite(Sprite sprite) {
        Vector pos = spriteProjector.project(sprite.getPosition());
        final IPlay play = sprite.getPlay();
        if (null != play) {
            GL11.glPushMatrix();/* w  w  w . j  a va 2 s  .c om*/
            GL11.glTranslatef(pos.x, pos.y, 0.0f);
            GL11.glRotatef(sprite.getRotate(), 0, 0, 1.0f);
            GL11.glScalef(sprite.getScale(), sprite.getScale(), 1);
            final IAnimationFrame frame = play.getCurrentFrame();
            final IAnimationImage image = frame.getImage();
            if (image.hasAlpha()) {
                GL11.glEnable(GL11.GL_BLEND);
            }
            GL11.glBindTexture(GL11.GL_TEXTURE_2D, (Integer) image.getId());

            final float u1, u2;
            if (sprite.isMirrorX()) {
                u1 = frame.getU2();
                u2 = frame.getU1();
            } else {
                u1 = frame.getU1();
                u2 = frame.getU2();
            }

            final float v1, v2;
            if (sprite.isMirrorY()) {
                v1 = frame.getV1();
                v2 = frame.getV2();
            } else {
                v1 = frame.getV2();
                v2 = frame.getV1();
            }
            GL11.glColor4f(sprite.getRed(), sprite.getGreen(), sprite.getBlue(), sprite.getAlpha());
            float x1 = -sprite.getWidth() / 2.0f;
            float x2 = sprite.getWidth() / 2.0f;
            float y1 = -sprite.getHeight() / 2.0f;
            float y2 = sprite.getHeight() / 2.0f;
            GL11.glBegin(GL11.GL_QUADS);
            GL11.glTexCoord2f(u1, v1);
            GL11.glVertex2f(x1, y2);
            GL11.glTexCoord2f(u2, v1);
            GL11.glVertex2f(x2, y2);
            GL11.glTexCoord2f(u2, v2);
            GL11.glVertex2f(x2, y1);
            GL11.glTexCoord2f(u1, v2);
            GL11.glVertex2f(x1, y1);
            GL11.glEnd();
            GL11.glColor3f(1f, 1f, 1f);
            if (image.hasAlpha()) {
                GL11.glDisable(GL11.GL_BLEND);
            }
            GL11.glPopMatrix();
        }
        if (null != sprite.getLabel()) {
            GL11.glPushMatrix();
            GL11.glTranslatef(pos.x, pos.y, 0.0f);
            GL11.glScalef(0.5f, -0.5f, 1f);
            GL11.glEnable(GL11.GL_BLEND);
            LwjglNuitFont font = (LwjglNuitFont) assets.getFont("");
            font.drawString(sprite.getLabel(), LwjglNuitFont.Align.CENTER);
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glPopMatrix();
        }
    }

From source file:a1.gui.GUI_Map.java

License:Open Source License

public void DoRender() {
    if (!gui_map_rendered)
        return;//from  www .  j  av a2  s  .co m

    if (render_lightmap)
        CreateLightMap();

    RenderedObjects = 0;
    GL11.glPushMatrix();
    GL11.glScalef(scale, scale, 1.0f);
    if (render_tiles)
        DrawTiles();
    if (render_objects)
        DrawObjects();
    DrawFlyText();

    if (render_lightmap)
        RenderLightMap();
    GL11.glPopMatrix();

    if (Config.debug) {
        Render2D.Text("", 10, 200, "mc=" + mc.toString());
        if (mouse_in_object != null)
            Render2D.Text("", 10, 220, "obj=" + mouse_in_object.toString());
        if (mouse_map_pos != null)
            Render2D.Text("", 10, 240, "mouse_map_pos=" + mouse_map_pos.toString());
        if (mouse_tile_coord != null) {
            Render2D.Text("", 10, 260, "mouse_tile_coord=" + mouse_tile_coord.toString());
            Coord tc = mouse_tile_coord.div(TILE_SIZE);
            Render2D.Text("", 10, 280, "mouse_tile=" + tc.toString());
            Render2D.Text("", 10, 300, "mouse_tile_type=" + Integer.toString(MapCache.GetTile(tc)));
        }

        if (player_rect != null)
            Render2D.Text("", 10, 320, "player_rect=" + player_rect.toString());
        Render2D.Text("", 10, 340, "scale=" + String.valueOf(scale));
    }
}

From source file:additionalpipes.client.gui.GuiTeleportManager.java

License:Minecraft Mod Public

private void renderPipeMap(int map, MapData mapData) {
    RenderHelper.disableStandardItemLighting();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glDisable(GL11.GL_DEPTH_TEST);/*from w w w. j a  va 2s . co m*/
    mc.renderEngine.bindTexture(MAP_TEXTURE);

    GL11.glPushMatrix();
    Tessellator var4 = Tessellator.instance;
    var4.startDrawingQuads();
    byte var5 = 7;
    var4.addVertexWithUV(0 - var5, 128 + var5, 0.0D, 0.0D, 1.0D);
    var4.addVertexWithUV(128 + var5, 128 + var5, 0.0D, 1.0D, 1.0D);
    var4.addVertexWithUV(128 + var5, 0 - var5, 0.0D, 1.0D, 0.0D);
    var4.addVertexWithUV(0 - var5, 0 - var5, 0.0D, 0.0D, 0.0D);
    var4.draw();

    mapRenderer.renderMap(mc.thePlayer, mc.renderEngine, mapData);

    PropertyIntArray pipeArr = (PropertyIntArray) clientProps.propPipes.value.get(PropertyInteger.create(map));
    int[] pipes = pipeArr != null ? pipeArr.value : ArrayUtils.EMPTY_INT_ARRAY;
    for (int p = 0; p < pipes.length / 3; p++) {
        int centerX = pipes[p * 3 + 1];
        int centerZ = pipes[p * 3 + 2];
        GL11.glPushMatrix();
        GL11.glTranslatef(centerX / 2.0F + 64.0F - 4, centerZ / 2.0F + 64.0F - 4, -0.02F);
        GL11.glScalef(0.5F, 0.5F, 0.5F);
        itemRenderer.renderItemAndEffectIntoGUI(fontRenderer, mc.renderEngine,
                new ItemStack(getTeleportPipe(PipeType.values()[pipes[p * 3]]), 1), 0, 0);
        GL11.glPopMatrix();
    }
    GL11.glPopMatrix();
}

From source file:additionalpipes.client.gui.GuiTeleportManager.java

License:Minecraft Mod Public

@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
    super.drawGuiContainerForegroundLayer(mouseX, mouseY);

    float scrollPercent = scrollLine / (float) getScrollMax();
    int scrollBarLeft = guiLeft + xSize - 20;
    int scrollBarTop = guiTop + 18;
    int scrollBarBottom = scrollBarTop + 113;
    boolean isClicking = Mouse.isButtonDown(0);
    if (!wasClicking && isClicking && mouseX >= scrollBarLeft && mouseX < scrollBarLeft + 20
            && mouseY >= scrollBarTop && mouseY < scrollBarBottom) {
        isScrolling = needsScrollBars();
    }/* w  w w  .j  a  v a 2  s . c  om*/
    if (!isClicking) {
        isScrolling = false;
    }
    wasClicking = isClicking;
    if (isScrolling) {
        scrollPercent = (mouseY - scrollBarTop - 7.5F) / (scrollBarBottom - scrollBarTop - 20.0F);
        if (scrollPercent < 0.0F) {
            scrollPercent = 0.0F;
        } else if (scrollPercent > 1.0F) {
            scrollPercent = 1.0F;
        }
        scrollLine = (int) (scrollPercent * getScrollMax() + 0.5D);
        validateScrollLine();
    }

    fontRenderer.drawString(StringUtils.localize("container.teleportManager"), 8, 6,
            clientProps.propIsPublic.value ? 0x0000FF : 0x404040);
    fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, 130, 0x404040);

    RenderHelper.disableStandardItemLighting();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine.bindTexture(CREATIVE_TEXTURE);
    drawTexturedModalRect(xSize - 20, 18 + (int) (93 * scrollPercent), 232 + (needsScrollBars() ? 0 : 12), 0,
            12, 15);

    theMap = -1;
    int[] maps = clientProps.propMaps.value;
    if (maps.length == 0) {
        if (mouseX >= guiLeft + 8 && mouseX < guiLeft + 8 + 36 * MAPS_ROW && mouseY >= guiTop + 18
                && mouseY < guiTop + 18 + 36 * MAPS_COL) {
            String text = StringUtils
                    .localize(AdditionalPipes.disableLinkingUsage ? "gui.map.emptyHint.position"
                            : "gui.map.emptyHint.link");
            int width = fontRenderer.getStringWidth(text);
            GL11.glPushMatrix();
            GL11.glTranslatef(-guiLeft, -guiTop, 0);
            drawCreativeTabHoveringText(text, mouseX - 12 - width / 2, mouseY - 4);
            GL11.glPopMatrix();
        }
    } else if (currentMap == -1) {
        ItemStack mapStack = new ItemStack(Item.map, 1, 0);
        for (int i = 0; i < MAPS_COL; i++) {
            for (int j = 0; j < MAPS_ROW; j++) {
                int index = j + (scrollLine + i) * MAPS_ROW;
                if (index < maps.length) {
                    mapStack.setItemDamage(maps[index]);
                    MapData mapData = Item.map.getMapData(mapStack, mc.theWorld);
                    if (mapData != null) {
                        int x = 10 + j * 36;
                        int y = 20 + i * 36;
                        GL11.glPushMatrix();
                        GL11.glTranslatef(x, y, 0.0F);
                        GL11.glScalef(0.25F, 0.25F, 0.25F);
                        renderPipeMap(maps[index], mapData);
                        GL11.glPopMatrix();
                    }
                }
            }
        }
        int index = getMapIndexAtPos(mouseX, mouseY);
        if (index >= 0 && index < maps.length) {
            theMap = index;
            mapStack.setItemDamage(maps[index]);
            drawItemStackTooltip(mapStack, mouseX - guiLeft + 8, mouseY - guiTop + 8);
        }
    } else {
        MapData mapData = Item.map.getMapData(new ItemStack(Item.map, 1, maps[currentMap]), mc.theWorld);
        if (mapData != null) {
            GL11.glPushMatrix();
            GL11.glTranslatef(7, guiTop, 0.0F);
            GL11.glScalef(1.25F, 1.25F, 1.25F);
            renderPipeMap(maps[currentMap], mapData);
            GL11.glPopMatrix();
        }
    }
    RenderHelper.enableGUIStandardItemLighting();
}

From source file:adrianton.gloptat.plotter.Displayer.java

License:Open Source License

private void box() {
    float spx = -rezx / 2f;
    float spy = -rezy / 2f;
    float epx = spx + rezx;
    float epy = spy + rezy;

    GL11.glPushMatrix();//from   ww w .ja v  a 2  s  . c o  m
    GL11.glTranslatef(0, 0, (float) (minc + (maxc - minc) / 2));
    GL11.glScalef(rezx / 2f, rezy / 2f, (float) (maxc - minc) / 2f);
    Box.call();
    GL11.glPopMatrix();
}

From source file:advancedbrewing.renderer.ItemGlintOverlayRenderer.java

License:Minecraft Mod Public

private void renderItem3D(ItemRenderType type, ItemStack itemStack, Object... data) {
    TextureManager renderEngine = FMLClientHandler.instance().getClient().renderEngine;
    Tessellator tessellator = Tessellator.instance;

    if (this.shouldRenderOverlay(itemStack)) {
        // render colored overlay
        renderEngine.bindTexture(renderEngine.getResourceLocation(itemStack.getItemSpriteNumber()));
        this.setColorByItemStack(itemStack);
        Icon icon = this.getIcon(itemStack, 0);
        ItemRenderer.renderItemIn2D(tessellator, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(),
                icon.getIconWidth(), icon.getIconHeight(), 0.0625F);

        // render glint
        if (itemStack.hasEffect(0)) {
            renderEngine.bindTexture(ItemGlintOverlayRenderer.RES_ITEM_GLINT);

            GL11.glDepthFunc(GL11.GL_EQUAL);
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glMatrixMode(GL11.GL_TEXTURE);

            GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
            GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F);

            // first pass
            GL11.glPushMatrix();// w w w  .  ja  v  a2s  .co m
            GL11.glScalef(0.125F, 0.125F, 0.125F);
            float f9 = 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.0625F);
            GL11.glPopMatrix();

            // second pass
            GL11.glPushMatrix();
            GL11.glScalef(0.125F, 0.125F, 0.125F);
            f9 = 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.0625F);
            GL11.glPopMatrix();

            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glDepthFunc(GL11.GL_LEQUAL);
        }
    }

    // render uncolored icon
    renderEngine.bindTexture(renderEngine.getResourceLocation(itemStack.getItemSpriteNumber()));
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    Icon icon = this.getIcon(itemStack, 1);
    ItemRenderer.renderItemIn2D(tessellator, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(),
            icon.getIconWidth(), icon.getIconHeight(), 0.0625F);
}

From source file:analog.clock.AnalogClock.java

private void loop() {
    try {/*from w ww  . j av  a  2  s . co m*/
        for (int i = 0; i < 1000; i++) {
            GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
            drawCircle(0.25, 8); // draw the sun

            earthOrbitAngle += 1;
            moonOrbitAngle += 5;
            earthAxisAngle += 10;

            GL11.glPushMatrix();
            GL11.glRotatef(earthOrbitAngle, 0, 0, 1);
            GL11.glTranslatef(0.75f, 0.0f, 0.0f);
            GL11.glPushMatrix();
            GL11.glRotatef(earthAxisAngle, 0, 0, 1);
            GL11.glScalef(0.5f, 0.5f, 0.5f);
            drawCircle(0.25, 3); // draw the earth
            GL11.glPopMatrix();

            GL11.glPushMatrix();
            GL11.glRotatef(moonOrbitAngle, 0, 0, 1);
            GL11.glTranslatef(0.25f, 0.0f, 0.0f);
            GL11.glScalef(0.25f, 0.25f, 0.25f);
            drawCircle(0.25, 5); // draw the moon
            GL11.glPopMatrix();
            GL11.glPopMatrix();

            Thread.sleep(10);
            GLFW.glfwSwapBuffers(window);
        }
    } catch (InterruptedException ex) {
        Logger.getLogger(AnalogClock.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:appeng.client.ClientHelper.java

License:Open Source License

@Override
public void doRenderItem(final ItemStack itemstack, final World w) {
    if (itemstack != null) {
        final EntityItem entityitem = new EntityItem(w, 0.0D, 0.0D, 0.0D, itemstack);
        entityitem.getEntityItem().stackSize = 1;

        // set all this stuff and then do shit? meh?
        entityitem.hoverStart = 0;//from   www . j a  v a2  s  .co m
        entityitem.age = 0;
        entityitem.rotationYaw = 0;

        GL11.glPushMatrix();
        GL11.glTranslatef(0, -0.04F, 0);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        // GL11.glDisable( GL11.GL_CULL_FACE );

        if (itemstack.isItemEnchanted() || itemstack.getItem().requiresMultipleRenderPasses()) {
            GL11.glTranslatef(0.0f, -0.05f, -0.25f);
            GL11.glScalef(1.0f / 1.5f, 1.0f / 1.5f, 1.0f / 1.5f);
            // GL11.glTranslated( -8.0, -12.2, -10.6 );
            GL11.glScalef(1.0f, -1.0f, 0.005f);
            // GL11.glScalef( 1.0f , -1.0f, 1.0f );

            final Block block = Block.getBlockFromItem(itemstack.getItem());
            if ((itemstack.getItemSpriteNumber() == 0 && block != null
                    && RenderBlocks.renderItemIn3d(block.getRenderType()))) {
                GL11.glRotatef(25.0f, 1.0f, 0.0f, 0.0f);
                GL11.glRotatef(15.0f, 0.0f, 1.0f, 0.0f);
                GL11.glRotatef(30.0f, 0.0f, 1.0f, 0.0f);
            }

            final IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack,
                    IItemRenderer.ItemRenderType.ENTITY);
            if (customRenderer != null && !(itemstack.getItem() instanceof ItemBlock)) {
                if (customRenderer.shouldUseRenderHelper(IItemRenderer.ItemRenderType.ENTITY, itemstack,
                        IItemRenderer.ItemRendererHelper.BLOCK_3D)) {
                    GL11.glTranslatef(0, -0.04F, 0);
                    GL11.glScalef(0.7f, 0.7f, 0.7f);
                    GL11.glRotatef(35, 1, 0, 0);
                    GL11.glRotatef(45, 0, 1, 0);
                    GL11.glRotatef(-90, 0, 1, 0);
                }
            } else if (itemstack.getItem() instanceof ItemBlock) {
                GL11.glTranslatef(0, -0.04F, 0);
                GL11.glScalef(1.1f, 1.1f, 1.1f);
                GL11.glRotatef(-90, 0, 1, 0);
            } else {
                GL11.glTranslatef(0, -0.14F, 0);
                GL11.glScalef(0.8f, 0.8f, 0.8f);
            }

            RenderItem.renderInFrame = true;
            RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
            RenderItem.renderInFrame = false;
        } else {
            GL11.glScalef(1.0f / 42.0f, 1.0f / 42.0f, 1.0f / 42.0f);
            GL11.glTranslated(-8.0, -10.2, -10.4);
            GL11.glScalef(1.0f, 1.0f, 0.005f);

            RenderItem.renderInFrame = false;
            final FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
            if (!ForgeHooksClient.renderInventoryItem(BLOCK_RENDERER, Minecraft.getMinecraft().renderEngine,
                    itemstack, true, 0, 0, 0)) {
                ITEM_RENDERER.renderItemIntoGUI(fr, Minecraft.getMinecraft().renderEngine, itemstack, 0, 0,
                        false);
            }
        }

        GL11.glPopMatrix();
    }
}

From source file:appeng.client.gui.widgets.GuiImgButton.java

License:Open Source License

@Override
public void drawButton(final Minecraft par1Minecraft, final int par2, final int par3) {
    if (this.visible) {
        final int iconIndex = this.getIconIndex();

        if (this.halfSize) {
            this.width = 8;
            this.height = 8;

            GL11.glPushMatrix();/*from   ww  w  .  j  av  a 2s.c  o  m*/
            GL11.glTranslatef(this.xPosition, this.yPosition, 0.0F);
            GL11.glScalef(0.5f, 0.5f, 0.5f);

            if (this.enabled) {
                GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
            } else {
                GL11.glColor4f(0.5f, 0.5f, 0.5f, 1.0f);
            }

            par1Minecraft.renderEngine.bindTexture(ExtraBlockTextures.GuiTexture("guis/states.png"));
            this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition
                    && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;

            final int uv_y = (int) Math.floor(iconIndex / 16);
            final int uv_x = iconIndex - uv_y * 16;

            this.drawTexturedModalRect(0, 0, 256 - 16, 256 - 16, 16, 16);
            this.drawTexturedModalRect(0, 0, uv_x * 16, uv_y * 16, 16, 16);
            this.mouseDragged(par1Minecraft, par2, par3);

            GL11.glPopMatrix();
        } else {
            if (this.enabled) {
                GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
            } else {
                GL11.glColor4f(0.5f, 0.5f, 0.5f, 1.0f);
            }

            par1Minecraft.renderEngine.bindTexture(ExtraBlockTextures.GuiTexture("guis/states.png"));
            this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition
                    && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;

            final int uv_y = (int) Math.floor(iconIndex / 16);
            final int uv_x = iconIndex - uv_y * 16;

            this.drawTexturedModalRect(this.xPosition, this.yPosition, 256 - 16, 256 - 16, 16, 16);
            this.drawTexturedModalRect(this.xPosition, this.yPosition, uv_x * 16, uv_y * 16, 16, 16);
            this.mouseDragged(par1Minecraft, par2, par3);
        }
    }
    GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}