Skip to content

Use Generic Builder pattern for MachineBuilder#4422

Merged
jurrejelle merged 2 commits into1.20.1from
jj/move-multiblock-builder-to-generic-system
Jan 9, 2026
Merged

Use Generic Builder pattern for MachineBuilder#4422
jurrejelle merged 2 commits into1.20.1from
jj/move-multiblock-builder-to-generic-system

Conversation

@jurrejelle
Copy link
Copy Markdown
Contributor

@jurrejelle jurrejelle commented Jan 5, 2026

What

Add second generic to MachineBuilder and reduce code duplication

Implementation Details

go from MachineBuilder<DEFINITION extends MachineDefinition> extends BuilderBase<DEFINITION> to MachineBuilder<DEFINITION extends MachineDefinition, TYPE extends MachineBuilder<DEFINITION, TYPE>> extends BuilderBase<DEFINITION>

Outcome

No longer need to add a public MultiblockMachineBuilder foo(Bar bar){ (MultiblockMachineBuilder) super.foo(bar) }; for every. single. MachineBuilder. method.

Additional Information

Unfortunately Lombok doesn't support returning getThis() and TYPE, so I had to un-lombok both classes for setters.

Genericslop.

Potential Compatibility Issues

People who store partially finished builders need to move from MachineBuilder<?> to MachineBuilder<?,?>

@jurrejelle jurrejelle requested a review from a team as a code owner January 5, 2026 15:40
@jurrejelle jurrejelle added type: refactor Suggestion to refactor a section of code 1.20.1 Release: Patch - 0.0.X Smaller changes that either are bug fixes or very minor tweaks. labels Jan 5, 2026
@github-actions github-actions bot added the Tests: Passed Game Tests have passed on this PR label Jan 5, 2026
@jurrejelle jurrejelle force-pushed the jj/move-multiblock-builder-to-generic-system branch from 4d10523 to 11a51c5 Compare January 5, 2026 15:48
Copy link
Copy Markdown
Contributor

@TarLaboratories TarLaboratories left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jurrejelle jurrejelle merged commit a91ad87 into 1.20.1 Jan 9, 2026
4 checks passed
@jurrejelle jurrejelle deleted the jj/move-multiblock-builder-to-generic-system branch January 9, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.20.1 Release: Patch - 0.0.X Smaller changes that either are bug fixes or very minor tweaks. 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