Skip to content

Commit

Permalink
clean up a little
Browse files Browse the repository at this point in the history
  • Loading branch information
sisby-folk committed Oct 11, 2024
1 parent 7fa08f9 commit 825209d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
15 changes: 11 additions & 4 deletions src/main/java/folk/sisby/surveyor/PlayerSummary.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<World> dimension, Vec3d pos, float yaw, boolean online) implements PlayerSummary {
public OfflinePlayerSummary(UUID uuid, NbtCompound nbt, boolean online) {
this(
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 825209d

Please sign in to comment.