Skip to content

Commit

Permalink
Fix syncing block entity attachments on load. (#4390)
Browse files Browse the repository at this point in the history
* Fix syncing block entity attachments on load.

Closes #4389

* Return success

(cherry picked from commit 7e31339)

(cherry picked from commit 8212661)
  • Loading branch information
modmuss50 committed Jan 21, 2025
1 parent 5ca99b9 commit 9ed317f
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.world.World;
Expand Down Expand Up @@ -100,7 +101,7 @@ public void fabric_readAttachmentsFromNbt(NbtCompound nbt, RegistryWrapper.Wrapp
if (this.fabric_shouldTryToSync() && this.fabric_dataAttachments != null) {
this.fabric_dataAttachments.forEach((type, value) -> {
if (type.isSynced()) {
acknowledgeSynced(type, value);
acknowledgeSynced(type, value, wrapperLookup);
}
});
}
Expand All @@ -117,8 +118,9 @@ public boolean fabric_hasPersistentAttachments() {
}

@Unique
private void acknowledgeSynced(AttachmentType<?> type, Object value) {
acknowledgeSyncedEntry(type, AttachmentChange.create(fabric_getSyncTargetInfo(), type, value, fabric_getDynamicRegistryManager()));
private void acknowledgeSynced(AttachmentType<?> type, Object value, RegistryWrapper.WrapperLookup wrapperLookup) {
DynamicRegistryManager dynamicRegistryManager = (wrapperLookup instanceof DynamicRegistryManager drm) ? drm : fabric_getDynamicRegistryManager();
acknowledgeSyncedEntry(type, AttachmentChange.create(fabric_getSyncTargetInfo(), type, value, dynamicRegistryManager));
}

@Unique
Expand Down

0 comments on commit 9ed317f

Please sign in to comment.