Skip to content

Improve Pattern Errors - #5285

Open
ghzdude wants to merge 7 commits into
1.20.1from
gh/better-pattern-errors
Open

Improve Pattern Errors#5285
ghzdude wants to merge 7 commits into
1.20.1from
gh/better-pattern-errors

Conversation

@ghzdude

@ghzdude ghzdude commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

What

As I was working on #5131, I had some gripes with how PatternError was handled
Improves PatternError along with the extending classes.

Implementation Details

PatternError constructors have been simplified to only a BlockPos or no-args. block pos is also nonnull
CoilMatchingError and FilterMatchingError extened a new class MismatchError along with codec helper method
renamed component() to of() in PatternStringError
PlaceholderError is now just a singleton
add constructor to PartAbilityError to simplify codec
make all codecs final

AI Usage

  • No AI driven tools were used for this pull request.
  • Yes AI driven tools were used for this pull request.

Outcome

better DX when extending PatternError

How Was This Tested

ran client and looked at some errors, seems fine

@ghzdude
ghzdude requested a review from a team as a code owner August 13, 2026 08:37
@ghzdude ghzdude added 1.20.1 type: refactor Suggestion to refactor a section of code labels Aug 13, 2026
@github-actions github-actions Bot added the Tests: Passed Game Tests have passed on this PR label Aug 13, 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.

Make this return Component or add a 2nd method that does so every use of it doesnt have to be wrapped in Component.translatable and subclasses can add arguments to the translation if they need to

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.

Or if not that, rename it to langKey as it shouldn't return the translated value which imo lang implies it does

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.

IMO literal strings shouldn't have util methods to dissuade people from using them

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.

Rename this argument to key

replace stringify method with setter and field
javadocs
rename lang -> langKey
lang method now returns a Component
rename s parameter to langKey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.20.1 Tests: Passed Game Tests have passed on this PR type: refactor Suggestion to refactor a section of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants