Jump to content

GUI From Item


Sleepwalkerx

Recommended Posts

Hello. In my mod, I need my item to open the gui when the left mouse button is pressed and change the properties of the same item. I figured out how to open my gui with -> NetworkHooks :: openGui. However, I have 2 questions.
1) How to transfer the subject on which I opened?
2) How the client and server parts work. That is, I do not understand how to change the nbt tag of an item from Sceen(such as pressing a button), which works on the client, and so that this is on the server?

Also, I essentially need to register my Container with Forge, but this registration is done through the IFactory method, which forces it to adhere to one pattern.
In general, please help me to understand this all in advance thanks.

 

I also wanted to ask for a bonus, is it possible to open Gui by their registration id?

 

MC version ->1.15.2

Edited by Sleepwalkerx
Link to comment
Share on other sites

1. Transfer what subject? The focus of the screen? It's always on the currently open screen.

2. Changing anything on the client does not work, you would need to send a packet back to the server with the change or have the logic execute on the server (preferably the latter).

On 5/22/2021 at 1:57 PM, Sleepwalkerx said:

Also, I essentially need to register my Container with Forge, but this registration is done through the IFactory method, which forces it to adhere to one pattern.

It's a factory to create a container for a specific circumstance. It's not supposed to be reusable for every single thing you do. If you wanted that, do some inheritance to make it to the point where the amount of code needed to modify is minimal.

On 5/22/2021 at 1:57 PM, Sleepwalkerx said:

I also wanted to ask for a bonus, is it possible to open Gui by their registration id?

Screens don't have a registry object, they are only present on the logical client. They can be attached to containers to give a server a client form or they can just be standalone. If you're going to open a screen, you can simply just call the display screen method either in Minecraft or ClientPlayerEntity similar to how the sign does it.

Link to comment
Share on other sites

57 minutes ago, ChampionAsh5357 said:

1. Transfer what subject? The focus of the screen? It's always on the currently open screen.

2. Changing anything on the client does not work, you would need to send a packet back to the server with the change or have the logic execute on the server (preferably the latter).

It's a factory to create a container for a specific circumstance. It's not supposed to be reusable for every single thing you do. If you wanted that, do some inheritance to make it to the point where the amount of code needed to modify is minimal.

Screens don't have a registry object, they are only present on the logical client. They can be attached to containers to give a server a client form or they can just be standalone. If you're going to open a screen, you can simply just call the display screen method either in Minecraft or ClientPlayerEntity similar to how the sign does it.

Thank you very much for your answer, but while I was waiting for the answer I figured it out myself. Thanks to the developer Botania, I took an example from there. However, I have another question about the GUI, I have already posted it on the forum.
Thank you very much for your help!

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.

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.