Jump to content

[1.7.2][SOLVED] Can't change a ItemStack properties in my Custom GuiContainer


Recommended Posts

Hello all,


I need your help for create a custom "GuiContainer" applied on an "ItemStack" with a Right Click. For my exemple, it's a "ItemStack" (item Plan) who will contain many others "ItemStack" to make a plan. I want use the "NBTTagCompound" of this item plan to save all the "ItemStack" who are containing into my item plan.


Here, my code : https://gist.github.com/beaucoralk/11235143


I realy need your help, because when I change the NBTTagCompound of my item in my Container, It don't change in real...

Please help me !


Sorry for my bad english.

Minecraftly, Kevin BEAUCORAL.

Link to comment
Share on other sites



Under the spoiler gui there should be an itemstack tutorial.

Thanks for you help but my problem it's not than I can't open a gui on a Right Click of ItemStack your link don't help me more. Look my code into the gist to understand my problem !

My problem it's that, after Right Click on my Item (ItemPlan) I want to change the properties of this Item who are RightClicked with my Gui, like a ItemBook, and I don't arrive to change it...


I think the problem it's the GuiHandler I don't do the good thing...


Someone else can help me ?

Link to comment
Share on other sites

You are changing the ItemStack from the GuiScreen. GuiScreen is only on the client side, but you need to change things on the server side. You will need to send packets.

Realy big thanks for your help diesieben07.

How and where ? Where in my GuiScreen I'm changing the ItemStack ? I changing the content of ItemStack into my Container who are used by the "public Object getServerGuiElement".

U can use my gist (modifiy) to show me :) !

Link to comment
Share on other sites

Done !!!


I help me by this page : http://www.minecraftforge.net/wiki/Netty_Packet_Handling

and this topic : http://www.minecraftforge.net/forum/index.php?topic=17242.0


I change my gist if someone want help about subject : https://gist.github.com/beaucoralk/11235143


In fact, we need to create a packet for send a modification of an item... it's strange, why minecraft don't already have a packet when changing a itemstack ? or I don't see it...

I create a PacketPipeline class, a PacketChangeItemStack class who read a decode a buffer ItemStack and encode a ItemStack to buffer.

And I use my PacketPipeline to send a new PacketChangeItemStack, and it's work fine :) !

Link to comment
Share on other sites

Looks good now. You can replace the .getClass() == XY.class check with an instanceof XY, that is going to perform better and looks nicer.


I've a question, why the function "onGuiClosed()" is called when I open my custom Gui ?

Because you are opening the GUI twice, once on the client, once on the server (

get's called both sides). You should only open on the server, it will then tell the client to open.

Ok thanks realy big thanks for your help !!


I was wondering if you could help me to progress my plugin by testing when the versions are finished? U can see all features and the advancement to my github and on the plugin repo for my mod : https://github.com/beaucoralk/labnetwork-public/issues

Link to comment
Share on other sites

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.

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.


  • Create New...

Important Information

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