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.

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

Featured Replies

Posted

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.

  • Author

http://www.minecraftforum.net/topic/1412300-147forgeblaueseichoerns-gui-tutorial/

 

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 ?

  • Author

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 :) !

  • Author

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 :) !

  • Author

Ok, so how I can do that ? Transform my PacketChangeItemStack to, PacketItemStackGui, and I just add the player, the gui.class, the itemstack and the slot number of the gui ? or not ?

Ok it's not that, how can I make that u say ?

  • Author

Ok I changed my Packet, and my function to save the nbttagcompound item can u look at my change and said me if it's great like that ?

Gist changing, look at revision if u want see more easily : https://gist.github.com/beaucoralk/11235143

 

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

  • Author

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 (
onItemRightClick

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

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.