Clears items from player inventory, including items being dragged by the player.
Syntax[]
- Java Edition
- Bedrock Edition
Arguments[]
JE: <targets>: entity
BE: player: target:
CommandSelector<Player>
JE: <item>:
item_predicate
BE: itemName: Item: enum
data: int: int
Specifies the data value of the item to be cleared. If not specified, or if -1, all items that match itemName: Item are cleared, regardless of their data. Values (bitwise AND 0xFFFF) that are invalid for the specified item id revert to 0.Must be a 32-bit integer number. Should be between -1 and 2,147,483,647 (inclusive, without commas).JE: <maxCount>: integer
BE: maxCount: int: int
Result[]
any | the arguments are not specified correctly | Unparseable | Unparseable |
<targets> or player: target is not specified when the command's executor is not a player. | Failed | Failed | |
player: target is not in player type | N/A | ||
<targets> or player: target fails to resolve to one or more online players | Failed | ||
there are no specified items in any player's inventory. | |||
If data: int is lower than -1. | N/A | ||
If maxCount: int is lower than -1. | |||
On success | Removes or detects the specified items. |
Output[]
any | Java Edition | On fail | 0 | 0 | 0 |
On success | 1 | 1 | the number of total items that are cleared or detected. | ||
Bedrock Edition | On fail | 0 | N/A | N/A | |
On success | the number of players who have the specified items. | N/A | N/A |
Note[]
Items in the inventory and items from container (chest, crafting table, etc.) dragging over the cursor can be cleared.
In Bedrock Edition, items dragging from the inventory can also be cleared, while in Java Edition only if not in creative mode can these be cleared.
In Java Edition, items in players' four crafting slots can also be cleared.
Examples[]
- To clear your entire inventory: clear
- To clear all items from Alice's inventory: clear Alice
- To clear all wool items from Alice's inventory: clear Alice minecraft:wool
- To clear all orange wool items from the inventory of all players: clear @a minecraft:wool 1[Bedrock Edition only] or clear @a minecraft:orange_wool[Java Edition only]
- To clear all golden swords with the "Sharpness I" enchantment from the nearest player
- clear @p minecraft:golden_sword{Enchantments:[{id:"minecraft:sharpness",lvl:1s}]}[Java Edition only]
- To test if a random player has stone in their inventory: clear @r minecraft:stone -1 0[Bedrock Edition only] or clear @r minecraft:stone 0[Java Edition only]
See also[]
- /data — can change or remove items in block or entity inventories
- /give — give items to player
- /kill — can destroy item entities
- /item[Java Edition only] — can manipulate items in block or entity inventories
- /replaceitem[Bedrock Edition only] — can replace items in block or entity inventories
History[]
Added /clear. |
Added item argument to /clear. |
Added data argument to /clear. |
/clear now clears the offhand slot. |
The syntax of /clear has changed from /clear [<target>] [<item>] [<data>] [<count>] [<nbt>] to /clear [<target>] [<item>] [<count>]. |
/clear now clears the items in the inventory crafting grid. |
/clear now works properly with the inventory crafting grid. |
Added /clear. |
How do you quickly drop items in your inventory in Minecraft?
To do so, press the number on your keyboard corresponding to the stack of items you would like to drop to select them. Press "Ctrl" on your keyboard and simultaneously press "Q." This will drop the entire stack of items in front of you.
What is the fastest way to manage inventory in Minecraft?
Pressing shift and double clicking on a stack will move all of that item between the player's inventory and the block or hotbar. However, players need to ensure that they are already holding an item for this shortcut to work.
How do you delete certain amounts of items in Minecraft?
You can clear items from a player's inventory using the /clear command in Minecraft.
What is the command to clear inventory?
You can use the command /clear [targets] [item] [maxCount] , where: targets is optional. It is the name of the player (or a target selector) whose inventory you wish to clear.