-
Notifications
You must be signed in to change notification settings - Fork 433
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
base: 1.19.3
Are you sure you want to change the base?
Conversation
fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/FabricModel.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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.
...neration-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/builder/DisplayBuilder.java
Outdated
Show resolved
Hide resolved
fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/FabricModel.java
Outdated
Show resolved
Hide resolved
fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/FabricModel.java
Outdated
Show resolved
Hide resolved
...neration-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/builder/ElementBuilder.java
Outdated
Show resolved
Hide resolved
...-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/builder/FaceBuilder.java
Outdated
Show resolved
Hide resolved
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. |
...1/src/main/java/net/fabricmc/fabric/api/datagen/v1/model/FabricBlockStateModelGenerator.java
Show resolved
Hide resolved
There was a problem hiding this 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.
...-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/model/property/RotationBuilder.java
Outdated
Show resolved
Hide resolved
...n-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/model/property/DisplayBuilder.java
Outdated
Show resolved
Hide resolved
...tion-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/model/builder/ModelBuilder.java
Outdated
Show resolved
Hide resolved
...n-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/model/property/ElementBuilder.java
Outdated
Show resolved
Hide resolved
...tion-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/model/builder/ModelBuilder.java
Show resolved
Hide resolved
displays.clear(); | ||
elements.clear(); | ||
overrides.clear(); | ||
guiLight = null; | ||
ambientOcclusion = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
There was a problem hiding this comment.
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.
blockStateModelGenerator.buildWithSingletonState(BLOCK_WITH_CUSTOM_MODEL_1, customModel); | ||
|
||
customModel.clearDisplays().clearElements() |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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"] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/FabricModel.java
Outdated
Show resolved
Hide resolved
…c/api/datagen/v1/FabricModel.java Co-authored-by: BasiqueEvangelist <[email protected]>
(new props now get added to the prior-generated model for whatever reason)
(fixes properties being added to the wrong models)
simplification step 1
This reverts commit 2e61ffc.
This reverts commit f731f11.
(also rebase)
2fa05ad
to
80de375
Compare
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-specificoverrides
. 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.