106 lines
3.3 KiB
Markdown
106 lines
3.3 KiB
Markdown
# Bag Tabs API
|
|
|
|
Bag Tabs exposes a small runtime API so other mods can make their portable storage items fully compatible without needing Bag Tabs to ship a built-in compat layer.
|
|
|
|
There are two pieces:
|
|
|
|
- Core API: register a bag provider
|
|
- Optional Curios helper: expose Curios slot tag keys for wearable bags
|
|
|
|
## Dependency Setup
|
|
|
|
Add Bag Tabs as a compile-time dependency in your development environment.
|
|
|
|
Your mod only needs the Bag Tabs jar present at runtime if you want to call the API directly. If you want Bag Tabs compatibility to stay optional, gate registration behind a Bag Tabs loaded check in your own mod.
|
|
|
|
## Core API
|
|
|
|
Register a provider with:
|
|
|
|
`com.trunksbomb.bagtabs.api.BagTabsApi.registerProvider(...)`
|
|
|
|
Implement:
|
|
|
|
- [BagTabsProvider](C:\Users\JessePersonal\Documents\Codex\minecraft-bag-tabs\src\main\java\com\trunksbomb\bagtabs\api\BagTabsProvider.java)
|
|
|
|
Supporting types:
|
|
|
|
- [BagTabsIdentity](C:\Users\JessePersonal\Documents\Codex\minecraft-bag-tabs\src\main\java\com\trunksbomb\bagtabs\api\BagTabsIdentity.java)
|
|
- [BagTabsLocation](C:\Users\JessePersonal\Documents\Codex\minecraft-bag-tabs\src\main\java\com\trunksbomb\bagtabs\api\BagTabsLocation.java)
|
|
|
|
### What a provider can do
|
|
|
|
- declare whether an `ItemStack` is one of your bags
|
|
- provide a stable or semi-stable identity for pinning and ordering
|
|
- open the bag natively
|
|
- support drag-insert from the carried stack
|
|
- report whether a menu is the active/open bag menu
|
|
- report fullness for the fullness indicator
|
|
|
|
### Minimal Example
|
|
|
|
A concrete copy-and-adapt example lives here:
|
|
|
|
- [ExampleBagTabsCompat.java](C:\Users\JessePersonal\Documents\Codex\minecraft-bag-tabs\src\test\java\com\trunksbomb\bagtabs\api\examples\ExampleBagTabsCompat.java)
|
|
|
|
## Identity Rules
|
|
|
|
Use a stable identity whenever possible.
|
|
|
|
Recommended:
|
|
|
|
- UUID stored on the item stack
|
|
- your mod's own saved container id
|
|
- another durable unique id already used by your bag system
|
|
|
|
Fallback only if you truly do not have a unique identifier:
|
|
|
|
- `modid + normalized display name`
|
|
|
|
That fallback behaves as semi-unique, which means only one matching bag can be pinned at a time.
|
|
|
|
## Optional Curios Helper
|
|
|
|
If your bag is wearable in Curios, you do not need a second Bag Tabs provider.
|
|
|
|
Register the same core provider once, then mark your item as wearable in Curios with the helper constants/tag keys from:
|
|
|
|
- [BagTabsCuriosApi](C:\Users\JessePersonal\Documents\Codex\minecraft-bag-tabs\src\main\java\com\trunksbomb\bagtabs\api\curios\BagTabsCuriosApi.java)
|
|
|
|
Helpers:
|
|
|
|
- `BagTabsCuriosApi.BACK_SLOT`
|
|
- `BagTabsCuriosApi.BELT_SLOT`
|
|
- `BagTabsCuriosApi.backTag()`
|
|
- `BagTabsCuriosApi.beltTag()`
|
|
- `BagTabsCuriosApi.tagForSlot(...)`
|
|
|
|
### Curios Example
|
|
|
|
If your item already has a provider registered with the core API, Bag Tabs will use that same provider when the item is found in a Curios slot.
|
|
|
|
You only need to make the item wearable in Curios, for example by adding Curios item tags:
|
|
|
|
```json
|
|
{
|
|
"replace": false,
|
|
"values": [
|
|
"examplemod:example_bag"
|
|
]
|
|
}
|
|
```
|
|
|
|
For a back slot tag file:
|
|
|
|
`data/curios/tags/item/back.json`
|
|
|
|
For a belt slot tag file:
|
|
|
|
`data/curios/tags/item/belt.json`
|
|
|
|
## Notes
|
|
|
|
- The Bag Tabs API is runtime registration, not a datapack format.
|
|
- One provider is enough for both normal inventory support and Curios-worn support.
|
|
- Curios support is optional; the core Bag Tabs API does not require Curios classes.
|