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

Use LinkedHashSet for Breadth First Search. #2697

Merged
merged 1 commit into from
Jan 10, 2025

Conversation

tomprince
Copy link
Contributor

What

When using a spray can that runs out partway through, we want to paint the nearest blocks, rather than a random selection of discovered blocks.

Implementation Details

I changed all the methods of BreadthFirstBlockSearch to return a LinkedHashSet instead of a HashSet, so that the caller can iterate the results in the order found. I could have left .search unchanged, but I think having a consistent behavior for all the methods makes more sense.

Outcome

When a spray can runs out while spraying, the nearest blocks to the initial block will be painted, rather than a random assortment of blocks within range.

When using a spray can that runs out partway through, we want
to paint the nearest blocks, rather than a random selection of
discovered blocks.
@tomprince tomprince requested a review from a team as a code owner January 6, 2025 03:43
@krossgg krossgg added the type: refactor Suggestion to refactor a section of code label Jan 10, 2025
@krossgg krossgg merged commit 9ca23ca into GregTechCEu:1.20.1 Jan 10, 2025
3 of 4 checks passed
@tomprince tomprince deleted the bfs-spray-run-out branch January 11, 2025 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: refactor Suggestion to refactor a section of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants