Jump to content

Recommended Posts

Posted

I am triing to create a custom GuiButton, so I created a new class overwrote GuiButton and changed the drawButton method.

Problem is that I dont know how to create a ResourceLocation that is leading into the right package. I want to deposit my texture in the assets.basewars.textures.gui (e.g. assets.basewars.textures.gui.furnace)

Sadly this isnt working

new ResourceLocation("basewars:gui/"+texture); 

Anyone here who knows?

Greetz Fail

Posted

Example:

new ResourceLocation("modid:path/to/image/image.png");

That will result in

assets/modid/path/to/image/image.png

.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Thank you, it is working now.

Problem is that the texture seems to scale really strange.

I created the button to be 16x16 pixel big, which is exactly the size of the texture I am using.

 

 

 

Link to the graphic below

http://www.directupload.net/file/d/4018/ima7zxlf_png.htm

 

TexturedButton

public class TexturedButton extends GuiButton{

protected ResourceLocation buttonTextures;

public TexturedButton(int buttonId, int x, int y, int widthIn,
		int heightIn, String buttonText, String texture) {
	super(buttonId, x, y, widthIn, heightIn, buttonText);
	buttonTextures= new ResourceLocation("basewars:textures/gui/"+texture+".png");
}

@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY)
    {
        if (this.visible)
        {
            FontRenderer fontrenderer = mc.fontRendererObj;
            mc.getTextureManager().bindTexture(buttonTextures);
            GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
            this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
            int k = this.getHoverState(this.hovered);
            GlStateManager.enableBlend();
            GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
            GlStateManager.blendFunc(770, 771);
            this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + k * 20, this.width / 2, this.height);
            this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + k * 20, this.width / 2, this.height);
            this.mouseDragged(mc, mouseX, mouseY);
            int l = 14737632;

            if (packedFGColour != 0)
            {
                l = packedFGColour;
            }
            else if (!this.enabled)
            {
                l = 10526880;
            }
            else if (this.hovered)
            {
                l = 16777120;
            }
        }
    }
}

Posted

Nope and nope.

 

drawTexturedModalRect always takes 256x256 (resized with resolution, so e.g 512 or 1024) image as Resource.

 

You need to make your button image be insie 256x256 palette and then choose coordinates for it to draw.

 

EDIT

Note - there is also method +"withCustomSize" or something like that. That one allows you to have custom sized png.

 

 

1.7.10 is no longer supported by forge, you are on your own.

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.