Skip to content
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

Render Data API v2 #3140

Closed

Conversation

PepperCode1
Copy link
Member

@PepperCode1 PepperCode1 commented Jun 24, 2023

This pull requests adds the Render Data v2 module, which directly supersedes the existing Rendering Data Attachment v1 module.

The original goal was to interface inject the two interfaces provided by Rendering Data Attachment v1, RenderAttachmentBlockEntity and RenderAttachedBlockView, to allow for an easier to use API. It proved to be impossible to achieve this and still provide a clean API without making a new module, as explained below.

The documentation of RenderAttachedBlockView states that it is guaranteed to be implemented on all instances of BlockRenderView, but this is not the case. The module implementation only guarantees that all WorldView instances implement the interface. RenderAttachedBlockView extends BlockRenderView, meaning that trying to change the mixin to satisfy the stated contract is not possible; thus, it can be deduced that the mixin is correct but the stated contract is not, though such a contract does not lead to an easy to use API. Such an API design also makes interface injection of RenderAttachedBlockView impossible.

To allow for the currently stated contract to be satisfied and to allow for interface injection to happen, a new module was made. It uses the same design as the existing module, with two interfaces that each have one method. Of course, the replacement for RenderAttachedBlockView no longer extends BlockRenderView. Some terminology and class member names were changed when creating the new module. The object that used to be termed "Render Data Attachment" or "Render Attachment" has been renamed to "Block Entity Render Data" or simply "Render Data". All methods, documentation, and other mentions of the old terms, apart from within the existing module, have been changed to use the new terms. Additionally, the documentation was rewritten to be more concise, provide more examples, remove mentions of implementation details, and add concrete requirements for use of certain methods.

The existing module has been completely deprecated and its documentation has been updated to state the contract that is actually satisfied and link to the v2 replacements. It was not possible to achieve perfect backward and forward compatibility since this would result in infinite recursion at first thought and degraded performance with an actual implementation. To compromise, it was observed that the BlockRenderView extension interface is invoked much more frequently than it is implemented, and that the BlockEntity extension interface is implemented much more frequently than it is invoked. As such, it was decided that the v1 BlockRenderView extension interface should proxy to v2 and the v2 BlockEntity extension interface should proxy to v1.

- Fix mixins of v1
- Use `fabric_` instead of `fabric$`; remove prefix completely in some cases
- Improve javadoc
- Remove dependencies on `fabric-api-base`
- Bump `fabricloader` dependency of v2
- Attempt to fix checkstyle
@PepperCode1 PepperCode1 changed the title Render Data v2 Module Render Data v2 Jun 24, 2023
@PepperCode1 PepperCode1 marked this pull request as ready for review June 24, 2023 16:46
- Clarify required checks after calling `RenderDataBlockView#getBlockEntityRenderData`
@PepperCode1 PepperCode1 changed the title Render Data v2 Render Data API v2 Jun 24, 2023
Copy link
Member

@Technici4n Technici4n left a comment

Choose a reason for hiding this comment

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

All good now. It would be great to test backwards compatibility in prod, just in case.

@modmuss50
Copy link
Member

Might be a nice idea to edit the PR description to include a short rundown of what is diffrent with this new API as its not that obvious, and possibly a migration guide. I usually copy these into the commit when suqishing+merging.

@modmuss50 modmuss50 requested review from modmuss50 and a team June 25, 2023 11:18
@Technici4n
Copy link
Member

Yes this would be nice. We could then reference the PR in the update announcement.

Something else we need at the ready for the announcement is the gradle invocation to include the old API back in dev:

"The old v0 rendering data attachment module is deprecated, and therefore not in the default dev jar anymore. Here is how to add it back if you don't want to update immediately:

"

@modmuss50 modmuss50 added enhancement New feature or request last call If you care, make yourself heard right away! labels Jun 28, 2023
@Technici4n Technici4n removed the last call If you care, make yourself heard right away! label Jul 1, 2023
@PepperCode1
Copy link
Member Author

Superseded by #3268.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants