Skip to content

fix: avoid double player-data deserialization during async login - #126

Open
dev2pew wants to merge 1 commit into
RelativityMC:ver/1.21.8from
dev2pew:fix/1.21.8-async-login-player-data
Open

dev2pew wants to merge 1 commit into
RelativityMC:ver/1.21.8from
dev2pew:fix/1.21.8-async-login-player-data

Conversation

@dev2pew

@dev2pew dev2pew commented Sep 21, 2026

Copy link
Copy Markdown

Fixes #104

Problem

With use_async_chunks_on_login_v2=true, the async login path calls
PlayerManager#loadPlayerData before the normal player join.

PlayerManager#onPlayerConnect later calls loadPlayerData again on the
same ServerPlayerEntity.

This is unsafe for mod-owned player data that is not designed to be
deserialized twice. Cardinal Components API is one affected case. An
equipped Traveler's Backpack can be loaded during the VMP preload and then
cleared during the normal join load. The next player save persists the empty
component, which makes the item loss permanent.

This reproduces issue #104.

Change

The async preload no longer applies complete player data to the
ServerPlayerEntity.

It reads only the saved values needed to choose the chunk to preload:

  • Dimension;
  • Pos,

For the integrated-server host, the lookup uses a copy of the cached player
NBT. For other players, it reads the saved .dat or .dat_old data and
applies the normal player data fixer.

The resulting ReadView is used only for the dimension and position lookup.
The full player data is still deserialized once by the normal
PlayerManager#onPlayerConnect path.

This keeps async chunk loading enabled without running arbitrary mod player
deserialization twice.

Testing

Tested on Minecraft 1.21.8 with:

  • VMP 0.2.0+beta.7.208;
  • Traveler's Backpack 10.8.4;
  • Cardinal Components API 7.0.0-beta.1;
  • use_async_chunks_on_login_v2=true,

gradlew.bat clean build completes successfully.

The original failure reproduces on 0.2.0+beta.7.207: an equipped backpack
disappears after leaving and re-entering the world, and its saved wearable
component becomes empty.

With this patch, the backpack and its contents survive repeated save/rejoin
cycles while equipped, in the normal inventory, and after being dropped and
picked up.

The same test also passes with C2ME installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant