Slot.hotbar: number: Replace a hotbar item (number between 0 and 8 to indicate the slot position in the hotbar) slot.inventory: number: Replace an inventory item (number between 0 and 26 to indicate the inventory position) slot.saddle: 0: Replace the saddle on a horse, mule or donkey: slot.weapon.mainhand: 0: Replace the weapon held in the main. Is it possible to test for the amount of a specific item in a players inventory in the latest snapshots? For example I need to see if a player has 2 arrows in his inventory so a separate command block stops giving them more.
- Minecraft Inventory Slot Numbers
- Minecraft Player Inventory Slot Numbers
- Minecraft Inventory Slot Numbers
A GUI is an in-game screen with which has interactive objects. It consists of text fields, images, buttons, slots etc.
GUI Properties
There are 5 properties:
- GUI Width: The width of your GUI (in pixels)
- GUI Height: The height of your GUI (in pixels)
- GUI Type: 2 options: With Slots or WIthout Slots. If you select With Slots, you will be able to create slots (Input and output slots) and inventories.
- Render background layer: Check this box if you want a backgound (Grey-White color). If not, uncheck the box.
- Bind GUI to block: If you want to make a Tile Entity, you have to choose the block with the option for inventory activated.
GUI Components
There are 6 components:
- Buttons: The buttons are objects with events. This event works like the normal events.
- Images: Just images from your PC.
- Text Label: Plain text that supports MCreator's default tags for some variables (both in-game and global MCreator's variables). The text can also be colored.
- Text Input: A section where the player can write any text and can be detected and used to execute events, example uses are like a custom command block or search function.
- Input Slot: Description below
- Output Slot: Description below
Slots and Inventory Components
To create a slot (input or output) you must first enable inventory, with the Inventory Option:
Slots Options
It has 2 buttons: Input and Output Slot:
- Input Slot: Choose it if you want to put items in there.
- Output Slot: Choose it if you want to put items with events, not by hand.
Input slot
- Belongs to: Select the inventory that you created earlier.
- Slot ID: It is the ID of this specific slot. It's necessary to don't have the same number more than one time.
- Custom Color: If you want to put a color in the slot, select the color. If not, skip clicking this button.
- Limit stack input: If you want to limit the type of item that the slot accepts (Like a redstone dust or a torch), select the desired item. If not, just ignore this option.
- Add Event: It's just self-explanatory.
Finally, just move the slot where you want it to be
Output Slot
- Belongs to: Select the inventory that you created earlier.
- Slot ID: It is the ID of this specific slot. It's necessary to don't have the same number more than one time.
- Custom Color: If you want to put a color in the slot, select the color. If not, skip clicking this button.
- Add Event: It's just self-explanatory.
Putting items in Output Slots
- Add an Event (In blocks, items, guns, slots, etc.)
- Select: Place items in GUI slot
- Write the ID of your Output slot (visible on the GUI, it's a number like 02)
- Write the name of the Inventory of your Output slot
- Select the item that you want to put in and select the amount.
Edit Options
These buttons will help you make a GUI:
- Move Component: Moves the components you select.
- Remove Component: Removes selected component.
- Remove Inventory: Removes selected inventory.
- Snap components on the grid: Toggles grid used to easily align components.
Restrictions | |
---|---|
First introduced | Java Edition 1.17 (20w46a) |
Manipulate items in the inventories of blocks (chest, furnaces, etc.) or entities (players or mobs).
Syntax[edit]
item ...
... block <pos> ...
or... entity <targets> ...
... <slot> ...
... copy block <pos> <slot> [<modifier>]
... copy entity <targets> <slot> [<modifier>]
... modify <modifier>
... replace <item> [<count>]
Arguments[edit]
<pos>
: block_pos
- Specifies the position of the block to be modified.
<targets>
: entity
- Specifies one or more entities to modify.
<slot>
: item_slot
- Specifies the inventory slot to be modified. Valid values depend on whether a block or an entity is being modified.
container.<slot_number>
where <slot_number> or <slotId: int> is replaced with a number specifying the slot.- Chests, dispensers, droppers, hoppers, and trapped chests are numbered 0 for the top-left slot and then increase first horizontally, then vertically (so, for example, a chest's top row slots are numbered 0 to 8 from left to right). Double chests and double trapped chests are treated as two single container blocks.
- A brewing stand's bottom slots are numbered 0 to 2 from left to right, its top slot is 3 and the fuel slot is 4.
- A furnace's slots are numbered 0 for the input slot, 1 for the fuel slot, and 2 for the output slot.
/data
.Slot | Slot Numbers | Restrictions |
---|---|---|
armor.chest | armor stands, mobs, and players only (though not all mobs will show or make use of the items) | |
armor.feet | ||
armor.head | ||
armor.legs | ||
weapon.mainhand | ||
weapon.offhand | ||
container.<slot_number> | 0–53 | players, item frames (slot 0), and minecarts only |
enderchest.<slot_number> | 0–26 | players only |
hotbar.<slot_number> | 0–8 | |
inventory.<slot_number> | 0–26 | |
horse.saddle | horses, donkeys, and mules; <item> must be a saddle or air to remove | |
horse.chest | donkeys/mules and llamas; <item> must be a chest or air to remove | |
horse.armor | horses; <item> must be a type of horse armor or air to remove | |
llamas; <item> must be a type of carpet or air to remove | ||
horse.<slot_number> | 0–2 | llamas with chests |
0–14 | donkeys/mules with chests | |
villager.<slot_number> | 0–7 | villagers and piglins only |
<item>
: item_stack
- Specifies the item to be placed in the block or entity's inventory slot.
<count>
: integer
- Specifies the number of items to be placed in the block or entity's inventory slot.
<modifier>
: item_modifier
- Specifies the item modifier to apply on the chosen item.
Result[edit]
Command | Trigger | Java Edition |
---|---|---|
any | the arguments are not specified correctly | Unparseable |
<count> exceeds the stack limit of the specified item | Failed | |
/item block ... | if the specified block is not a container | Failed |
if the specified block does not have the specified slot | ||
/item entity ... | if <targets> or target: target fails to resolve to one or more entities (named players must be online) | |
if none of the targets have the specified slot (for example, zombies don't have horse.armor ) | ||
if specified item cannot be place into the specified slot of any targeted entity(for example, place a stone into armor.chest of a player) | ||
any | On success | Replaces the items in the specified slot with the specified items (previous items in that slot are lost). |
Output[edit]
Command | Edition | Situation | Success Count | /execute store success ... | /execute store result ... |
---|---|---|---|---|---|
any | Java Edition | On fail | 0 | 0 | 0 |
/item block ... | On success | 1 | 1 | 1 | |
/item entity ... | On success | 1 | 1 | the number of entities whose items are successfully replaced |
Minecraft Inventory Slot Numbers
Examples[edit]
- To replace the items in the bottom-right slot of a single chest two block above with four spruce saplings:
item block ~ ~2 ~ container.26 replace minecraft:spruce_sapling 4
- To replace the items in the rightmost hotbar slot of the nearest player with four spruce saplings:
item entity @p hotbar.8 replace minecraft:spruce_sapling 4
- To replace the item in the offhand of the selected player with the item in their main hand:
item entity @s weapon.offhand copy entity @s weapon.mainhand
History[edit]
Upcoming Java Edition | |||||
---|---|---|---|---|---|
1.17 | 20w46a | Added /item , replacing /replaceitem |
See also[edit]
Minecraft Player Inventory Slot Numbers
/blockdata
— can also replace items in a container/entitydata
— can also replace items in a mob's inventory, or modify the drop chances of armor and weapons/give
— give items to players without specifying specific inventory slots or overwriting other items