Skip to content

Render State Data Extraction#5235

Open
Ramixin wants to merge 27 commits intoFabricMC:26.1from
Ramixin:renderStateDataExtraction
Open

Render State Data Extraction#5235
Ramixin wants to merge 27 commits intoFabricMC:26.1from
Ramixin:renderStateDataExtraction

Conversation

@Ramixin
Copy link
Copy Markdown
Contributor

@Ramixin Ramixin commented Mar 1, 2026

Render State Data Extraction

Goal

After the addition of RenderStateDataKey, there is not a way, through the Fabric API, to set that data automatically without the user using mixin to gain access to the extract method for the given subject. These classes allow the user to register extractors, which fulfill those keys automatically.

How to use (for non-avatar entities)

  1. create a RenderStateDataKey that the extractor will be used with. The generic type associated with this key determines the type of data that the extractor will be extracting
  2. create a RenderStateDataExtractor by passing it: the EntityType of the entity being rendered (ex. EntityType.CREEPER), the key, and a RenderStateDataExtractorCallback. The callback is a functional interface that takes in an instance of the entity, as well as the delta ticks, and returns the extracted value.
  3. register the extractor by calling the RenderStateDataExtractionRegistry#register method, which only requires the extractor to be passed to it.

How to use (for avatar entities)

  1. Same as the first step above
  2. create the RenderStateDataExtractor through the createAvatar method instead of the create method. This new method does not require an EntityType to be passed.
  3. register the extractor with the method registerAvatar instead of register. Failing to call the correct method for registration will throw an IllegalArgumentException.

Current notes about the implementation

  • This is my first addition to the Fabric API with actual substance to it, so I may have messed up the implementation style Fabric uses (ex. impl class and interfaces). Please let me know what I need to fix.
  • I was not sure how to go about the test for this system, so let me know if the current test class needs to be redone/simplified.

Ramixin and others added 6 commits March 1, 2026 15:59
- Fixed checkstyle issue in RenderStateDataExtractionRegistryImpl
* 26.1-snapshot-11

* Fix client tests.

* Bump version
Due to release failuire
Due to release failuire
@Patbox Patbox added enhancement New feature or request area: rendering labels Mar 3, 2026
Copy link
Copy Markdown
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.

I have just posted some rough thoughts on how I imagined doing this. Its quite possible I missed something funimental that prevents my solution from working though. Let me know what you think or if something doesnt make sense.

@Ramixin
Copy link
Copy Markdown
Contributor Author

Ramixin commented Mar 8, 2026

I rewrote the system to focus on entity renderers in particular rather than trying to generalize to all renderers. The new system moves the extractor references to the renderers as soon as they are created during resource loading rather than having the renderers constantly look them up from the registry.

I did not implement a factory for RenderStateDataExtractor since I feel it is very streamlined at the moment, but I am happy to do so if it still feels needed.

The system has separate methods for working with avatar entities, which may be a bit overkill, so any advice is welcome.

@Ramixin Ramixin marked this pull request as ready for review March 8, 2026 19:31
@Ramixin Ramixin requested a review from modmuss50 March 8, 2026 19:32
- Removed RenderStateDataExtractionRegistry and impl
- Repurposed callback interface into an event
Ramixin and others added 12 commits March 8, 2026 18:00
- Fixed checkstyle
- Fixed questionable design choices
- Removed game test (now covered by RenderLayerTest)
- removed mixin AvatarRendererMixin used by RenderLayerTest
- Renamed FabricEntityRenderer to EntityRenderStateExtractorHolder
- removed interface injection of EntityRenderStateExtractorHolder
- Fixed old game test entrypoint still being present in the fabric.mod.json
- Moved extraction movement from event invoker to context cleanup
- Fixed checkstyle issue in RenderStateDataExtractionRegistryImpl
- Fixed some checkstyle issues
- Removed unit test
- Removed RenderStateDataExtractionRegistry and impl
- Repurposed callback interface into an event
- Renamed FabricEntityRenderer to EntityRenderStateExtractorHolder
- removed interface injection of EntityRenderStateExtractorHolder
- Fixed old game test entrypoint still being present in the fabric.mod.json
- Moved extraction movement from event invoker to context cleanup
* initial implementation

* fix AttachmentTargetsMixin error

* add some tests

* fix tests

* remove transitive interface injection for ClientPacketListener

* use IdentityHashMap for player connections

* woops readd ClientboundCustomPayloadPacketAccessor to mixins.json

* add proper docs to new API

* incremental sync global attachments using ServerConnectionListener
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: rendering enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants