diff --git a/src/main/java/folk/sisby/surveyor/PlayerSummary.java b/src/main/java/folk/sisby/surveyor/PlayerSummary.java index c66d53f..eb349e0 100644 --- a/src/main/java/folk/sisby/surveyor/PlayerSummary.java +++ b/src/main/java/folk/sisby/surveyor/PlayerSummary.java @@ -45,6 +45,7 @@ static PlayerSummary of(UUID uuid, MinecraftServer server) { } SurveyorExploration exploration(); + void copyExploration(PlayerSummary oldSummary); String username(); @@ -100,6 +101,10 @@ public int viewDistance() { return 0; } + @Override + public void copyExploration(PlayerSummary oldSummary) { + } + public record OfflinePlayerExploration(Set sharedPlayers, Map, Map> terrain, Map, Map, LongSet>> structures, boolean personal) implements SurveyorExploration { public static OfflinePlayerExploration ofMerged(Set explorations) { Set sharedPlayers = new HashSet<>(); @@ -134,6 +139,10 @@ public SurveyorExploration exploration() { return null; } + @Override + public void copyExploration(PlayerSummary oldSummary) { + } + @Override public String username() { return player.getGameProfile().getName(); @@ -179,6 +188,11 @@ public SurveyorExploration exploration() { return exploration; } + @Override + public void copyExploration(PlayerSummary oldSummary) { + exploration.copyFrom(((ServerPlayerEntitySummary) oldSummary).exploration); + } + @Override public int viewDistance() { return viewDistance; diff --git a/src/main/java/folk/sisby/surveyor/SurveyorExploration.java b/src/main/java/folk/sisby/surveyor/SurveyorExploration.java index d1357c0..7e47d0a 100644 --- a/src/main/java/folk/sisby/surveyor/SurveyorExploration.java +++ b/src/main/java/folk/sisby/surveyor/SurveyorExploration.java @@ -56,6 +56,11 @@ static SurveyorExploration ofShared(UUID player, MinecraftServer server) { Set sharedPlayers(); + default void copyFrom(SurveyorExploration oldExploration) { + terrain().putAll(oldExploration.terrain()); + structures().putAll(oldExploration.structures()); + } + boolean personal(); default boolean exploredChunk(RegistryKey worldKey, ChunkPos pos) { diff --git a/src/main/java/folk/sisby/surveyor/mixin/MixinServerPlayerEntity.java b/src/main/java/folk/sisby/surveyor/mixin/MixinServerPlayerEntity.java index 0eed8a5..3b89e60 100644 --- a/src/main/java/folk/sisby/surveyor/mixin/MixinServerPlayerEntity.java +++ b/src/main/java/folk/sisby/surveyor/mixin/MixinServerPlayerEntity.java @@ -61,6 +61,11 @@ 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); + } + @Override public PlayerSummary surveyor$getSummary() { return surveyor$summary;