beaucoralk Posted April 23, 2014 Posted April 23, 2014 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. Quote
Godis_apan Posted April 24, 2014 Posted April 24, 2014 http://www.minecraftforum.net/topic/1412300-147forgeblaueseichoerns-gui-tutorial/ Under the spoiler gui there should be an itemstack tutorial. Quote My mod for futher awesomeness: http://www.minecraftforum.net/topic/1714396-the-decopack-collection-v010-wip-made-a-signature-new-snapshot-1-screenshots-are-up-small-snapshot-1-is-out-for-147/#entry21250399
beaucoralk Posted April 24, 2014 Author Posted April 24, 2014 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 ? Quote
beaucoralk Posted April 24, 2014 Author Posted April 24, 2014 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 ! Quote
beaucoralk Posted April 24, 2014 Author Posted April 24, 2014 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 ! Quote
beaucoralk Posted April 25, 2014 Author Posted April 25, 2014 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 ? Quote
beaucoralk Posted April 25, 2014 Author Posted April 25, 2014 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 ? Quote
beaucoralk Posted April 25, 2014 Author Posted April 25, 2014 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 Quote
beaucoralk Posted April 25, 2014 Author Posted April 25, 2014 When I use "@SideOnly(Side.SERVER)" in onItemRightClick, I can't use correctly my item... Quote
Recommended Posts
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.