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

    • i managed to fix it by reinstalling the modpack and re-add all the extra mods I've had previously.
    • Ah, it appears I spoke too soon, I still need a little help here. I now have the forceloading working reliably.  However, I've realized it's not always the first tick that loads the entity.  I've seen it take anywhere from 2-20ish to actually go through, in which time my debugging has revealed that the chunk is loaded, but during which time calling  serverLevelIn.getEntity(uuidIn) returns a null result.  I suspect this has to do with queuing and how entities are loaded into the game.  While not optimal, it's acceptable, and I don't think there's a whole ton I can do to avoid it. However, my concern is that occasionally teleporting an entity in this manner causes a lag spike.  It's not every time and gives the appearance of being correlated with when other chunks are loading in.  It's also not typically a long spike, but can last a second or two, which is less than ideal.  The gist of how I'm summoning is here (although I've omitted some parts that weren't relevant.  The lag occurs before the actual summon so I'm pretty confident it's the loading, and not the actual summon call). ChunkPos chunkPos = new ChunkPos(entityPosIn); if (serverLevelIn.areEntitiesLoaded(chunkPos.toLong())) { boolean isSummoned = // The method I'm using for actual summoning is called here. Apart from a few checks, the bulk of it is shown later on. if (isSummoned) { // Code that runs here just notifies the player of the summon, clears it from the queue, and removes the forceload } } else { // I continue forcing the chunk until the summon succeeds, to make sure it isn't inadvertently cleared ForgeChunkManager.forceChunk(serverLevelIn, MODID, summonPosIn, chunkPos.x, chunkPos.z, true, true); } The summon code itself uses serverLevelIn.getEntity(uuidIn) to retrieve the entity, and moves it as such.  It is then moved thusly: if (entity.isAlive()) { entity.moveTo(posIn.getX(), posIn.getY(), posIn.getZ()); serverLevelIn.playSound(null, entity, SoundEvents.ENDERMAN_TELEPORT, SoundSource.NEUTRAL, 1.0F, 1.0F); return true; } I originally was calling .getEntity() more frequently and didn't have the check for whether or not entities were loaded in place to prevent unnecessary code calls, but even with those safety measures in place, the lag still persists.  Could this just be an issue with 1.18's lack of optimization in certain areas?  Is there anything I can do to mitigate it?  Is there a performance boosting mod I could recommend alongside my own to reduce the chunk loading lag? At the end of the day, it does work, and I'm putting measures in place to prevent players from abusing the system to cause lag (i.e. each player can only have one queued summon at a time-- trying to summon another replaces the first call).  It's also not an unacceptable level of lag, IMO, given the infrequency of such calls, and the fact that I'm providing the option to toggle off the feature if server admins don't want it used.  However, no amount of lag is ideal, so if possible I'd love to find a more elegant solution-- or at least a mod recommendation to help improve it. Thanks!
    • When i start my forge server its on but when i try to join its come a error Internal Exception: java.lang.OutOfMemoryError: Requested array size exceeds VM limit Server infos: Linux Minecraft version 1.20.1 -Xmx11G -Xms8G
    • Also add the latest.log from your logs-folder
  • Topics

×
×
  • Create New...

Important Information

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