Skip to content

Conversation

@8s2
Copy link
Contributor

@8s2 8s2 commented Oct 9, 2025

Vanilla's rendering overhaul with the RenderCommandQueue has made it nearly impossible to create a custom armor renderer that can render properly on any biped entity with the ArmorRenderer in its current implementation. In Vanilla, the setAngles method for models is now called when a ModelCommand is rendered, meaning that calling it before submitting a model to the render queue is not a reliable way to transform a model.

For example, the current armor rendering test mod adds a renderer for a helmet and chestplate. The model has visibility of its parts set based on the equipment slot, but because this happens before the model is submitted, it leads to visibility conflicts when the helmet and chestplate are worn at the same time. Furthermore, the model's arms swing when it is worn on an armor stand (ignores the armor stand's poses too) and it does not scale properly on differently sized biped mobs.

I am creating this pull request to not only provide a solution for this issue, but to also provide some related upgrades that help with armor rendering.

This PR includes:

  • A factory-based option for registering an ArmorRenderer.
    • Current implementations of ArmorRenderer need a mutable and nullable model field that is checked on render and instantiated if null.
    • Renderers registered with a factory are reinstantiated on resource pack reload, which keeps their models up to date.
  • The TransformCopyingModel
    • A workaround for transforms being applied on model command render, this model type has a source (Model<? super S>) and delegate (Model<? super D>) model field, with its render state holding both the source and delegate states at the same time (Pair<S, D>). When the setAngles method for this model is called, it sets the source model's angles using the first pair value, copies the transforms to the delegate model, then optionally sets the angles for the delegate model. The delegate model is what gets rendered.
    • Two static methods for rendering a TransformCopyingModel have been added to ArmorRenderer, based on the renderPart static method that used to be there.
  • EntityModelLayerRegistry register method for EquipmentModelData<EntityModelLayer>
    • Vanilla now handles armor models using the EquipmentModelData class, this allows users to do the same.
  • FabricModel injected interface
    • Adds the getChildPart and copyTransforms methods, which were needed to make the TransformCopyingModel to function. I find them useful enough to users for this to be a injected interface rather than just a mixin duck.
    • Models now cache a map of their model parts with a String key for their names.

@Juuxel Juuxel self-requested a review October 9, 2025 10:13
@PepperCode1 PepperCode1 added reviews needed This PR needs more reviews area: rendering labels Oct 10, 2025
@Sollace
Copy link
Contributor

Sollace commented Oct 15, 2025

I wouldn't say it's entirely impossible. For example, I'm making use of a custom render command for my in-progress porting of Mine little Pony to 1.21.10

https://github.com/MineLittlePony/MineLittlePony/blob/1.21.10/src/main/java/com/minelittlepony/client/render/command/CustomModelRenderCommand.java

@modmuss50 modmuss50 added the priority: high High priority PRs that need review and work now. Review these first. label Oct 30, 2025
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.

Generally looks great, just a few questions.

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 good to me, but really needs someone familar with this area to approve.

@modmuss50 modmuss50 added the status: last call If you care, make yourself heard right away! label Nov 2, 2025
Copy link
Member

@Juuxel Juuxel left a comment

Choose a reason for hiding this comment

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

Looks generally fine to me.

I have a custom ArmorRenderer in 1.21.10 that doesn't need these changes, but I assume that's because I render block models instead of entity models.

@modmuss50 modmuss50 added the status: merge me please Pull requests that are ready to merge label Nov 3, 2025
@modmuss50 modmuss50 merged commit bee81f0 into FabricMC:1.21.10 Nov 4, 2025
4 checks passed
modmuss50 pushed a commit that referenced this pull request Nov 4, 2025
* Add EquipmentModelData to EntityModelLayerRegistry

* Add TransformCopyingModel

* Upgrade ArmorRenderer

* Update tests

* Mark FabricModel as NonExtendable

* Fix FabricModel doc

Co-authored-by: Juuz <[email protected]>

* Make ModelMixin package-private

Co-authored-by: Juuz <[email protected]>

* Make EntityRenderManagerMixin package-private

Co-authored-by: Juuz <[email protected]>

* Remove try-catch block in ArmorRendererRegistryImpl

* Make TransformCopyingModel final

* Use spaces for alignment in ArmorRenderer

---------

Co-authored-by: Juuz <[email protected]>

(cherry picked from commit bee81f0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: rendering priority: high High priority PRs that need review and work now. Review these first. reviews needed This PR needs more reviews status: last call If you care, make yourself heard right away! status: merge me please Pull requests that are ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants