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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Without Network protocol fix mod, I get kicked with a Network Protocol error when on LAN. Also, both of these issues are caused by a Null Pointer Exception/Screen cannot be null in a "Client Bound Player Combat Kill Packet".
    • You need a new "items" folder at  resources/assets/yourmodid/ there you add for every item model a .json file with the exact item/block name and fill it like this if it's an item: { "model": { "type": "minecraft:model", "model": "yourmodid:item/youritem" } } and so if its a block: { "model": { "type": "minecraft:model", "model": "yourmodid:block/youritem" } } There is also a generator for it you can do namy crazy things with it which replaces the previous hard coded Item Properties implementaion method (Bow pulling animation for example). https://misode.github.io/assets/item/
    • Hello! I'm playing a modpack (custom made) with some friends, and we have the server running on BisectHosting. We encountered a bug with an entity from The Box Of Horrors mod, that would crash the game whenever someone nearby it would log in. We tried to fix it by: 1) Editing the player.dat files to change the location of the affected players (something I had done successfully previously) 2) Updating the version of the mod we had (0.0.8.2) to the latest alpha version (0.0.8.3 However, after doing both of those, none of us are able to join the server, and we get the following errors: Server side: https://pastebin.com/J5sc3VQN Client side: Internal Server Error (that's basically all I've gotten) Please help! I've tried restoring the player data to how it was before I made the changes (Bisect allows you to restore deleted files) and deleting all of my player data files and I still get the same error. Deleting Box Of Horrors causes the error: Failed to load datapacks, cannot continue with server load.
    • Hey there! I'm trying to create a simple mod for Forge 1.21.1 that adds a few custom banner patterns that don't require any banner pattern items. To be completely honest, this is my first time modding for Minecraft, so after setting up the project in Intellij, I copied the parts of the source code from this mod on CurseForge that dealt with adding and registering banner patterns, including the lang and banner_pattern .json files. From what I understand, to add a banner pattern that doesn't require a banner pattern item, I only needed to create the registries for each pattern like in here and then register it in the main java class like here on Line 54. Additionally, in the lang/en_us.json file, add in the names for each respective banner color, and in the data/minecraft/tags/banner_pattern/no_items_required.json file, add each banner pattern that does not require a banner pattern item to make a banner. The project is able to compile when loading in Forge which makes me assume that the file structure I have is correct, but on loading a Minecraft world, this error appears in console and the loom is subsequently blank. [Worker-Main-1/ERROR] [minecraft/TagLoader]: Couldn't load tag minecraft:no_item_required as it is missing following references: *lists every added entry in no_item_required.json* The message clearly states something went wrong regarding when trying to load in the registries from the mod, but I have no clue what could be wrong with the code I have. Attached below are screenshots of what I currently have. Java Main Class Banner Registry Class File Structure Error in Console upon loading a Minecraft world What the loom shows without minecraft:no_item_required    The original mod I copied still functions completely, so if anyone can figure out why the registries for the mod I'm making isn't working, that would be greatly appreciated!    
    • Please someone help me to know how can I fix this generation error in the trees! I already uninstalled and reinstalled several mods in my modpack and can't figure out what is causing it.    
  • Topics

×
×
  • Create New...

Important Information

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