Fabric API

Fabric API

112M Downloads

Block state groups for `BlockStateResolver` and color properties

Technici4n opened this issue ยท 0 comments

commented

(For the not-yet released Model Loading API v1).

Vanilla does some block state grouping (this is the stateLookup thing in yarn - mojmap calls it modelGroups) when it sees that the block state models for multiple states are identical. Vanilla tries to avoid re-drawing the chunk if a block state changes, but the model group does not change. (see BakedModelManager#shouldRerender)

Currently all models added by BlockStateResolvers would be unmapped in the groups, so they would always be redrawn. Should we add a way to support model groups?
A possibility would be the following override in the block state context, grouping block states by modelGroup in a hash map:

    void setModel(BlockState state, UnbakedModel model, Object modelGroup);

As a related issue, vanilla models forces some block state properties to be in different model groups when they have equivalent JSON models, but the property is used to compute the color. See BlockColors#registerColorProperties. This is not relevant to BlockStateResolver models, but might be relevant to standard JSON block models added by mods.

Original discussion: https://discord.com/channels/507304429255393322/1122471818150825994/1128680466397016166.