Jump to content

[Solved][1.6.2]Gui texture oversized.


Naiten

Recommended Posts

So, i try to open a gui, here's what i get:

bEePZZK.png

My gui texture:

EsuatPl.png

My draw gui class:

public class GuiTub extends GuiContainer{

public GuiTub(InventoryPlayer invPlayer, CherTub tub) {
	super(new ContainerTub(invPlayer, tub));
	xSize = 176;
	ySize = 149;
}

@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        Minecraft.getMinecraft().func_110434_K().func_110577_a(
        		new ResourceLocation("row:textures/gui/gui_tub.png"));
        int posx = (width - xSize) / 2;
        int posy = (height - ySize) / 2;
        drawTexturedModalRect(posx, posy, 0, 0, xSize, ySize);
}

}

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

Link to comment
Share on other sites

You are assigning new values to xSize and ySize, remove these new assignments and keep everything else. The reason is because you are assigning a new value to xSize and ySize, which GuiContainer uses these values to find the size of the inventory window in pixels. I recommend removing these assignments, then tell me how it went.

 

Change this

public GuiTub(InventoryPlayer invPlayer, CherTub tub) {
	super(new ContainerTub(invPlayer, tub));
	xSize = 176;
	ySize = 149;
}

 

to this

public GuiTub(InventoryPlayer invPlayer, CherTub tub) {
	super(new ContainerTub(invPlayer, tub));
}

 

and remove the new assignments

 

Also where you say,

Minecraft.getMinecraft().func_110434_K().func_110577_a(
        		new ResourceLocation("row:textures/gui/gui_tub.png"));

 

you don't need to create another instance, GuiContainer already has an instance of Minecraft, it looks like this

this.mc.func_110434_K().func_110577_a(yourtexturefile)

But you don't need to do the above if you don't want to, it will just decrease the amount of objects (and code that you have to write) and be much easier, totally up to you to change the above code.

 

If the above methods do not work, I recommend you still remove the new assignments of xSize and ySize, and use the furnace gui texture as your template, just paste over it and remove the furnace bar icons, keep all of the empty space. This worked for me with my gui.

 

Hope I have been of help to you

Link to comment
Share on other sites

Those assigned values are exact size of my texture. And i made my texture from chest one, there's no problem with it's size.

Anyway, if i remove those assignments, it works neither.

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

Link to comment
Share on other sites

public static void drawTexturedQuadFit(double x, double y, double width, double height, double zLevel){
	Tessellator tessellator = Tessellator.instance;
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(x + 0, y + height, zLevel, 0,1);
        tessellator.addVertexWithUV(x + width, y + height, zLevel, 1, 1);
        tessellator.addVertexWithUV(x + width, y + 0, zLevel, 1,0);
        tessellator.addVertexWithUV(x + 0, y + 0, zLevel, 0, 0);
        tessellator.draw();
}

sry for formatting,

 

 

this will fit the image entirelly inside the quad no matter what its size is (so you dont have to worry about stupid power of 2 wtv ass thing notch did)

just bind the texture and call this function

 

 

Minecraft.getMinecraft().renderEngine.func_somenumber_a(ResourceLocation);//bind texture
drawTexturedQuadFit(x, y, width, height, zLevel);//render nice image

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

 

... Nice utility code here ...

... Prevents frustration and gives more freedom with GUI textures ...

Minecraft.getMinecraft().renderEngine.func_somenumber_a(ResourceLocation);//bind texture
drawTexturedQuadFit(x, y, width, height, zLevel);//render nice image

 

Thank you!

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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