Skip to content

Commit

Permalink
Fix respawning not loading chunks
Browse files Browse the repository at this point in the history
We need to copy the real player field and view distance holder
object over, as Vanilla re-creates ServerPlayer objects unlike
CraftBukkit.
  • Loading branch information
Spottedleaf committed Jun 18, 2024
1 parent ac971be commit 502cee8
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,19 @@ private void init(final CallbackInfo ci) {
public final RegionizedPlayerChunkLoader.ViewDistanceHolder moonrise$getViewDistanceHolder() {
return this.viewDistanceHolder;
}

/**
* @reason Copy player state when respawning
* @author Spottedleaf
*/
@Inject(
method = "restoreFrom",
at = @At(
value = "HEAD"
)
)
private void copyRealPlayer(ServerPlayer from, boolean bl, CallbackInfo ci) {
this.isRealPlayer = ((ServerPlayerMixin)(Object)from).isRealPlayer;
this.viewDistanceHolder = ((ServerPlayerMixin)(Object)from).viewDistanceHolder;
}
}

0 comments on commit 502cee8

Please sign in to comment.