Fix 2x2 sapling replant landing offset from the chopped trunk - #2
Merged
Merged
Conversation
The 2x2 replant formation could be planted up to one block off on each axis from the trunk that was actually chopped. Two causes stacked: * The log recorded as the replant anchor was "the first log with the lowest Y", and a 2x2 trunk's four base logs all share that Y. The discovery set is a HashSet, so the winner was an arbitrary one of the four corners. * isLikely2x2Tree() already scanned the chopped-log set and computed the trunk's real minimum-corner anchor, but discarded it and returned only a boolean. find2x2PlantLocation() then re-guessed the anchor from that arbitrary corner, trying the origin-as-minimum-corner candidate first. With the tree gone the ground is flat, so the offset square passed the clear-and-soil check and was accepted. Dark Oak and Pale Oak skipped the footprint scan entirely, so their anchor was always a guess. Return the anchor from the footprint scan instead of a boolean and plant on it, falling back to the search only when that footprint is no longer plantable or was never detected (partial chop). Run the scan for Dark Oak and Pale Oak too, keeping their unconditional 2x2 behaviour via isAlways2x2(). Also order the anchor candidates by Y, then X, then Z, so the recorded corner is the minimum one and, above all, deterministic on the fallback path. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DLvC3xDtLN8xhL6fok7RKW
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The 2x2 replant formation could be planted up to one block off on each axis from the trunk that was actually chopped.
Two causes stacked:
The log recorded as the replant anchor was "the first log with the lowest Y", and a 2x2 trunk's four base logs all share that Y. The discovery set is a HashSet, so the winner was an arbitrary one of the four corners.
isLikely2x2Tree() already scanned the chopped-log set and computed the trunk's real minimum-corner anchor, but discarded it and returned only a boolean. find2x2PlantLocation() then re-guessed the anchor from that arbitrary corner, trying the origin-as-minimum-corner candidate first. With the tree gone the ground is flat, so the offset square passed the clear-and-soil check and was accepted. Dark Oak and Pale Oak skipped the footprint scan entirely, so their anchor was always a guess.
Return the anchor from the footprint scan instead of a boolean and plant on it, falling back to the search only when that footprint is no longer plantable or was never detected (partial chop). Run the scan for Dark Oak and Pale Oak too, keeping their unconditional 2x2 behaviour via isAlways2x2().
Also order the anchor candidates by Y, then X, then Z, so the recorded corner is the minimum one and, above all, deterministic on the fallback path.
Claude-Session: https://claude.ai/code/session_01DLvC3xDtLN8xhL6fok7RKW