Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

First of all, my gui uses more then 256*256 texture, so i needed to rewrite drawTexturedModalRect().

It's done, but now i'm having a lot of problems:

None of methods are not working properly to draw texture above old place (ex: burning progress in furnace, etc), because

1) i don't unedrstand properly what does x, y, u, v, width, height means and i can't figure it out.

2) i have too big texture

Also i found that if change screen size of mc, position and square changes...? I'm not sure if it must happen.

Modified drawTexturedModalRect:

public void drawTexturedModalRect(int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight)
{
	float f = 1F / (float)textureWidth;
	float f1 = 1F / (float)textureHeight;
	Tessellator tessellator = Tessellator.instance;
	tessellator.startDrawingQuads();
	tessellator.addVertexWithUV((double)(x), (double)(y + height), 0, (double)((float)(u) * f), (double)((float)(v + height) * f1));
	tessellator.addVertexWithUV((double)(x + width), (double)(y + height), 0, (double)((float)(u + width) * f), (double)((float)(v + height) * f1));
	tessellator.addVertexWithUV((double)(x + width), (double)(y), 0, (double)((float)(u + width) * f), (double)((float)(v) * f1));
	tessellator.addVertexWithUV((double)(x), (double)(y), 0, (double)((float)(u) * f), (double)((float)(v) * f1));
	tessellator.draw();
}

and it calling code in drawGuiContainerBackgroundLayer

drawTexturedModalRect(guiLeft + 154, guiTop + 83, 13, 13, guiLeft + 248, guiTop + 0, 288, 288);

My texture:

03BajQT.png

Help me please!

  • Author

You might want to rework that texture to fit into 256x256, like this:

VRsEqgD.png

 

You will need to draw it in 2 parts, but power-of-two textures (256 = 28) are more efficient in graphics cards (and older cards only support those kinds of textures).

Thanks! I know that i can fit in 256*256, but gui it self draws fine, like expected (drawTexturedModalRect(guiLeft, guiTop, 0, 0, 247, 248, 288, 288); )

 

EDIT: i think i figured it out:

drawTexturedModalRect(x, y, u, v, width, height);

x and y being coordinates of top left corner of place to place image. Must always begin with guiLeft + and guiTop +

u and v being place of top left corner of image to take. MUST NEVER USE guiLeft and guiTop

width and height being size of image to draw...

Pretty simple. FAIL.

 

  • Author

Ok. Now i have another problem:

TileEntity isn't get properly for GUIand with wrong data:

GUI:

public GUIToolsCompressor(InventoryPlayer inventory, TileEntityToolsCompressor tileentity) {
	super(new ContainerToolsCompressor(inventory, tileentity));
	toolsCompressor = tileentity;
	System.out.println(toolsCompressor + " " + toolsCompressor.isWorking());
	this.xSize = 247;
	this.ySize = 248;
}

onBlockActivated:

public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ){
	if(world.isRemote){
		return true;
	} else if(!player.isSneaking()) {
		TileEntityToolsCompressor te = (TileEntityToolsCompressor) world.getTileEntity(x, y, z);
		System.out.println(te + " " + te.isWorking());
		if(te != null){
			FMLNetworkHandler.openGui(player, MainToolsCompressor.instance, MainToolsCompressor.guiIdToolsCompressor, world, x, y, z);
		}

		return true;
	} else {
		return false;
	}
}

Console:

[16:20:05] [server thread/INFO] [sTDOUT]: [code.elix_x.mods.toolscompressor.blocks.ToolsCompressor:onBlockActivated:61]: code.elix_x.mods.toolscompressor.blocks.TileEntityToolsCompressor@43c0a9cb true
[16:20:05] [Client thread/INFO] [sTDOUT]: [code.elix_x.mods.toolscompressor.gui.GUIToolsCompressor:<init>:24]: code.elix_x.mods.toolscompressor.blocks.TileEntityToolsCompressor@75f2a654 false

Why tile entity's data is different in gui???

 

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.