Jump to content

Recommended Posts

Posted

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.

Posted

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

Posted

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.

Posted

Oh my. I've forgot that texture file must be sized in powers of 2. It's ok now.

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

Posted

stop using this method

drawTexturedModalRect(posx, posy, 0, 0, xSize, ySize);

cmon its fucking retarded, i have no idea why notch did that

 

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

-hydroflame, author of the forge revolution-

Posted

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-

Posted

It's easier to resize image canvas than write additional code. I don't get any problems with powers of 2.

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

Posted

its a static method, you code that once, not every time you draw something

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

-hydroflame, author of the forge revolution-

Posted

I haven't said anything about 'every time i draw'.

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

Posted

 

... 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...

Posted

Maybe you'll find another place for discussing your genius codes? This topic has it's problem solved and it should be locked.

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

Posted

I was waiting to get sure nobody has to add something on-topic. Nobody has.

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

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.