Jump to content

Recommended Posts

Posted

As detailed in this thread I made a few days ago I've had some problems syncing capability data to the client, I marked that thread as solved thinking I fixed the issue, but upon testing my mod in multiplayer I realized that I did nothing. To put it simply, I stored an instance of the capability in my main class and used that, which is wrong in many ways. I've restructured the capability in a way in which it should send an update packet to the client every time it's data is updated, but nothing is happening.

The update packet can be found here on GitHub,

the capability class that's sending the packet here,

and the code I'm trying to run here(method on line 39).

There aren't any errors in the debug.log, but it can be found here.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Posted
32 minutes ago, diesieben07 said:

This makes no sense. "Are we on the server? Okay. Then: Send a packet to the server." What? That does not work. And then immediately after you send a packet to the client..

Agreed, removed the first one.

 

33 minutes ago, diesieben07 said:

This is very wrong. Your capability is also created on the server, where this is now reaching across logical sides. This will also cause the check above to never be true, causing no packets to ever be sent

I've changed out the LazyOptional for something else, how is my capability being created on the server?

 

34 minutes ago, diesieben07 said:

Because your storage implementation uses your setters your code will try to send packets during reading from NBT. This will fail.

I've created a second version of the setters that doesn't send the packet.

 

35 minutes ago, diesieben07 said:

You have to sync the data in PlayerLoggedInEvent, PlayerChangedDimensionEvent and PlayerRespawnEvent as well, if you want it to be available on the client at all times.

Agreed, but first I'd like to fix what I already have.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Posted
9 hours ago, diesieben07 said:

No... no no no. The LazyOptional part was correct... The wrong part was accessing Minecraft#player...

I'm using LazyOptional again but now I'm not passing in Minecraft#player as the player, but now I'm passing in null so:

 

9 hours ago, diesieben07 said:

uses a null player. This will cause your onDataUpdated to immediately bail out.

 

10 hours ago, diesieben07 said:

without checking the logical side.

I've now added a check for the logical side before applying the capability.

 

9 hours ago, diesieben07 said:

Honestly, your capability should not allow for itself to be created with a null player.

I've added @Nonull on the player argument in the capability's constructor.

 

It seems my only problem is that I'm passing in null as the player in a few places causing 

10 hours ago, diesieben07 said:

onDataUpdated to immediately bail out.

, but I don't think I can pass in a non-null argument in these places without using Minecraft#player, how am I supposed the get a player besides Minecraft#player in my main class or my provider?

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Posted
22 minutes ago, diesieben07 said:

In the place where you attach the capability (AttachCapabilitiesEvent) you have the player available. You already use it, to attach your capability to.

Thanks for all the help, I fixed it by making a player object in my provider and passing that into the LazyOptional.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

  • Novârch changed the title to [SOLVED][1.15.2] Trouble with syncing capability data

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.