Posted January 17, 20205 yr 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 January 17, 20205 yr by transfarmer vague title
January 17, 20205 yr 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 Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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)
January 17, 20205 yr Author 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 January 17, 20205 yr by transfarmer misspelled "sent" twice
January 17, 20205 yr 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 Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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)
January 17, 20205 yr Author I pushed my changes to the GitHub repository that I mentioned earlier. I will check these resources when I return home.
January 18, 20205 yr Author Thank you for your assistance; your code was very helpful. I also looked at the post that you linked. My issue is now solved.
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.