/replaceitem block <pos> <slot> <item> [<count>]/replaceitem entity <targets> <slot> <item> [<count>]| Argument | Type | What it means |
|---|---|---|
<pos> | block position | Three coordinates x y z. Use ~ for relative or ^ for local coordinates. |
<slot> | slot | An inventory slot such as weapon.mainhand or container.0. |
<item> | item | An item ID, optionally with components, e.g. diamond_sword[enchantments={sharpness:5}]. |
<count> | whole number 1 to 64 | A whole number such as 5 or -3. |
<targets> | target selector | A player name, a UUID or a target selector such as @p, @a, @e or @s. |
Measured from the game files of every Java release from 1.13 to 26.3.