Fabric API

Fabric API

152M Downloads

Add attachment holder context to creation

Flemmli97 opened this issue ยท 3 comments

commented

Currently the default initializer for attachment only accepts a supplier. it would be better if it can also accepts a function that provides the current holder of the attachment.
https://github.com/FabricMC/fabric/blob/1.21.8/fabric-data-attachment-api-v1/src/main/java/net/fabricmc/fabric/api/attachment/v1/AttachmentRegistry.java#L151

This way if you e.g. wanted an attachment for an entity and provide modification access to the attachment that requires the entity too you don't need to create a method with the entity as one of the args all the time.

commented

I think this was rejected due to generic problems? You can currently somewhat work around it by creating your own entity/world/block entity load event at the right spot, and using the attachment changed event to handle all further changes.

commented

tbh can just have Function<Object, T> and it lies on the modder to properly check. (not too sure how to handle it otherwise either)

commented

I don't think they wanted that, but it's in an issue now