Commands/clear

Clears items from player inventory, including items being dragged by the player.

Syntax

 * Java Edition


 * Bedrock Edition

Arguments

 * Specifies the player(s) whose items are cleared. If not specified, defaults to the player who executes the command.
 * Specifies the player(s) whose items are cleared. If not specified, defaults to the player who executes the command.


 * Specifies the item to be cleared. If not specified, all items are cleared.
 * Specifies the item to be cleared. If not specified, all items are cleared.


 * Must be between -1 and 2,147,483,647 (inclusive, without the commas).
 * Specifies the data value of the item to be cleared. If not specified, or if, all items that match   are cleared, regardless of their data. Values that are invalid for the specified item id revert to 0.


 * $$, it must be between -1 and 2147483647 (inclusive).
 * Specifies the maximum number of items to be cleared. If not specified, or if, all items that match  , or   and   are cleared. If  , instead of clearing of items, detectes and queries the amount of specified items.

Note
Items in the the inventory and items from container (chest, crafting table, etc.) dragging over the cursor can be cleared. Items in players' crafting slots cannot be cleared.

$$,items dragging from the inventory can also be cleared, while $$ only if not in creative mode can these be cleared.

$$, if a player has more than one stack of item with specified ID and different data values (For example planks 0 and planks 1). When clearing with a specific, The command first quiries how many specified items in the inventory can be cleared, then ignores data values and clears the corresponding amount of items with specified ID in the inventory from the left side of the hot bar to the right and from bottom to top.

Examples

 * To clear your entire inventory:
 * To clear all items from Alice's inventory:
 * To clear all wool items from Alice's inventory:
 * To clear all orange wool items from the inventory of all players:  or
 * To clear all golden swords with the "Sharpness I" enchantment from the nearest player
 * To test if a random player has stone in his inventory:  or
 * To test if a random player has stone in his inventory:  or

History
Befehl/clear Comandos/clear Команды консоли/clear คำสั่ง/clear Komutlar/clear Команди консолі/clear 命令/clear