DaFuqs / Spectrum

A full-feature minecraft mod about harnessing the powers of color
Other
95 stars 51 forks source link

Allow staves to draw from bottomless bundles #334 #398

Closed KatTheFox closed 1 month ago

DaFuqs commented 1 month ago

Looking good! Can you change the dedicated check for the Bottomless Bundle for a more generic one that can also handle vanilla Bundles, Shulker Boxes (and other modded stuff, maybe?).

KatTheFox commented 1 month ago

Oh, good point, I'll look into that tomorrow

DaFuqs commented 1 month ago

No hurry whatsoever

unilock commented 1 month ago

Can you change the dedicated check for the Bottomless Bundle for a more generic one that can also handle vanilla Bundles, Shulker Boxes (and other modded stuff, maybe?).

I think the intended way to do that is with the Fabric API Lookup API; in this case, specifically ItemApiLookup.

I'm not sure if there's actually a standardized item storage API to lookup, however...

DaFuqs commented 1 month ago

however...

1.20.6 Components in the corner be like:

KatTheFox commented 1 month ago

I can at least allow it to draw from bundles. I'm not actually sure how shulkers store their items, since there's no documentation on the wiki (besides the new components which should of course make this way easier, however as of right now we're working with 1.20.1 so jank time it is), I'll do some testing. Bundles seem to just store their items in the 'items' nbt tag, which shouldn't be too hard to handle.

KatTheFox commented 1 month ago

oh wow, nice. i was struggling to find a sensible way to do that

unilock commented 1 month ago

Botania, for example, does something similar using FAPI lookup, but there indeed does not seem to be a generic way to do this.

I made a basic mod that implements the Fabric Lookup API for finding Storage<ItemVariant> instances from ItemStack instances, which registers Bundles (untested) and Shulker Boxes (tested, working!) by default: https://github.com/unilock/ItemStorageProviderAPI

Notably, it supports extracting and inserting items to/from the inventory-bearing items.

Though I'm not sure it's worth finishing when it was already made obsolete in 1.20.5 :P

Noaaan commented 1 month ago

The implementation might be obsolete, but the idea is still sound. In a 1.20.5+ context: How can you ensure that a custom component provided by a mod actually provides some form of storage? It could be as simple as iterating over them and checking whether they have an interface, but as it is right now this is not something a vanilla ContainerComponent has. For item-exclusive storage people might stick to the Container component, after all, it supports up to 256 slots. But for mixed storages and custom component implementations, an API like this would still be useful