mojira.dev
MC-312753

/item modify uses the wrong evaluation order for `filtered` and `limit_slots`

When filtered and limit_slots are used together in a slot source definition, /item modify command applies the item filter before the slot limit. As a result, limit_slots limits the matching slots rather than limiting the slots to be checked by the filter.

Steps to reproduce the issue:

  1. Hold the following items in your hotbar

    • Slot 1: stone

    • Slot 2: red wool

    • Slot 3: blue wool

  2. Run the following command:

    item modify entity @s {type:filtered,item_filter:{items:"#wool"},slot_source:{type:limit_slots,limit:2,slot_source:{type:slot_range,slots:"container.*"}}} {type:set_count,count:1,add:true}

Expected result:

The slot_range source selects the slots matching container.*. The limit_slots source should then restrict this selection to the first two slots, which are hotbar slots 1 and 2. Finally, the filtered source should select only the slots containing items that match #wool from this limited selection.

Since slot 1 contains stone and slot 2 contains red wool, only the red wool in slot 2 should be modified. The blue wool in slot 3 should not be considered.

Actual result:

Modified 2 slot(s) on <username>

Both the red wool in slot 2 and the blue wool in slot 3 are modified. The item filter is applied before the slot limit, so the limit is applied to the filtered slots rather than to the original slot range.

Additional test case

To compare the behavior, run the following /execute if slots command:

execute if slots entity @s {type:filtered,item_filter:{items:"#wool"},slot_source:{type:limit_slots,limit:2,slot_source:{type:slot_range,slots:"container.*"}}}

It outputs "Test passed. Count: 1", indicating that one slot was selected. Strangely, this differs from the number of slots modified by /item modify, even though both commands use the same slot source. At least one of the two commands is wrong, and I suspect that /item modify is the one behaving incorrectly.

Comments 0

No comments.

Triton365

(Unassigned)

Confirmed

26.3, 26.4 Snapshot 4

Retrieved