Jump to content

Recommended Posts

Posted (edited)

I have a capability whose serializeNBT, writeNBT, deserializeNBT, and readNBT methods are called, and its information is preserved after disconnecting a server; however, the client's information is not updated. It sends a packet to the server after clicking a button in a custom GUI and the server modifies the capability attached to the sender of the packet. Should the server send a packet back? If so, then how? I tried using the shorter method described in the Forge documentation, but instead of a PlayerEntity I need a Supplier<PlayerEntity> and I doubt that I have to make a new class for it, so what should I do?

My packet class is available on GitHub.

Edited by transfarmer
vague title
Posted
2 hours ago, transfarmer said:

Should the server send a packet back?

Yes

2 hours ago, transfarmer said:

instead of a PlayerEntity I need a Supplier<PlayerEntity> and I doubt that I have to make a new class for it, so what should I do?

Learn about Functional Interfaces in Java. () -> playerEntity.

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted (edited)
1 hour ago, Cadiboo said:

Learn about Functional Interfaces in Java. () -> playerEntity.

Thank you. So I did.

Currently, I handle packets sent to a client and packets sent to the server inside the same function, separated by a check on FMLEnvironment.dist. Is this correct? My client receives information back from the server and does what the server did (it modified a capability), based on its response, and my client appears synchronized with the server. However, when the former connects to the latter, the capability seems to have returned to its default state on the client side. Do I have to use something like a UserJoinedEvent to correct this?

 

edit: I used PlayerLoggedInEvent to send a packet to my client and it seems to work. If what I did is acceptable would not cause problems, then this issue is solved. Otherwise, please enlighten me.

Edited by transfarmer
misspelled "sent" twice
Posted
7 hours ago, transfarmer said:

Currently, I handle packets sent to a client and packets sent to the server inside the same function, separated by a check on FMLEnvironment.dist. Is this correct?

Uh, show your code please.

Heres a request packet (client -> server). I register it here. Remember to mark it as handled.

Heres is the response packet (server -> client). I register it here.

Also take a look at this post

 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

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.