Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.14.4] Deserializing NBT on the client


Recommended Posts

I have a contraption that renders static entities, meaning the entities don't exist in the world.

The entity NBT must be read before the render to conserve information such as sheep color or entity age.

This used to work fine for all cases in 1.12, but I'm having trouble with Villagers and Foxes.


I'll illustrate my issue for foxes:


First, I call IForgeEntity#deserializeNBT.

That then calls Entity#read, which eventually calls Entity#readAdditional.


For foxes, that method then calls a method of FoxEntity called "func_213501_ej".

That function adds attack goals to the fox. Problem is, that those attack goals haven't been initialized yet and are null, causing a NPE further down the line in the TargetSelector class.


One potential solution that I see for this is that I call MobEntity#registerGoals before the NBT read. However, I would need to use reflection for that.

MobEntity#registerGoals is usually called from the MobEntity constructor but registerGoals only gets executed when the world is not remote. 


But I wonder, how does vanilla do it? I mean the game reads the NBT on the client at some point, but doesn't get any crashes from uninitialized AI Goals...

Am I calling the wrong serialize/deserialize functions?


Link to comment
Share on other sites

5 hours ago, diesieben07 said:

It does not.

Yeah, after a few hours of stepping through the debugger I noticed that too... How does the client then acquire an updated version of entities from the server? Is it a packet? (Probably)


Do you see any other solution for my problem?

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.

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.


  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.