Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Commands/clear

From SAS Gaming Wiki

Template:Infobox command

Clears Minecraft:items from player Minecraft:inventory, including items being dragged by the Minecraft:player. Can also detect and query the amount of specified items.

Usage

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

Template:IN, items dragging from the inventory can also be cleared, while Template:In only if not in creative mode can these be cleared.

Template:IN, items in players' four crafting slots can also be cleared.

Syntax

  • Java Edition
clear [<targets>] [<item>] [<maxCount>]
  • Bedrock Edition
clear [player: target] [itemName: Item] [data: int] [maxCount: int]

Arguments

Template:Argument

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

Template:Argument

Specifies the item to be cleared. If not specified, all items are cleared.
Template:Arg desc

Template:Argument

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.
Template:Arg desc Should be between -1 and 2,147,483,647 (inclusive, without commas).

Template:Argument

Specifies the maximum number of items to be cleared. If not specified, or if -1Template:Only, all items that match item, or itemName: Item and data: int are cleared. If 0, instead of clearing of items, detects and queries the amount of specified items.
Template:Arg desc Template:IN, it should be between -1 and 2147483647 (inclusive).

Result

Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table

Output

Template:Output table Template:Output table Template:Output table Template:Output table Template:Output table Template:Output table

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:woolTemplate:Only
  • To clear all orange wool items from the inventory of all players: clear @a minecraft:wool 1Template:Only or clear @a minecraft:orange_wool
  • 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}]}Template:Only
  • To test if a random player has stone in their inventory: clear @r minecraft:stone 0 0Template:Only or clear @r minecraft:stone 0Template:Only

History

Java Edition

Template:HistoryTable

Bedrock Edition

Template:HistoryTable

See also

External links

Navigation

Template:Navbox commands

Minecraft:de:Befehl/clear Minecraft:es:Comandos/clear Minecraft:fr:Commandes/clear Minecraft:ja:コマンド/clear Minecraft:ko:명령어/clear Minecraft:pt:Comandos/clear Minecraft:ru:Команды консоли/clear Minecraft:th:คำสั่ง/clear Minecraft:uk:Команди консолі/clear Minecraft:zh:命令/clear