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

[1.21.4] Expose vanilla model generators for modded usages #1725

Open
wants to merge 59 commits into
base: 1.21.x
Choose a base branch
from

Conversation

ApexModder
Copy link
Contributor

Updated version of #1696 for 1.21.4.

While the vanilla providers have been exposed for modded usage, and can be used for more simpler model generation. This is still highly WIP and requires more patches to support our model extensions and generating a model from scratch.

@ApexModder ApexModder added the 1.21.4 Targeted at Minecraft 1.21.4 label Dec 3, 2024
@neoforged-pr-publishing
Copy link

neoforged-pr-publishing bot commented Dec 3, 2024

  • Publish PR to GitHub Packages

Last commit published: c351c859d1d2faa560c3fd4a85830b69b4cb8cb4.

PR Publishing

The artifacts published by this PR:

Repository Declaration

In order to use the artifacts published by the PR, add the following repository to your buildscript:

repositories {
    maven {
        name 'Maven for PR #1725' // https://github.com/neoforged/NeoForge/pull/1725
        url 'https://prmaven.neoforged.net/NeoForge/pr1725'
        content {
            includeModule('net.neoforged', 'neoforge')
            includeModule('net.neoforged', 'testframework')
        }
    }
}

MDK installation

In order to setup a MDK using the latest PR version, run the following commands in a terminal.
The script works on both *nix and Windows as long as you have the JDK bin folder on the path.
The script will clone the MDK in a folder named NeoForge-pr1725.
On Powershell you will need to remove the -L flag from the curl invocation.

mkdir NeoForge-pr1725
cd NeoForge-pr1725
curl -L https://prmaven.neoforged.net/NeoForge/pr1725/net/neoforged/neoforge/21.4.93-beta-pr-1725-pr-vanilla-datagen-21.4/mdk-pr1725.zip -o mdk.zip
jar xf mdk.zip
rm mdk.zip || del mdk.zip

To test a production environment, you can download the installer from here.

@neoforged-automation
Copy link

@ApexModder, this pull request has conflicts, please resolve them for this PR to move forward.

@ApexModder ApexModder force-pushed the pr/vanilla-datagen-21.4 branch from 41e1c12 to 3d04267 Compare December 3, 2024 18:47
@ApexModder ApexModder changed the base branch from port/1.21.4 to 1.21.x December 3, 2024 18:48
@ApexModder
Copy link
Contributor Author

ApexModder commented Dec 3, 2024

Merged in @XFactHD fork, everything should be exposed and usable. Test mod datagen just needs rewriting to now use vanilla model providers.

@neoforged-compatibility-checks
Copy link

neoforged-compatibility-checks bot commented Dec 3, 2024

@ApexModder, this PR introduces breaking changes.
Fortunately, this project is currently accepting breaking changes, but if they are not intentional, please revert them.
Last checked commit: c351c859d1d2faa560c3fd4a85830b69b4cb8cb4.

Compatibility checks

neoforge (:neoforge)

  • net/neoforged/neoforge/client/model/generators/MultiPartBlockStateBuilder
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/ModelBuilder$ElementBuilder$RotationBuilder
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/BlockModelBuilder
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/ModelFile
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/ConfiguredModel$Builder
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/ModelBuilder$ElementBuilder
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/ModelBuilder$ElementBuilder$FaceBuilder
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/loaders/ObjModelBuilder
    • ❗ Class missing superclass of net/neoforged/neoforge/client/model/generators/CustomLoaderBuilder
    • begin(Lnet/neoforged/neoforge/client/model/generators/ModelBuilder;Lnet/neoforged/neoforge/common/data/ExistingFileHelper;)Lnet/neoforged/neoforge/client/model/generators/loaders/ObjModelBuilder;: ❗ API method was removed
    • <init>(Lnet/neoforged/neoforge/client/model/generators/ModelBuilder;Lnet/neoforged/neoforge/common/data/ExistingFileHelper;)V: ❗ API method was removed
  • net/neoforged/neoforge/client/model/generators/ModelBuilder$RootTransformsBuilder
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/loaders/SeparateTransformsModelBuilder
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/BlockModelProvider
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/loaders/DynamicFluidContainerModelBuilder
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/MultiPartBlockStateBuilder$PartBuilder$ConditionGroup
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/ModelBuilder$TransformsBuilder
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/MultiPartBlockStateBuilder$PartBuilder
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/loaders/CompositeModelBuilder
    • ❗ Class missing superclass of net/neoforged/neoforge/client/model/generators/CustomLoaderBuilder
    • child(Ljava/lang/String;Lnet/neoforged/neoforge/client/model/generators/ModelFile;)Lnet/neoforged/neoforge/client/model/generators/loaders/CompositeModelBuilder;: ❗ API method was removed
    • <init>(Lnet/neoforged/neoforge/client/model/generators/ModelBuilder;Lnet/neoforged/neoforge/common/data/ExistingFileHelper;)V: ❗ API method was removed
    • begin(Lnet/neoforged/neoforge/client/model/generators/ModelBuilder;Lnet/neoforged/neoforge/common/data/ExistingFileHelper;)Lnet/neoforged/neoforge/client/model/generators/loaders/CompositeModelBuilder;: ❗ API method was removed
  • net/neoforged/neoforge/client/model/generators/loaders/ItemLayerModelBuilder
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/ItemModelProvider
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/ModelFile$UncheckedModelFile
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/CustomLoaderBuilder
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/VariantBlockStateBuilder$PartialBlockstate
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/ConfiguredModel
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/VariantBlockStateBuilder
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/ItemModelBuilder$OverrideBuilder
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/BlockStateProvider
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/ModelFile$ExistingModelFile
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/ModelProvider
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/ItemModelBuilder
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/IGeneratedBlockState
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/ModelBuilder
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/ModelBuilder$TransformsBuilder$TransformVecBuilder
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/BlockStateProvider$ConfiguredModelList
    • ❗ API class no longer exists
  • net/neoforged/neoforge/client/model/generators/ModelBuilder$FaceRotation
    • ❗ API class no longer exists

@ApexModder
Copy link
Contributor Author

This PR should now be ready for view but important note ExtendedModelTemplate.Builder may still get some major reworking to lessen the amount of nesting/.end calls.
Thinking of refactoring into lambda style rather than builder style.

Meaning that the following
ExtendedModelTemplate.builder().element().end()

would change to something like so
ExtendedModelTemplate.builder().element(element -> { })

@ApexModder ApexModder marked this pull request as ready for review December 7, 2024 01:17
@neoforged-automation
Copy link

@ApexModder, this pull request has conflicts, please resolve them for this PR to move forward.

@neoforged-automation
Copy link

@ApexModder, this pull request has conflicts, please resolve them for this PR to move forward.

@neoforged-automation
Copy link

@ApexModder, this pull request has conflicts, please resolve them for this PR to move forward.

Copy link
Member

@XFactHD XFactHD left a comment

Choose a reason for hiding this comment

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

A couple more comments, primarily about documentation.
When these are adressed, this PR is good to go from my end. The approval and merge has to be done by someone else as this PR adds code I wrote.


void copy(Item p_387316_, Item p_387995_);
+
+ default void register(Item item, net.minecraft.client.renderer.item.ClientItem clientItem) {
Copy link
Member

Choose a reason for hiding this comment

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

This should have a comment mentioning that Neo pulls this up into the interface to allow mods to control the entire ClientItem for an item and not just the ItemModel.Unbaked it uses.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please provide JDoc on what this method does or is supposed to do after it now has been pulled up.

We can not expect tools like Parchment to provide this to modders so we should be libraral here with the explanation even if that increases the patch size.

@ApexModder ApexModder requested a review from XFactHD December 16, 2024 05:45
@ApexModder
Copy link
Contributor Author

PR should be ready for review and merge, only unresolved comment should be xfacts one about ModelTemplate#extend but we are both unsure of a more fitting name.


void copy(Item p_387316_, Item p_387995_);
+
+ default void register(Item item, net.minecraft.client.renderer.item.ClientItem clientItem) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please provide JDoc on what this method does or is supposed to do after it now has been pulled up.

We can not expect tools like Parchment to provide this to modders so we should be libraral here with the explanation even if that increases the patch size.

import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;

public interface IBlockModelGeneratorsExtension {
Copy link
Contributor

Choose a reason for hiding this comment

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

This extension is not strictly necessary.
It is possible to create a custom BlockFamily that is incomplete and use it to perform these generations

Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove it.

Copy link
Contributor

@ChampionAsh5357 ChampionAsh5357 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 minor things excluding what Orion said. I also removed my comments about the ExistingFileHelper if we are planning to strip it out.


void copy(Item p_387316_, Item p_387995_);
+
+ // Neo: Pulled up from 'ModelProvider.ItemInfoCollector' to give modders full control over the 'ClientItem' instead of just the 'ItemModel.Unbacked' in '#accept'
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
+ // Neo: Pulled up from 'ModelProvider.ItemInfoCollector' to give modders full control over the 'ClientItem' instead of just the 'ItemModel.Unbacked' in '#accept'
+ // Neo: Pulled up from 'ModelProvider.ItemInfoCollector' to give modders full control over the 'ClientItem' instead of just the 'ItemModel.Unbaked' in '#accept'

Comment on lines +13 to +15
default TexturedModel updateTemplate(UnaryOperator<ModelTemplate> modifier) {
return new TexturedModel(self().getMapping(), modifier.apply(self().getTemplate()));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like this needs some documentation to explain why updateTemplate makes sense, since the additional data used by the custom loaders is set on the template itself rather than the textures slots.

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like this could be moved to an extension method on ItemModelGenerators rather than being outright removed as it still is a neoforge-added item model.

Copy link
Member

Choose a reason for hiding this comment

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

The only reason custom model loaders have builders is because they aren't reversible and therefore not serializable. The dynamic fluid container model is a custom ItemModel now though and the associated ItemModel.Unbaked can just be instantiated and passed to ItemModelOutput#register().

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand. I just figured it would probably be easier to have a convenience method to create them, similar to all the methods in the model generator.

Comment on lines 85 to 87
protected static void serializeNestedTemplate(ModelTemplate template, TextureMapping textures, Consumer<JsonElement> consumer) {
template.create(DUMMY, textures, (id, jsonSup) -> consumer.accept(jsonSup.get()));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Documentation? I don't know what this would be for.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Method was unused and thus has been removed, was told its better practice to now reference external files rather than inlining models like we used to, which this was used for in the past.

@XFactHD XFactHD removed their request for review December 19, 2024 17:38
@XFactHD XFactHD dismissed their stale review December 19, 2024 17:42

Completed

@ApexModder ApexModder added the keep rebased Add this label to a PR to keep it rebased continuously automatically label Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.21.4 Targeted at Minecraft 1.21.4 keep rebased Add this label to a PR to keep it rebased continuously automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[1.21.4] Missing json files when generating Item Models
6 participants