Commands/clear

Clears items from player inventory.


 * Syntax


 * Java Edition


 * Bedrock Edition


 * Arguments
 * targets (BE: player: target) (optional)
 * Must be a player name or a target selector. If not specified, defaults to the player who executed the command. Not optional in command blocks.
 * item (BE: itemName: Item) (optional)
 * Specifies the id of the item to be cleared. If not specified, all items in the player's inventory are cleared.
 * data: int (optional)
 * Specifies the data value of the item to be cleared. If not specified, or if, all items that match item are cleared, regardless of their data.
 * maxCount (BE: maxCount: int) (optional)
 * Specifies the maximum number of items to be cleared. If not specified, or if, all items that match item and data are cleared. If  , does not clear items, but returns successfully if there were items that could have been cleared (allowing detection of items rather than clearing of items).


 * Result
 * Fails if the arguments are not specified correctly, if player fails to resolve to one or more online players, or if no items are removed (except when maxCount is )
 * On success, removes the specified items from the player(s).


 * 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


 * See also
 * — can change or remove items in block or entity inventories
 * — give items to player
 * — can destroy item entities
 * — can replace items in block or entity inventories