diff --git a/src/main/java/folk/sisby/surveyor/PlayerSummary.java b/src/main/java/folk/sisby/surveyor/PlayerSummary.java index 1cf390e..a3eace8 100644 --- a/src/main/java/folk/sisby/surveyor/PlayerSummary.java +++ b/src/main/java/folk/sisby/surveyor/PlayerSummary.java @@ -58,6 +58,11 @@ static PlayerSummary of(UUID uuid, MinecraftServer server) { boolean online(); + + default void copyFrom(PlayerSummary oldSummary) { + exploration().copyFrom(oldSummary.exploration()); + } + record OfflinePlayerSummary(SurveyorExploration exploration, String username, RegistryKey dimension, Vec3d pos, float yaw, boolean online) implements PlayerSummary { public OfflinePlayerSummary(UUID uuid, NbtCompound nbt, boolean online) { this( @@ -184,12 +189,14 @@ public int viewDistance() { return viewDistance; } - public void setViewDistance(int viewDistance) { - this.viewDistance = viewDistance; + @Override + public void copyFrom(PlayerSummary oldSummary) { + super.copyFrom(oldSummary); + viewDistance = oldSummary.viewDistance(); } - public void copyExploration(ServerPlayerEntitySummary oldSummary) { - exploration.copyFrom(oldSummary.exploration); + public void setViewDistance(int viewDistance) { + this.viewDistance = viewDistance; } public void read(NbtCompound nbt) { diff --git a/src/main/java/folk/sisby/surveyor/mixin/MixinServerPlayerEntity.java b/src/main/java/folk/sisby/surveyor/mixin/MixinServerPlayerEntity.java index 3b89e60..e2891d1 100644 --- a/src/main/java/folk/sisby/surveyor/mixin/MixinServerPlayerEntity.java +++ b/src/main/java/folk/sisby/surveyor/mixin/MixinServerPlayerEntity.java @@ -62,8 +62,8 @@ public void onDeath(DamageSource damageSource, CallbackInfo ci) { } @Inject(method = "copyFrom", at = @At("TAIL")) - public void copyFrom(MixinServerPlayerEntity oldPlayer, boolean alive, CallbackInfo ci) { - surveyor$summary.copyExploration(oldPlayer.surveyor$summary); + public void copyFrom(ServerPlayerEntity oldPlayer, boolean alive, CallbackInfo ci) { + surveyor$summary.copyFrom(PlayerSummary.of(oldPlayer)); } @Override