-
-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[1.21.3] RegisterRenderStateModifiersEvent
and EntityRenderState
extends AttachmentHolder
#1650
base: 1.21.x
Are you sure you want to change the base?
Conversation
|
I think that having:
Also, are there thread-safety or similar issues that would force us to make the data immutable? Or is it fine to directly reference the entity or something that it contains? |
I mentioned in the description that the key system and extension system were two different examples for how it could work, only one would be implemented. I somewhat agree that the attachments would be enough (and yes, while it's mutable, it's a copy and wouldn't affect the client entity), though there may be some aspects that simply would be better off not using attachments and should use something else to extend the RenderState. Tslat mentioned in neocord that generic extension outside of attachments would be necessary. |
An idea might be to use a context map 🤔 |
@dhyces, this pull request has conflicts, please resolve them for this PR to move forward. |
1. Moved callsite to `createRenderState`. This differs from feedback, though I believe is a better location, seeing as the method is final and will apply modifiers if users call the method. 2. Some classes have been renamed to better reflect behavior 3. Use ContextKey instead of custom class 4. Retain each modifier separately so that subclasses may be considered 5. Use lazily evaluated map for storing all modifiers that apply to a given renderer
92ee698
to
a8ef1cf
Compare
UpdateRenderStateEvent
and EntityRenderState
extends AttachmentHolder
RegisterRenderStateModifiersEvent
and EntityRenderState
extends AttachmentHolder
Closes #1638
Consider this an RFC atm.
This PR targets extensibility of
EntityRenderState
due to how inextensible the new render state system is. To do this, we will expand the class withAttachmentHolder
to allow users to query attachment data in rendering. The attachments are copied to ensure the values are not mutated between the render state update and the user's custom rendering. The other system added on top allows for adding client-sided elements to render states, used when the data stored is not related to attachments. To accomplish this, a new event is addedRegisterRenderStateModifiersEvent
. The event currently has only one method,registerEntityModifier
, which accepts the targeted renderer class and a modifier function, though should be extended with another methodregisterItemModifier
in 1.21.4 forItemStackRenderState
s. TheEntityRenderStateModifier
accepts the entity instance and the render state, after callingextractRenderState
. Users would then modify the render state by callingIEntityRenderState#setRenderData
with a statically initializedContextKey
and the data they wish to store. Every modifier that applies to the renderer is run, including modifiers that target superclasses. These collections are cached to be as efficient as possible.