Jump to content

Recommended Posts

Posted

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.

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

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

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

Posted
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!

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

Posted
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!

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.