Support modifying data attachments using the /data command#5280
Open
modmuss50 wants to merge 4 commits intoFabricMC:26.1from
Open
Support modifying data attachments using the /data command#5280modmuss50 wants to merge 4 commits intoFabricMC:26.1from
modmuss50 wants to merge 4 commits intoFabricMC:26.1from
Conversation
There was a problem hiding this comment.
Pull request overview
Adds dedicated handling for /data-driven updates to Fabric data attachments so attachment callbacks and sync behavior stay consistent (fixing desync reported in #5275).
Changes:
- Wraps vanilla
EntityDataAccessor#setDataandBlockDataAccessor#setDatato apply attachment changes through Fabric’s high-level attachment APIs. - Skips the normal “read attachments from NBT” path while
/datais being applied, and applies diffs via a newDataAccessorHandler. - Adds unit tests plus a client gametest to validate
/data modifyupdates sync to clients.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/impl/attachment/DataAccessorHandler.java | New helper that diffs and applies attachment changes during /data operations. |
| fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/BlockDataAccessorMixin.java | Wraps block /data application to route attachment updates through DataAccessorHandler. |
| fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/EntityDataAccessorMixin.java | Wraps entity /data application to route attachment updates through DataAccessorHandler. |
| fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/AttachmentTargetsMixin.java | Avoids applying attachment NBT directly while a /data change is in progress. |
| fabric-data-attachment-api-v1/src/main/resources/fabric-data-attachment-api-v1.mixins.json | Registers the new accessor mixins. |
| fabric-data-attachment-api-v1/src/test/java/net/fabricmc/fabric/test/attachment/DataAccessorHandlerTests.java | New unit tests validating attachment add/update/remove behavior via DataAccessor set/merge. |
| fabric-data-attachment-api-v1/src/test/java/net/fabricmc/fabric/test/attachment/CommonAttachmentTests.java | Exposes mockRA() for reuse by new unit tests. |
| fabric-data-attachment-api-v1/src/testmodClient/java/net/fabricmc/fabric/test/attachment/client/gametest/SyncGametest.java | Extends client gametest to verify /data modify updates a synced attachment and reaches the client. |
| fabric-data-attachment-api-v1/src/testmod/java/net/fabricmc/fabric/test/attachment/AttachmentTestMod.java | Adds chicken initialization behavior for a synced item attachment in the testmod. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...attachment-api-v1/src/main/java/net/fabricmc/fabric/impl/attachment/DataAccessorHandler.java
Outdated
Show resolved
Hide resolved
...attachment-api-v1/src/main/java/net/fabricmc/fabric/impl/attachment/DataAccessorHandler.java
Show resolved
Hide resolved
...src/testmodClient/java/net/fabricmc/fabric/test/attachment/client/gametest/SyncGametest.java
Show resolved
Hide resolved
...chment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/AttachmentTargetsMixin.java
Outdated
Show resolved
Hide resolved
...hment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/EntityDataAccessorMixin.java
Show resolved
Hide resolved
DennisOchulor
suggested changes
Mar 29, 2026
...chment-api-v1/src/main/java/net/fabricmc/fabric/mixin/attachment/BlockDataAccessorMixin.java
Outdated
Show resolved
Hide resolved
...attachment-api-v1/src/main/java/net/fabricmc/fabric/impl/attachment/DataAccessorHandler.java
Outdated
Show resolved
Hide resolved
...attachment-api-v1/src/main/java/net/fabricmc/fabric/impl/attachment/DataAccessorHandler.java
Show resolved
Hide resolved
DennisOchulor
approved these changes
Mar 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR add a seperate set of logic for handling data attachment updates when using the /data command. This ensures that the correct events are fired, and the changes are synced to the client if required. It does so by using the higher level API's for updating data attachments as opposed to overwriting the list of attachments without progagating the updates as required.
Fixes #5275