change_item
Very powerful action, allows you to add, change and remove items from players, entities and different storages.
Last updated
Very powerful action, allows you to add, change and remove items from players, entities and different storages.
Last updated
Modifies items in players, entities and storages (chest, barrels etc) inventories, allows you to give, exchange, remove and customize different items in different ways, has very rich and useful functionality.
- 'change_item: target:<entity_uuid|player_name|world,x,y,z>;<option>:<value>;<optionN>:<valueN>'
target:<entity_uuid | player_name | world,x,y,z> โ the UUID of the target entity, the nickname of the target player or the target storage in which the items will be changed; (MANDATORY)
source:<entity_uuid | player_name | world,x,y,z> โ the source inventory from which the items will be taken; (OPTIONAL)
source_slot:<slot> โ the slot in the source inventory (only in case of specifying the "source" option); (SEMI-MANDATORY)
switch:<true | false> โ whether to swap the items between the source and target inventories or just move the item from the source to the target (only in case of specifying the "source" option, can be skipped); (SEMI-OPTIONAL)
action:<action> โ may be set, remove or reset, it affects the "item options" (see below), that is, whether the options will be set, removed or reset (can be skipped in case of not specifying any "item options", and specifying for example only the "source" option); (SEMI-MANDATORY)
slot:<slot> | material:<material> โ the slot or the material in the target inventory to change, can be many via "," (should be at least one of them); (MANDATORY)
counts:<counts> โ indicates how many items will be changed; (OPTIONAL)
order:<order> โ to specify the order of the "source", "slot" and "material" parameters execution through the comma and many other properties described below, in general this option means in which order, which options and how many times will be executed, that is, you can exclude some options, duplicate them several times etc, also you can configure the different options as you want; (OPTIONAL)
overrideOrderCountsOverGlobalCounts:<true | false> โ if you want that "order" option local "counts" properties, if specified, to take precedence over the global "counts" option. (OPTIONAL)
order:slot,material,source (for example) โ execute first all modifiers under the "slot" option, then under the "material", and then under the "source" (it can be useful for example if you need firstly to change the items and then swap them with source, and not firstly swap and then change, of course in case of enabled "switch" option);
order:slot,source (for example) โ execute first all modifiers under the "slot" option, then under the "source", and skip the "material" at all.
order:slot{<property1>=<value1>`<propertyN>=<valueN>},material{<property1>=<value1>`<propertyN>=<valueN>},source{<property1>=<value1>`<propertyN>=<valueN>} (for example)
order:slot,material,source(material`slot) (for example) โ first change all materials to the source item, then all slots;
order:slot,material,source(material) (for example) โ just change all materials to the source item, and skip the "slot" at all;
useSourceMaterialIfFurther
material
true / false
If "material" stands after "source" in order, whether to take the new material that came from source or not.
applyOpenedToSourceMaterial
material
ifExists / anyway
If the useSourceMaterialIfFurther property is specified to "true", whether to apply this material also to the player's open inventory or not. "ifExists" will consider the current value of the "material" option and will be applied only if "OPENED|<material>" exists there, and "anyway" will be applied in any way.
materialAdd | materialOverride
slotAdd | slotOverride
material and slot
The list through the "~"
It will add or override (you can and override and add) the current materials or slots from the "material" or "slot" option. You can use "CURSOR", "OPENED" etc as well.
counts
material, slot, source
Any number above 0
You can specify how many items will be changed for the each sub-option.
material.counts | slot.counts
source
Any number above 0
You can specify the personal counts for "material" and "slot" in "source", and not only general "counts" in the source.
useNewMaterialIfFurther
source
true / false
The same as useSourceMaterialIfFurther property, but vice versa, if "source" stands after the "material" or "slot" in order, whether to take the new material to which item changed or not (note that by changing the source only by slots and not materials, you will not change anything by this option).
applyOpenedToNewMaterial
source
ifExists / anyway
The same as applyOpenedToSourceMaterial property, but vice versa, if the useNewMaterialIfFurther property is specified to "true", whether to apply this material also to the player's open inventory or not. "ifExists" will consider the current value of the "material" option and will be applied only if "OPENED|<material>" exists there, and "anyway" will be applied in any way.
overridePartialCountsOverGeneralCounts
source
true / false
Whether to override material.counts and slot.counts properties with default source counts or not.
newMaterial:<new_material> โ the new material of the item (can change items from the air and to the air as well); (OPTIONAL)
durability:<durability> โ the new durability of the item; (OPTIONAL)
name:<name> โ the new name of the item; (OPTIONAL)
lore:<lore> โ the new lore of the item (in case of "set" action "line1|line2|line3" or in case of "remove" action just numbers separated by commas, like "1,4,7"); (OPTIONAL)
enchantments:<enchantments> โ the new enchantments of the item in format "ENCHANTMENT_1=LEVEL,ENCHANTMENT_2=LEVEL" (note that the names of enchantments may be different on different versions); (OPTIONAL)
flags:<flags> โ the new flags of the item, see the available flags (note that the names and presence of flags may be different on different versions); (OPTIONAL)
amount:<amount> โ the new amout of the item; (OPTIONAL)
customModelData:<customModelData> โ the new custom model data of the item; (OPTIONAL)
dataContainer:<name>,<id>,<type>,<value> โ the new PersistentDataContainer of the item (the "type" and "value" should be used only in case of "set" action, the "value" should be wrapped in [ ] in case of array types in "type"), see the available types for "type" (but not all types are supported yet), for example, the ExecutableItems plugin adds a PersistentDataContainer with <name> โexecutableitemsโ, <id> โei-idโ and <type> โSTRINGโ to its items, this is what you specify when you create the item in the /ei create <id> command, carefully use only appropriate values for appropriate types, for example, integer - integer, string - string. Name and id of the dataContainer should not contain any capital letters!; (OPTIONAL)
maxStack:<maxStack> โ the new maximum stack of the item, should be above 1 and below 99, but values above 64 will not be displayed visually, only when changing the <amount> option. (OPTIONAL)
The <slot>, <source_slot> and <material> options support "OPENED|<option>" to obtain the items in the playerโs open inventory. Also the <slot> and <material> options support specifying many objects via "," (<source_slot> does not support). The <slot> and <source_slot> option also support "CURSOR" slot to obtain the item at the player's cursor and different named slots such as "HAND", see all possible values .
Even in case of <action> option "remove", you need to specify the values of the options you want to remove, these values can be any, but not empty (for example just "name:1").
If something is not working as you intended, most likely you are just doing something wrong!
The amount of the options is not limited, you can specify as many you want combining one options with another.
Can be useful in any cases where you need to modify the storages, entities or player inventories and items in them in any ways, for example in some technical systems or mini-games.
- 'change_item: target:%player%;slot:HEAD,CHEST,LEGS,FEET;action:set;durability:150' # Just change the items durability on the armor slots of the current player
- 'change_item: target:%player%;material:OPENED|STONE;action:set;newMaterial:COBBLESTONE;counts:10' # Change all stones to the cobblestones in the open inventory of the current player and limit it to the 10 changings
- 'change_item: target:%player%;source:d3cb4dcc-95c1-4214-8296-db81b7a6eb2a;source_slot:HAND;material:DIAMOND_PICKAXE,NETHERITE_AXE;slot:10,15,HAND;action:set;newMaterial:DIAMOND_SWORD;enchantments:DAMAGE_ALL=1;switch:true;order:source(material`slot),material{useSourceMaterialIfFurther=true}' # First swap all diamond pickaxes and netherite axes in the current player inventory with some item from the source slot "HAND" from some entity, then swap "10", "15" and "HAND" slots in the current player inventory with the "HAND" slot from the source entity (there already will be netherite axe as last material), and then apply all item modifiers ("newMaterial" and "enchantments") to the material from the source, that is, netherite axes