Inventory Action (Entity Action Type)

Walks the entity's inventory or a power inventory and performs one operation per matching slot — the operation field replaces the separate modify_inventory, replace_inventory and drop_inventory actions.

Walks the items of either the entity’s inventory or an apoli:inventory, and performs one operation per matching slot. This single action replaces Apace’s modify_inventory, replace_inventory, and drop_inventory — the operation field picks which behaviour you get.

Type ID: apoli:inventory_action

ALIASES: the three legacy ids still work and select the matching operation automatically: apoli:modify_inventoryoperation: modify, apoli:replace_inventoryoperation: replace, apoli:drop_inventoryoperation: drop. (Both the apoli: and origins: namespaces resolve.) Data packs written for either era load unchanged.

Operations

operationPer-slot behaviourEmpty slots
modify (default)Runs item_action on the stack.skipped
replaceSwaps the stack for stack, then runs item_action (if any) on the replacement.included
dropDrops the stack into the world, then runs item_action (if any) on the dropped stack first.skipped

replace deliberately visits empty slots, so it can put an item into an empty slot — that is how you keep an item pinned in the offhand. It also means a replace with no slot/slots and no item_condition fills the entity’s whole inventory with stack. Always scope it.

Fields

FieldTypeDefaultDescription
operationString"modify"One of modify, replace, drop — see the table above.
inventory_typeInventory Type"inventory"Whether to walk the entity’s own inventory or a power’s inventory.
entity_actionEntity Action TypeoptionalExecuted on the entity once, before the slots are walked.
item_conditionItem Condition TypeoptionalIf specified, only items fulfilling this condition are affected.
slotItem SlotoptionalRestrict to a single slot.
slotsArray of Item SlotsoptionalRestrict to these slots. For a power inventory, use the container.N form (raw slot index).
powerIdentifieroptionalThe apoli:inventory to walk, when inventory_type is "power".
process_modeProcess Mode"stacks"How stacks are counted toward limit. Honoured by modify; replace/drop always act once per stack.
limitInteger0Max number of stacks (or items, in items mode) to affect. <= 0 means no limit.
item_actionItem Action TypeoptionalRequired-in-spirit for modify (without it modify is a no-op); optional post-step for replace/drop.
stackItem Stackoptionalreplace only — the replacement item.
merge_nbtBooleanfalsereplace only — merge the old item’s data onto the replacement. (1.20.1: NBT tag; 1.21.1: data components.)
throw_randomlyBooleanfalsedrop only — scatter items in random directions (death-drop style).
retain_ownershipBooleantruedrop only — keep the dropping entity as the item’s thrower.
amountIntegeroptionaldrop only — split this many off each matching stack instead of dropping the whole stack.

Examples

"entity_action": {
    "type": "apoli:inventory_action",
    "operation": "modify",
    "item_condition": {
        "type": "apoli:armor_value",
        "comparison": ">",
        "compare_to": 0
    },
    "item_action": {
        "type": "apoli:damage",
        "amount": 1,
        "ignore_unbreaking": true
    }
}

Slightly damages every armour-valued item in the entity’s inventory.

"entity_action": {
    "type": "apoli:inventory_action",
    "operation": "replace",
    "slot": "weapon.offhand",
    "stack": { "item": "minecraft:barrier" }
}

Replaces the entity’s offhand item with a Barrier — including when the offhand is empty. (Equivalent to the legacy apoli:replace_inventory.)

"entity_action": {
    "type": "apoli:drop_inventory",
    "slots": ["hotbar.0", "hotbar.1", "hotbar.2"]
}

A legacy-id example: drops the first three hotbar slots. Resolves to operation: drop.

"entity_action": {
    "type": "apoli:inventory_action",
    "operation": "modify",
    "inventory_type": "power",
    "power": "example:extra_inventory",
    "item_action": { "type": "apoli:consume" }
}

Walks the example:extra_inventory Inventory power’s stored container and consumes one of each item. Power-inventory slots are addressed with container.N (e.g. "slots": ["container.0", "container.1"]); this runs server-side only.