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

Extensions to datagen API for model generation #2754

Open
wants to merge 29 commits into
base: 1.19.3
Choose a base branch
from

Conversation

62832
Copy link
Contributor

@62832 62832 commented Dec 12, 2022

For a while now, I've been meaning to extend Fabric's datagen API in order to provide support for more complex data generation, particularly for block and item models. Ideally, beyond block/item models, extra providers could also be implemented for other data such as particles and sounds.

At present, the datagen suite within vanilla itself is severely limited for models, providing not even half of the JSON properties that are actually supported by models such as individual elements and item-specific overrides. This PR aims to provide various custom builders to facilitate the generation of these properties as additions to vanilla's own model classes via interface injection. These builders mostly follow the spec provided by the following Minecraft Wiki page.

Currently, this is still a very early draft. Among other things, I have not figured out a particularly adequate method for actually building models with these new properties that doesn't just involve toying around with the various models and texture mappings used by the existing vanilla generator methods, as can be seen in the test mod.

Copy link
Member

@Technici4n Technici4n left a comment

Choose a reason for hiding this comment

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

A few misc comments.

@62832 62832 changed the title Extensions to datagen API Extensions to datagen API for model generation Dec 13, 2022
@Technici4n Technici4n added the in progress This issue has PR(s) open to resolve it (or a PR that is WIP) label Dec 16, 2022
@62832 62832 marked this pull request as ready for review December 16, 2022 17:23
@62832
Copy link
Contributor Author

62832 commented Dec 16, 2022

I've marked this PR as ready for review as I am more or less content with the model builders themselves in their current form, however I am still open to suggestions on how to process might be better simplified with any specific generator methods. I would hope that the ability to reuse builders and re-generate resulting models should help keep things clean for mods with a greater amount of models with variably-complex properties.

Copy link
Member

@modmuss50 modmuss50 left a comment

Choose a reason for hiding this comment

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

Looks like a great start, I am not too familar with custom models so im unable to review that too well.

Please let me know if you dont agree with anything ive pointed out.

Comment on lines +168 to +172
displays.clear();
elements.clear();
overrides.clear();
guiLight = null;
ambientOcclusion = true;
Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since these are mutable fields, any Model for which they're set will retain these properties even when it isn't intended. This was a concern at an earlier stage when standard models such as Models.GENERATED would retain these properties, though I'll try to give this a further look and see if it still applies.

Comment on lines +203 to +279
blockStateModelGenerator.buildWithSingletonState(BLOCK_WITH_CUSTOM_MODEL_1, customModel);

customModel.clearDisplays().clearElements()
Copy link
Member

Choose a reason for hiding this comment

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

I dont like how the builder is same builder is being reused. Maybe copy from the built model of customModel?

.setGuiLight(ItemModelBuilder.GuiLight.SIDE);
itemModelGenerator.build(ITEM_WITH_CUSTOM_MODEL_1, customModel);

customModel.clearOverrides().setGuiLight(null)
Copy link
Member

Choose a reason for hiding this comment

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

Again here, reusing the builder is a little odd imo? Doesnt quite follow the builder design pattern too well. Nither does the clearOverrides() like methods either 🤔

"loom:injected_interfaces": {
"net/minecraft/class_4910": ["net/fabricmc/fabric/api/datagen/v1/model/FabricBlockStateModelGenerator"],
"net/minecraft/class_4915": ["net/fabricmc/fabric/api/datagen/v1/model/FabricItemModelGenerator"],
"net/minecraft/class_4942": ["net/fabricmc/fabric/impl/datagen/FabricModel"]
Copy link
Member

Choose a reason for hiding this comment

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

Dont use interface injection for impl.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that I think about it I'm not sure if this should even be an impl interface given its use in the API-provided model builders. Given the intent to also allow ModelBuilder to be extended for custom models I may also have to reconsider how to go about this to actually allow for any custom properties that other mods may choose to incorporate.

@62832 62832 force-pushed the datagen-extensions branch from 2fa05ad to 80de375 Compare January 11, 2023 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in progress This issue has PR(s) open to resolve it (or a PR that is WIP)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants