Jump to content

[1.7.10] gui being wierd. (and crashes) [I STILL NEED HELP!]


Recommended Posts

Posted

i made a block that opens up a crafting table gui when right clicked, but it seems like all the slots in the user's inventory are shifted one forwards and its being wierd. take a look:

i really don't know how to fix this. ive looked into overriding the crafting table container class and do some tweaks to it to make it work, but i figured if it works with the vanilal craftign table, then surely it should work with mine too. my gui class is different because i wanted to use a custom texture for it, but it essentially works the same way as the vanilla craftign table gui class. it crashes when you put an item in the last hotbar slot, because it is of course out of bounds.

 

code:

onBlockActivated in BlockVendorUInvent

public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float xF, float yF, float zF)
{
	int power = this.getPowered(world,x,y,z,0);
	if(power > 0 || power == 0)
	{
		if(world.isRemote)
		{
			ItemAudioLogSound.displayGuiScreen(player, x, y, z);;
		}
		return true;
	}
	return false;
}

GuiCraftingUInvent class

@SideOnly(Side.CLIENT)
public class GuiCraftingUInvent extends GuiContainer
{
private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation("bioshock:textures/gui/u_invent.png");

public GuiCraftingUInvent(InventoryPlayer inventory, World world, int x, int y, int z)
{
        super(new ContainerWorkbench(inventory, world, x, y, z));
}

/**
 * Draw the foreground layer for the GuiContainer (everything in front of the items)
 */
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)
{
	this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 1, 0x4C3C17);
}

protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_)
{
	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
	this.mc.getTextureManager().bindTexture(craftingTableGuiTextures);
	int k = (this.width - this.xSize) / 2;
	int l = (this.height - this.ySize) / 2;

	this.drawTexturedModalRect(k + this.xSize/4, l - 42, 0, 166, 84, 43);
	this.drawTexturedModalRect(k - 40, l, 0, 0, this.xSize + 80, this.ySize);
}
}

http://www.planetminecraft.com/member/sigurd4

I'm making the bioshock mod!

Posted

The tile entity is literally just empty. It's simply there to give the block a custom model. The gui shouldnt interact with it. Remember the crafting table has no tile entity, yet it has a gui! Mine works the excact same way except different texture.

And a gui handler?? Do i need that? Dang. Thats probably it, then.

http://www.planetminecraft.com/member/sigurd4

I'm making the bioshock mod!

Posted

displayGuiScreen in ItemAudioLogSound:

@SideOnly(Side.CLIENT)
public static void displayGuiScreen(EntityPlayer player, int x, int y, int z)
{
	Minecraft.getMinecraft().displayGuiScreen(new GuiCraftingUInvent(player.inventory, player.worldObj, x, y, z));
}

TileEntityVendorUInvent class:

public class TileEntityVendorUInvent extends TileEntity {}

i dont have a guihandler, though.

http://www.planetminecraft.com/member/sigurd4

I'm making the bioshock mod!

Posted

Yeah, you're definitely bypassing the handler... and using the base container... From the video - which is deceptive - I would guess its maybe a combination of syncing and slot locations? I had a similar issue once when the client was drawing a different screen (gui vs slot locations) than the server had. Is there a way to see all the code in one place, like a Git or something?

I'll need help, and I'll give help. Just ask, you know I will!

Posted

Well same here lol, but when you request a gui the handler is done through your proxies... it tells the server to open a TileEntity/container and the client the gui item, as gui is only on the client.  I will share something when I can.

I'll need help, and I'll give help. Just ask, you know I will!

  • 1 month later...

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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