Skip to content

refactor(stash-finder): modernize file IO and CSV handling - #6607

Open
Big-Iron-Cheems wants to merge 4 commits into
MeteorDevelopment:masterfrom
Big-Iron-Cheems:feat/stash-finder
Open

refactor(stash-finder): modernize file IO and CSV handling#6607
Big-Iron-Cheems wants to merge 4 commits into
MeteorDevelopment:masterfrom
Big-Iron-Cheems:feat/stash-finder

Conversation

@Big-Iron-Cheems

Copy link
Copy Markdown
Collaborator

Type of change

  • Bug fix
  • New feature

Description

Refactors StashFinder file I/O and chunk coordinate handling.

The changes modernize the CSV serialization/deserialization by defining CSV fields with explicit getters and setters,
while keeping CSV coordinates stored as chunk coordinates, matching the existing JSON representation and preserving the previous coordinate format.

Chunk world coordinates are no longer stored as redundant/transient fields.
They are derived directly from ChunkPos using Minecraft's ChunkPos helpers, ensuring there is a single source of truth for chunk position and avoiding duplicated coordinate state.

ChunkPos is also treated as effectively immutable within Chunk, reflecting that the chunk position is assigned when the stash is created and is not subsequently replaced.

Related issues

None.

How Has This Been Tested?

Tested by loading and saving existing StashFinder JSON/CSV data and verifying that:

  • Chunk coordinates are preserved in their existing format.
  • CSV and JSON continue to represent the same chunk positions.
  • World-space coordinates are correctly derived from ChunkPos.
  • Stash coordinates displayed in the UI and notifications remain correct.
  • Goto and tracer functionality continue to target the center of the recorded chunk.
  • Existing stash entries load correctly after the coordinate refactor.

Checklist:

  • My code follows the style guidelines of this project.
  • I have added comments to my code in more complex areas.
  • I have tested the code in both development and production environments.

This also fixes mismatches in CSV field read/writes.
Mistakenly switched to world coords.
No need to store transient x/z coords and recalculate the values on load.
Only the counters are to be mutated at any time.
String line;
while ((line = reader.readLine()) != null) {
String[] values = line.split(" ");
String[] values = line.split(",");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use apache's StringUtils.split(String, char)

String header = CSV_FIELDS.stream()
.map(CsvField::name)
.collect(Collectors.joining(","));
writer.write(header + "\n");

@MukjepScarlet MukjepScarlet Aug 27, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

write(header).append('\n')

write(header)
newLine()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants