Skip to content

Conversation

@Penguin-Spy
Copy link

This PR adds mappings for most classes related to loading and baking the models of blocks from their block state definition files. The biggest (breaking?) change in this PR is renaming n.m.client.render.model.ModelVariantMap to BlockstateDefinition, the rationale for which is given below.

Because there's a lot of new stuff, here's a rough guide to how it relates to the block state definition JSON files:

{ // BlockStateDefinition
  "variants": { // BlockStateDefinition.Variants, a map of String to BlockStateModel.Part. decoded by map of String to BlockStateModelPart.VARIANTS_CODEC
    // either:
    "property=value": { // SingleBlockStateModel.SinglePart, a BlockStateModel.Part. decoded by SingleBlockStateModel.SinglePart.CODEC
        "model": "a:b",    \  ModelVariant (from json)
        "x": 0,         \  |
        "y": 0,         | ModelVariant.Orientation
        "uvlock": false /
    }
    ,// or:
    "property=value": [ // WeightedBlockStateModel.WeightedParts, a BlockStateModel.Part. decoded by BlockStateModel.Part.VARIANT_LIST_CODEC
        {
            "model": "a:b",  \
            "x": 0,          | ModelVariant
            "y": 0,          |  |
            "uvlock": false, /  | VARIANT_LIST_ENTRY_CODEC
            "weight": 1         /
        }
    }
    // VariantMatcher is used before baking to determine which variant shows for each block state
  },

  "multipart": [ // BlockStateDefinition.Multipart, a list of MultipartModelCase. decoded by MultipartModelCase.CODEC
    { // a single MultipartModelCase
      "when": { // MultipartModelSelector
        // either:
        "OR": [ // OperatorMultipartModelSelector (using .OR Operator)
            { "property": "value" } // MultipartModelSelector (these can nest i'm pretty sure)
        ]
        ,// or:
        "AND": [ // OperatorMultipartModelSelector (using .AND Operator)
            { "property": "value" } // MultipartModelSelector
        ]
        ,// or:
        "property": "value" // SimpleMultipartModelSelector, which contains a map of ValueSelector, which contains multiple selector terms (seperated by '|' characters)
      },

      // BlockStateModel.Part (same as variants' value above)
      // either:
      "apply": { }
      ,// or:
      "apply": [ { } ]
    }
  ]

  // `MultipartModelCase`s turn into `MultipartBlockStateModel.Selector`s before baking to determine which parts appear for which block states
}

And the classes that the definitions turn into before baking:

  • n.m.client.render.block.BlockStateModel (interface): a block state model
    • WeightedBlockStateModel: a block state model with multiple (weighted) parts to be chosen to be rendered
    • SingleBlockStateModel: a block state model with one part to be rendered
    • MultipartBlockStateModel: a block state model comprised of multiple models to be rendered, depending on if their selectors match the block state
      And after baking:
  • n.m.client.render.block.BakedBlockModel (interface): a baked block model, with methods getQuads and getParticleSprite
    • Its only implementation is the unmapped class C_eqeibyds, i don't know enough about Minecraft's rendering to map this.

Other classes (most in n.m.client.render.model.):

  • BlockStateLoader: the main class that manages loading block state definitions and turning them into unbaked models for baking
  • ItemModelLoader: the same thing, but for item models. not mapped other than the name, a couple fields, and the load() method
  • BakedModelManager: just renamed RESOURCE_NAMESPACE to MODEL_NAMESPACE (there's multiple resource namespaces used, this one is for "models")
  • ModelBaker: just an interface for ModelLoader.ModelLoaderBaker
  • n.m.data.client.model.ModelVariantModifier: utility class for modifying ModelVariants during data generation
  • moved n.m.client.render.model.WeightedUnbakedModel to n.m.data.client.model.WeightedUnbakedModel; it appears to only be used during data generation

for the only breaking change: i renamed ModelVariantMap to BlockstateDefinition because

  • it specifically applies to blocks, not all models (compare n.m.client.render.item.model.BaseItemModel)
  • it's equivalent to the block state definition files in assets/<namespace>/blockstates/<entry>.json
  • "variants" are a specific term used within blockstates definitions, but not everything in them is variants
  • blockstate loading has changed quite a lot since this class was first mapped, the behavior of this class has morphed over time
  • why BlockStateDefinition?
    • it's what the Minecraft Wiki calls it, and it's the generally agreed upon term for this thing
    • BlockStateDefinitionProvider already exists in the client data generation package (though that class's name actually might be incorrect now that items also have model definitions)

i tried to follow the naming conventions & guidelines as much as i could, but this is my first mappings PR; let me know if anything should be changed :)

@supersaiyansubtlety supersaiyansubtlety added t: new adds new mappings v: release targets a release version of minecraft outdated this pull request hasn't been updated to the latest version or has merge conflicts reviews needed please review this PR s: medium PRs with less than 700 lines and more than 200 labels Oct 10, 2025
@supersaiyansubtlety supersaiyansubtlety changed the title Map most block state model classes Map most block state model classes 1.21.8 Oct 10, 2025
Copy link
Member

@supersaiyansubtlety supersaiyansubtlety left a comment

Choose a reason for hiding this comment

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

This is good coverage, thanks!
The breakdown and explanations were super helpful, and I especially like the ModelVariantMap -> BlockstateDefinition refactor; nice catch of an outdated name!

I did a bit of a deep dive review, so I have some nit picks and a couple suggestions, but overall this is a great PR.

METHOD m_pwxgnxdm withOrientation (Lnet/minecraft/unmapped/C_blazqqmb$C_ufdansrr;)Lnet/minecraft/unmapped/C_blazqqmb;
ARG 1 orientation
METHOD m_yfzzsmuo orientation ()Lnet/minecraft/unmapped/C_blazqqmb$C_ufdansrr;
CLASS C_ufdansrr Orientation

Choose a reason for hiding this comment

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

Suggested change
CLASS C_ufdansrr Orientation
CLASS C_ufdansrr ModelState

uvLock doesn't really fit in Orientation

CLASS net/minecraft/unmapped/C_blazqqmb net/minecraft/client/render/block/model/ModelVariant
FIELD f_qhvszzcj orientation Lnet/minecraft/unmapped/C_blazqqmb$C_ufdansrr;
FIELD f_szkyblfb location Lnet/minecraft/unmapped/C_ncpywfca;
FIELD f_zldxgrxu CODEC Lcom/mojang/serialization/MapCodec;

Choose a reason for hiding this comment

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

Suggested change
FIELD f_zldxgrxu CODEC Lcom/mojang/serialization/MapCodec;
FIELD f_zldxgrxu MAP_CODEC Lcom/mojang/serialization/MapCodec;

to differentiate it from the non-map codec field

@@ -0,0 +1,34 @@
CLASS net/minecraft/unmapped/C_blazqqmb net/minecraft/client/render/block/model/ModelVariant
FIELD f_qhvszzcj orientation Lnet/minecraft/unmapped/C_blazqqmb$C_ufdansrr;
FIELD f_szkyblfb location Lnet/minecraft/unmapped/C_ncpywfca;

Choose a reason for hiding this comment

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

Suggested change
FIELD f_szkyblfb location Lnet/minecraft/unmapped/C_ncpywfca;
FIELD f_szkyblfb id Lnet/minecraft/unmapped/C_ncpywfca;

qmap tends to use "id"/"identifier" over "location"; qmap's Identifier is mojmap's ResourceLocation

Comment on lines +12 to +13
METHOD m_jwusibwq withIdentifier (Lnet/minecraft/unmapped/C_ncpywfca;)Lnet/minecraft/unmapped/C_blazqqmb;
ARG 1 identifier

Choose a reason for hiding this comment

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

Suggested change
METHOD m_jwusibwq withIdentifier (Lnet/minecraft/unmapped/C_ncpywfca;)Lnet/minecraft/unmapped/C_blazqqmb;
ARG 1 identifier
METHOD m_jwusibwq withId (Lnet/minecraft/unmapped/C_ncpywfca;)Lnet/minecraft/unmapped/C_blazqqmb;

to match the field; the param gets automatically mapped to id

ARG 1 yQuadrant
METHOD m_hcdcljgq withUvLock (Z)Lnet/minecraft/unmapped/C_blazqqmb;
ARG 1 uvLock
METHOD m_ihmyzhvs location ()Lnet/minecraft/unmapped/C_ncpywfca;

Choose a reason for hiding this comment

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

Suggested change
METHOD m_ihmyzhvs location ()Lnet/minecraft/unmapped/C_ncpywfca;
METHOD m_ihmyzhvs id ()Lnet/minecraft/unmapped/C_ncpywfca;

Comment on lines +2 to +4
METHOD m_grlikkhm collectBlockModels (Lnet/minecraft/unmapped/C_rlomrsco;Ljava/util/List;)V
ARG 1 random
ARG 2 bakedModels

Choose a reason for hiding this comment

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

Suggested change
METHOD m_grlikkhm collectBlockModels (Lnet/minecraft/unmapped/C_rlomrsco;Ljava/util/List;)V
ARG 1 random
ARG 2 bakedModels
METHOD m_grlikkhm collectParts (Lnet/minecraft/unmapped/C_rlomrsco;Ljava/util/List;)V
ARG 1 random
ARG 2 parts

to match the updated name for C_uudyvsyc (currently BakedBlockModel)

METHOD m_grlikkhm collectBlockModels (Lnet/minecraft/unmapped/C_rlomrsco;Ljava/util/List;)V
ARG 1 random
ARG 2 bakedModels
METHOD m_ikisitoo getBlockModels (Lnet/minecraft/unmapped/C_rlomrsco;)Ljava/util/List;

Choose a reason for hiding this comment

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

Suggested change
METHOD m_ikisitoo getBlockModels (Lnet/minecraft/unmapped/C_rlomrsco;)Ljava/util/List;
METHOD m_ikisitoo chooseParts (Lnet/minecraft/unmapped/C_rlomrsco;)Ljava/util/List;

to match the updated name for C_uudyvsyc (currently BakedBlockModel)

Choose a reason for hiding this comment

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

this isn't really a "model" itself, so I think something like WeightedVariants would be more accurate

METHOD m_ytjbermp loadPartsForStates (Lnet/minecraft/unmapped/C_ezfeikaq;)Lnet/minecraft/unmapped/C_teykdqpg$C_wyawmrcu;
ARG 1 stateManager
CLASS C_qsaqchhw Variants
FIELD f_gjkxbbmc parts Ljava/util/Map;

Choose a reason for hiding this comment

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

Part for C_iqnucppo is a little off here
the "parts" don't combine to create one model; one complete model is selected

C_iqnucppo is Unbaked on mojmap and yarn, which I think makes more sense here; this field would be models

though this change would require renaming some other inner classes of BlockStateModel

Choose a reason for hiding this comment

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

Since this class contains only static members, conventionally the name would either be plural or have a Util suffix to make it clearer that it's not meant for instantiation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

outdated this pull request hasn't been updated to the latest version or has merge conflicts reviews needed please review this PR s: medium PRs with less than 700 lines and more than 200 t: new adds new mappings v: release targets a release version of minecraft

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants