Power inventories
An origins:inventory power keeps its items inside Origins' power data. There are two ways to reach them:
| You want to… | Use | Reaches |
|---|---|---|
| Check or change your own power inventory from power JSON | Origins' own types, below | only the entity running the condition or action |
| Read it from a function, or copy/move items between players, or between a power and a normal slot | /opp powerinv (OPP) | any entity, any power, any vanilla slot |
Vanilla /item and /data can't see power inventories.
Slots: a power's slots are container.0 … container.<size-1>, as in Origins' item_slot docs. The size depends on the power's container_type: dropper has 9 (the default), hopper 5, chest 27.
From power JSON (Origins, no OPP needed)
The inventory is named by its power id. Four Origins types accept it:
| Type | Field that selects power inventories | Plus |
|---|---|---|
origins:inventory (entity condition) | "inventory_types": ["power"], an array | "power": "<id>" |
origins:modify_inventory (entity action) | "inventory_type": "power", a single value | "power": "<id>" |
origins:replace_inventory (entity action) | "inventory_type": "power" | "power": "<id>" |
origins:drop_inventory (entity action) | "inventory_type": "power" | "power": "<id>" |
Catches:
- You need both fields. With
poweralone, the player's normal inventory is used. Withinventory_type(s)alone, no power inventory is used. - Slots past the power's size are skipped silently.
- Only your own inventory. All four types act only on the entity they run on, with no bi-entity version. To move items between players, use
/opp powerinv.
Example: does slot 0 of mypack:satchel hold at least 1 item?
{
"type": "origins:inventory",
"inventory_types": [
"power"
],
"power": "mypack:satchel",
"slot": "container.0",
"comparison": ">=",
"compare_to": 1
}Example: use up one item from each of the first three slots.
{
"type": "origins:modify_inventory",
"inventory_type": "power",
"power": "mypack:satchel",
"slots": [
"container.0",
"container.1",
"container.2"
],
"item_action": {
"type": "origins:consume",
"amount": 1
}
}From commands: /opp powerinv
Needs permission level 2, like /item.
opp powerinv get <target> <power> <slot>
opp powerinv id <target> <power> <slot>
opp powerinv set <target> <power> <slot> <item> [count]
opp powerinv clear <target> <power> [slot]
opp powerinv copy <from> <to>
opp powerinv move <from> <to><from> and <to> are each one of:
power <target> <power> <slot>: a slot in a power inventory, such aspower @s mypack:satchel container.3entity <target> <slot>: any vanilla slot, such asentity @s hotbar.0orentity @s enderchest.5
<target> must be exactly one entity holding the power, and the power must be an origins:inventory power. Otherwise the command fails with the reason.
| Subcommand | What it does | Result (for execute store result) |
|---|---|---|
get | Shows the stack in the slot | the item count, or 0 if empty |
id | Prints the item's id on its own, as plain text: minecraft:spruce_log, or minecraft:air for an empty slot | the item's number in the item registry |
set | Replaces the slot with a new stack | the count set |
clear | Empties one slot, or the whole power if no slot is given | items removed (one slot) or stacks removed (whole power) |
copy | Copies the source stack over the destination, overwriting it. The source keeps its item. | the count copied |
move | Moves the stack and empties the source. It only moves into an empty destination, so items are never duplicated or lost. | the count moved, or 0 if the source was empty |
Examples:
How many items are in slot 0, stored in a score:
execute store result score @s satchel_0 run opp powerinv get @s mypack:satchel container.0Hand one player's slot 0 to another player's matching slot:
opp powerinv move power @s mypack:satchel container.0 power @p[tag=partner] mypack:satchel container.0Pull a power slot into the hotbar, or put the held item into the power:
opp powerinv move power @s mypack:satchel container.0 entity @s hotbar.0
opp powerinv move entity @s weapon.mainhand power @s mypack:satchel container.4Reading item types
Three ways to find out what is in a slot:
| From | Use |
|---|---|
Variable code, conditions, ${…} | Item.id(power, slot) and Item.count(power, slot) |
| Power JSON, as a list you can loop over | origins-powerful-powers:item_list |
| Commands and functions | opp powerinv id |
Item.id and Item.count
held = Item.id("mypack:satchel", 0); // "minecraft:spruce_log", or "minecraft:air" when empty
stack = Item.count("mypack:satchel", 0); // 5
weapon = Item.id("weapon.mainhand"); // a vanilla slot
theirs = Item.id(other, "mypack:satchel", 0); // the target's satchel, in bientity code
gotLogs = Item.id("mypack:satchel", 0).endsWith("_log");| Call | Returns | |
|---|---|---|
Item.id(power, slot) | String | the item in a power inventory slot: its full id, namespace:item. An empty slot is minecraft:air. |
Item.count(power, slot) | int | the stack size there, 0 when empty |
Item.id(slot) | String | the item in a vanilla slot, named as in /item |
Item.count(slot) | int | the stack size there |
- Power slots: the power is its id as a String, and the slot is a plain number, so
Item.id("mypack:satchel", 3)iscontainer.3. - Vanilla slots:
weapon.mainhand,weapon.offhand,armor.head,armor.chest,armor.legs,armor.feet,hotbar.0tohotbar.8,inventory.0toinventory.26,enderchest.0toenderchest.26. The short formsmainhand,offhand,head,chest,legsandfeetwork too. Hands and armor work on any living entity. The rest are players only. - Whose inventory: the power holder by default, or the actor in bi-entity code. Put
selforotherfirst to choose:Item.count(other, "weapon.mainhand").otheronly exists in bi-entity actions and conditions (page 8). - They're read-only, so they work in
executecode,expressionconditions,modify_variablevalues and${…}(page 9). Field initializers can't use them. - An unknown power, a power the entity lacks, a power of another type, an unknown slot name, or a slot outside the inventory is an error. The action stops there, a condition counts as
false, and the message says which.
Example: in a bi-entity action, take note of what the entity you hit is holding.
{
"type": "origins:action_on_hit",
"bientity_action": {
"type": "origins-powerful-powers:execute",
"code": "lastVictimWeapon = Item.id(other, \"weapon.mainhand\");"
}
}Example: true when slot 0 holds logs or is empty.
{
"type": "origins-powerful-powers:expression",
"expression": "Item.id(\"mypack:satchel\", 0).endsWith(\"_log\") || Item.count(\"mypack:satchel\", 0) == 0"
}Item.cooldown
pearl = Item.cooldown("minecraft:ender_pearl"); // 20 right after throwing one, 0 when it's ready
held = Item.cooldown("weapon.mainhand"); // the item in your main hand
theirs = Item.cooldown(other, "weapon.offhand"); // the target's offhand, in bientity code| Call | Returns | |
|---|---|---|
Item.cooldown(itemOrSlot) | int | ticks left on the item's vanilla cooldown (the one ender pearls use), 0 when it has none |
- The argument is an item id (
minecraft:ender_pearl) or a vanilla slot name as inItem.id. A slot name reads the item in that slot. - It's
0for non-players. - An unknown item id or slot name is an error.
- The
item_on_cooldowncondition reads the same value. Set it withset_item_cooldown.
opp powerinv id
opp powerinv id @s mypack:satchel container.0prints exactly:
minecraft:spruce_logIts result is the item's number in the item registry, so a score can track a slot's item:
execute store result score @s slot0_item run opp powerinv id @s mypack:satchel container.0Every spruce log has the same number, and stone has a different one. The numbers can change when mods or versions change, so only compare readings from the same session. Code can read the score with Scoreboard.get.
Watching a slot for changes
Item.id plus Item.count fingerprints a slot. It catches a stack growing or shrinking and a same-size swap (5 logs for 5 stone). Keep last tick's fingerprints in a list and compare:
now = Item.id("mypack:satchel", index) + " x" + Item.count("mypack:satchel", index);
changed = !value.equals(now);A complete power that keeps several players' satchels in step is in the cookbook.
Two players sharing items
move makes a duplication-free outbox: one player puts an item in their own power slot, and a function moves it into the partner's matching slot. If the partner's slot is full, the item stays where it is.
Mirroring an inventory with copy in both directions can duplicate items, because a command can't tell whether an item was taken out or never there.