it replaces items in inventorys/containers with more passion then normal /replaceitem
1. The Command Syntax
/scriptevent my:replaceitem <newItem> <slot> <target> <location> <amount|objective> [Properties]
2. Argument Guide
<newItem>: The item you want to give (e.g., minecraft:diamond).
<slot>: The slot index (0 is the first slot).
<target>: The script checks this slot first. It only replaces the item if the slot contains this target (use air if the slot must be empty).
<location>:
- Use
player to target your own inventory.
- Use
x,y,z (e.g., 10,64,10) to target a chest or barrel.
<amount|objective>:
- A number:
64
- A scoreboard name:
money (the script will give items equal to your score).
none: Defaults to 1.
[Properties]: Optional custom data separated by pipes (|).
- Format:
Name | Lore | Keep | Lock | Place | Destroy | Enchants
3. Usage Examples
A. Basic Swap (Empty Slot Only)
Place a torch in slot 0 of a chest at 10, 64, 10, but only if the slot is empty:
/scriptevent my:replaceitem minecraft:torch 0 air 10,64,10 1
B. Upgrade System (Targeted Replace)
Turn a player's wooden_sword in slot 0 into a stone_sword:
/scriptevent my:replaceitem minecraft:stone_sword 0 minecraft:wooden_sword player 1
C. Scoreboard Shop (Dynamic Amount)
Give the player a number of gold ingots equal to their "gold_balance" score:
/scriptevent my:replaceitem minecraft:gold_ingot 0 air player gold_balance
D. Advanced Item (Using Properties)
Replace an empty slot with a named, enchanted sword. Note the pipes | used to skip empty sections:
/scriptevent my:replaceitem minecraft:iron_sword 0 air player 1 "Hero Sword" | "Legacy Blade" | true | none | none | none | sharpness:3
4. Special Logic Features
- Stacking: If the slot already contains the
<newItem>, the script won't replace it; it will simply add the amount to the existing stack (up to 64).
- Coordinates: When using coordinates, don't use spaces between the numbers (use
10,64,10 not 10, 64, 10).
- Safety: If the
<target> doesn't match what is currently in the slot, the script does nothing. This prevents accidentally deleting a player's valuable items.