AnotherBackpackContent:Modding API
Other mods can find the backpacks a player carries and move items into or out of them. Better Storage uses this for its Backpacks box.
Overview
The public API is the class com.cyberpiratepenguin.anotherbackpackcontent.api.BackpackAPI. Everything outside the api package is internal and may change in any version.
| Member | Purpose |
|---|---|
API_VERSION |
int, currently 1. Goes up with every new method. Existing methods stay.
|
isBackpack(ItemStack stack) |
Whether the stack is a backpack from this mod. |
backpacks(Ref<EntityStore> player, ComponentAccessor<EntityStore> accessor) |
The contents of every backpack the player carries, as a List<ItemContainer>, in the order hotbar, inventory, backpack slots, utility slot.
|
Using the containers
- Each container carries the filter of its backpack.
addItemStackandmoveItemStackFromSlotonly let in what belongs there. - Every change is written into the backpack item right away. You don't need to save anything.
- The containers are the same instances an open backpack window and the auto-pickup use, so writing to them at the same time doesn't overwrite anything.
- Call the API from the world thread only.
Depending on the mod
The signatures in BackpackAPI are stable. To keep your mod working without Another Backpack Content, call the API through reflection, the way Better Storage does, and list the mod as an optional dependency in your manifest:
"OptionalDependencies": {
"com.cyberpiratepenguin:anotherbackpackcontent": "*"
}
Check API_VERSION before you call a method that was added later.
Item IDs
Backpack IDs follow the scheme ABC_Backpack_<Kind>_<Size>:
- Kind:
Miner,Digger,Forester,Hunter,Builder,Adventurer - Size:
Small,Medium,Big
For example ABC_Backpack_Hunter_Big. All backpacks carry the tags Type: Utility and Family: Backpack.
| Another Backpack Content | |
|---|---|
| Start | Installation · Getting Started |
| Backpacks | Overview · Miner's · Digger's · Forester's · Hunter's · Builder's · Adventurer's |
| Mechanics | Crafting · Auto-Pickup · Item Filters · Better Storage |
| Reference | Modding API · Version History |
| Links | Project page on mutigeraffe.com · Download on CurseForge |