Skip to content

Render State Data Extraction#5235

Draft
Ramixin wants to merge 3 commits intoFabricMC:26.1from
Ramixin:renderStateDataExtraction
Draft

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

Conversation

@Ramixin
Copy link
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

  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 class of the subject being rendered (ex. LocalPlayer), the key, and a RenderStateDataExtractorCallback. The callback is a functional interface that takes in an instance of the subject class and returns the extracted value.
  3. register the extractor by calling the RenderStateDataExtractionRegistry#register method, which takes in the class of the renderer that the extractor will target and also the extractor itself.

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 have only used mixin on a singular renderer, EntityRenderer, at the moment since I am looking for feedback before I do the remaining ones just in case I butchered this.
  • 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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant