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

Add Model#toBuilder method #32

Merged
merged 1 commit into from
Nov 5, 2023
Merged

Add Model#toBuilder method #32

merged 1 commit into from
Nov 5, 2023

Conversation

Boy0000
Copy link
Contributor

@Boy0000 Boy0000 commented Nov 5, 2023

Convenience method to let you convert a Model to a builder for further manipulating it
Useful if you are trying to merge resourcepacks and avoid overriding one

So instead of this:

List<ItemOverride> overrides = new ArrayList<>();
Model baseModel = resourcePack.model(baseKey);
if (baseModel == null) Model.model().build();
Model.Builder modelBuilder = Model.model().key(baseModel.key()).parent(baseModel.parent()).textures(baseModel.textures());
modelBuilder.overrides(overrides);

You could do:

List<ItemOverride> overrides = new ArrayList<>();
Model baseModel = resourcePack.model(baseKey);
if (baseModel == null) Model.model().build();
baseModel = baseModel.toBuilder().overrides(overrides).build();

@yusshu yusshu self-requested a review November 5, 2023 18:16
@yusshu yusshu added the enhancement New feature or request label Nov 5, 2023
@yusshu yusshu merged commit b57a8c0 into unnamed:dev Nov 5, 2023
@Boy0000 Boy0000 deleted the model-builder branch November 5, 2023 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants