Skip to content
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
12 changes: 9 additions & 3 deletions src/main/java/com/extantape/rewild/scan/Scanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ public Verdict evaluate(int x, int z) {
if (r == null || !r.known) {
why.add(r == null ? "no tracking history: it was generated before tracking began, or never changed"
: "generated before tracking began, so natural and player-placed blocks can't be told apart");
return new Verdict(x, z, Kind.UNKNOWN, why, 0);
return unknown(x, z, why);
}
if (r.bornAt < ctx.everyBlockSince) {
why.add("generated before Rewild recorded every player-placed block (0.3.0), so a build there could be lost");
return new Verdict(x, z, Kind.UNKNOWN, why, 0);
return unknown(x, z, why);
}
if (r.epoch != ctx.epoch) {
why.add("generated before the world generator changed, so a reset wouldn't blend");
return new Verdict(x, z, Kind.UNKNOWN, why, 0);
return unknown(x, z, why);
}
List<Reason> keep = keepReasons(x, z);
boolean fullDamage = r.removed() >= s.minRemovedBlocks() || r.explosionBlocks >= s.minExplosionBlocks();
Expand Down Expand Up @@ -196,6 +196,12 @@ public Verdict evaluate(int x, int z) {
return new Verdict(x, z, Kind.UNDAMAGED, why, 0);
}

/** An unknown chunk never resets; any keep that also covers it is listed too, so /rewild why shows it. */
private Verdict unknown(int x, int z, List<String> why) {
for (Reason reason : keepReasons(x, z)) why.add("also kept: " + reason.text());
return new Verdict(x, z, Kind.UNKNOWN, why, 0);
}

/** What stays as it is when the chunk rewilds, or null if nothing known yet. Listed blocks are found at restart. */
String staysInPlace(ChunkRecord r) {
List<String> parts = new ArrayList<>();
Expand Down
11 changes: 11 additions & 0 deletions src/test/java/com/extantape/rewild/scan/ScannerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@ void untrackedChunkIsUnknownAndNeverQueued() {
assertFalse(Scanner.candidates(records, ctx).contains(r.key()));
}

@Test
void unknownChunkStillNamesWhatKeepsIt() {
// Found on the 26.2 clone: the station's own chunk predates tracking, and /rewild why only said "unknown".
ChunkRecord r = minedOut(0, 0);
r.known = false;
ctx.external.put(ChunkRecord.key(0, 0), List.of("the station (Waystation)"));
Scanner.Verdict v = verdict(0, 0);
assertEquals(Scanner.Kind.UNKNOWN, v.kind());
assertTrue(String.join(" ", v.reasons()).contains("also kept: the station (Waystation)"), v.reasons().toString());
}

@Test
void chunkFromAnOlderGeneratorIsUnknown() {
minedOut(0, 0).epoch = 0;
Expand Down
Loading