Jump to content

[1.8]Gui drawLine & drawRect broken


poopsicle

Recommended Posts

I am not new to java, but am to OPGL, and minecraft logic in terms of whatever mojang has decided todo...

 

Im trying to draw a button, and on the button is a little meter. But the bar (line will not render), the following methods do not work at all for me. Regardless if im using it from within a button subclass or the guiScreen.

 

-drawRect

-drawHorizonalRect

-drawVerticalRect

 

@Override
    public void drawButton(Minecraft mc, int mouseX, int mouseY) {
        if (this.visible) {
            mc.getTextureManager().bindTexture(texture);
            this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
            GlStateManager.enableBlend();
            GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
            GlStateManager.blendFunc(770, 771);

            int baseX = this.xPosition;
            int baseY = this.yPosition + (this.id * 25);
            drawTexturedModalRect(baseX, baseY, 0, 0, 35, 22);
            drawHorizontalLine(baseX + 15, baseX + 7, baseY + 20, 64_000);//meter
            mc.getRenderItem().renderItemIntoGUI(new ItemStack(Item.getByNameOrId("minecraft:diamond_axe")), baseX, baseY + 2);
            this.mouseDragged(mc, mouseX, mouseY);
            mc.fontRendererObj.drawString("5%"+, baseX, baseY + 7, 3947580);
        }
    }

 

P.S. bbcodes and such dont seem to want to work, i only knew the code one from the top of my head.

Link to comment
Share on other sites

I don't know the default parameters of drawHorizontalLine, but that (the arguments you passed, particularly '64_000') does seem odd to me. Maybe compare it to the GUI/GUI screen methods, and make sure you have the right parameters/arguments. I know the functions aren't broken since I used them before without issue.

Link to comment
Share on other sites

The arguments are at least for HorizontalLine(srcX, destX, yPos, color) so 64_000, is the color, and its a bright green. No color shows up, even if put in hex format, or just a 0 is used(black).

 

The arguments are at least for HorizontalLine(srcX, destX, yPos, color) so 64_000 is the color, and its a bright green. No color shows up, even if put in hex format, or just a 0 is used(black).

Link to comment
Share on other sites

Also, a nice way to use colors is to use java.awt.Color

 

So in your class, you can have a Color field like so:

 

Color lineColor = new Color(0,255,0,255);

 

Then when you want to use the color integer, use

 

lineColor.getRGB();

 

Though the method is getRGB, it will also return with the alpha bits.

 

Doing so also helps make the code nice to read, and involves less guess work for the person viewing the code.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.