Skip to content

clean up RelativeDirection and rename its methods to be more consistent with vanilla#3198

Merged
screret merged 5 commits into1.20.1from
sc/clean-up-relative-direction
Jun 22, 2025
Merged

clean up RelativeDirection and rename its methods to be more consistent with vanilla#3198
screret merged 5 commits into1.20.1from
sc/clean-up-relative-direction

Conversation

@screret
Copy link
Contributor

@screret screret commented Jun 1, 2025

What

  • Cleaned up RelativeDirection and the code using it directly
  • Made Assembly Lines and Distillation towers not override the definition's part sorter every time they form
  • Made MetaMachineConfigCopyBehaviour not repeat itself constantly
  • Added some new utility methods to RelativeDirection
  • Also touched up some other stuff relating to the matter

Implementation Details

  • added IMultiController#getPartSorter so it can be overridden if necessary
  • changed MultiblockMachineDefinition#partSorter to be a fn(contoller) -> comparator<part> so it can use the controller's state as extra information
    • this is cached via a new memoization function in GTMemoizer using ConcurrentWeakIdentityHashMap.
  • renamed RelativeDirection#getActualFacing to getActualDirection (the old method still exists, but is deprecated for removal)
  • renamed RelativeDirection#getRelativeFacing to getRelative (the old method still exists, but is deprecated for removal)
  • changed RelativeDirection#getSorter's type to Comparator<BlockPos>
  • added an utility method to RelativeDirection for finding the relative direction between two directions

Outcome

cleaner code in RelativeDirection & co.

Additional Information

Do tell me if I should make MetaMachineConfigCopyBehaviour NOT print out the actual relative facing if you find that confusing, as currently it will rotate the direction correctly in all axes, which could result in "above" not actually being up if the machine is facing up or down.

Potential Compatibility Issues

addons using RelativeDirection#getSorter will break, but everything else should work like before.

@screret screret requested a review from a team as a code owner June 1, 2025 19:04
@screret screret added the type: refactor Suggestion to refactor a section of code label Jun 1, 2025
@screret screret changed the title clean up RelativeDirection clean up RelativeDirection and rename its methods to be more consistent with vanilla Jun 22, 2025
@screret screret merged commit 4176fbb into 1.20.1 Jun 22, 2025
4 checks passed
@screret screret deleted the sc/clean-up-relative-direction branch June 22, 2025 09:52
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