Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix player data not being copied on respawn #53

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/folk/sisby/surveyor/PlayerSummary.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ public int viewDistance() {
return ((ServerPlayerEntity) this.player).getViewDistance();
}

public void copyExploration(ServerPlayerEntitySummary oldSummary) {
exploration.copyFrom(oldSummary.exploration);
}

public void read(NbtCompound nbt) {
exploration.read(nbt.getCompound(KEY_DATA));
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/folk/sisby/surveyor/SurveyorExploration.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ static SurveyorExploration ofShared(UUID player, MinecraftServer server) {

Set<UUID> sharedPlayers();

default void copyFrom(SurveyorExploration oldExploration) {
terrain().putAll(oldExploration.terrain());
structures().putAll(oldExploration.structures());
}

boolean personal();

default boolean exploredChunk(RegistryKey<World> worldKey, ChunkPos pos) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,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;
Expand Down