Posted July 16, 20178 yr I have a gui that needs to have an EntityPlayer and an ItemStack passed into its constructor to work properly. The problem is that I don't know how to do this in a GuiHandler. I'm having trouble describing it, but I cannot get this value from any of the parameters passed into getClientGuiElement. Feel free to ask for code, I just don't really know what to show you currently.
July 16, 20178 yr 1 minute ago, That_Martin_Guy said: I have a gui that needs to have an EntityPlayer and an ItemStack passed into its constructor to work properly. The problem is that I don't know how to do this in a GuiHandler. I'm having trouble describing it, but I cannot get this value from any of the parameters passed into getClientGuiElement. Feel free to ask for code, I just don't really know what to show you currently. Where is the ItemStack stored? VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
July 16, 20178 yr Author Just now, Animefan8888 said: Where is the ItemStack stored? In a list stored in a tile entity. The way I want to do this is to call the method getRandomCard, but if I called it every time I opened the gui it would get a different card. This is not what I want since I have a list of players that are supposed to get the same card, and if I got a random card every time I opened the gui they would get different ones.
July 16, 20178 yr Just now, That_Martin_Guy said: In a list stored in a tile entity. The way I want to do this is to call the method getRandomCard, but if I called it every time I opened the gui it would get a different card. This is not what I want since I have a list of players that are supposed to get the same card, and if I got a random card every time I opened the gui they would get different ones. You will need to use a Capabilty and attach it to the player to store the card they are supposed to get. And how is the player opening the gui, right clicking on a block? If so you can get the TileEntity from there and get the initial card. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
July 16, 20178 yr Author 1 minute ago, Animefan8888 said: You will need to use a Capabilty and attach it to the player to store the card they are supposed to get Seems like the best solution. Really the last thing I would think of, but probably the best one for my situation. Thanks!
July 16, 20178 yr Just now, That_Martin_Guy said: Seems like the best solution. Really the last thing I would think of, but probably the best one for my situation. Thanks! This is also very vital. 2 minutes ago, diesieben07 said: Use a custom packet to send the info to the client. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
July 16, 20178 yr Author I already open it via a custom packet. Do I need to do anything else other than the usual packet handling you do with capabilities? Edited July 16, 20178 yr by That_Martin_Guy
July 16, 20178 yr Author 4 minutes ago, diesieben07 said: If you are using a custom packet already there is no point in using an IGuiHandler, just open the GUI directly from the packet. And then you can also just include the ItemStack directly with the packet. Ah, thank you for the heads up! That's much simpler than setting up an entire capability system. Thanks!
July 16, 20178 yr Author 1 minute ago, diesieben07 said: You will still need the capability to actually store the stack. I mean, it has to go somewhere, right? Very true, didn't think about that. Thanks again!
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.