Minecraft:Commands/clear: Difference between revisions
More actions
imported>MinecraftBedrockPlayer7 mNo edit summary |
Remove broken links to missing pages |
||
| Line 4: | Line 4: | ||
* 2 {{only|java|short=1}} | * 2 {{only|java|short=1}} | ||
* 1 {{only|bedrock|short=1}} | * 1 {{only|bedrock|short=1}} | ||
|others= | |others=Cheat only{{only|bedrock|short=1}} | ||
}} | }} | ||
Clears [[Minecraft:item]]s from player [[Minecraft:inventory]], including items being dragged by the | Clears [[Minecraft:item]]s from player [[Minecraft:inventory]], including items being dragged by the player. Can also detect and query the amount of specified items. | ||
== Usage == | == Usage == | ||
| Line 47: | Line 47: | ||
{{Result table|The command is incomplete, or any argument is not specified correctly.|unparseable|unparseable}} | {{Result table|The command is incomplete, or any argument is not specified correctly.|unparseable|unparseable}} | ||
{{Result table|<code><targets></code> or <code>player: target</code> is not specified when the command's executor is not a player.|fail|fail}} | {{Result table|<code><targets></code> or <code>player: target</code> is not specified when the command's executor is not a player.|fail|fail}} | ||
{{Result table|<code>player: target</code> is a target selector that is not in | {{Result table|<code>player: target</code> is a target selector that is not in player type.|N/A|}} | ||
{{Result table|<code><targets></code> or <code>player: target</code> fails to resolve to one or more online players.|fail}} | {{Result table|<code><targets></code> or <code>player: target</code> fails to resolve to one or more online players.|fail}} | ||
{{Result table|There are no specified items in any player's inventory.}} | {{Result table|There are no specified items in any player's inventory.}} | ||
| Line 85: | Line 85: | ||
|{{HistoryLine||1.16|dev=20w07a|{{cmd|clear|link=none}} now clears the items in the inventory crafting grid.}} | |{{HistoryLine||1.16|dev=20w07a|{{cmd|clear|link=none}} now clears the items in the inventory crafting grid.}} | ||
|{{HistoryLine|||dev=20w22a|{{cmd|clear|link=none}} now works properly with the inventory crafting grid.}} | |{{HistoryLine|||dev=20w22a|{{cmd|clear|link=none}} now works properly with the inventory crafting grid.}} | ||
|{{HistoryLine||1.20.5|dev=24w09a|Updated the syntax. Now uses | |{{HistoryLine||1.20.5|dev=24w09a|Updated the syntax. Now uses item components instead of NBT tags.|Now target items must have every component that is the same as the specified key-value pair, or the default value of the component if it is not specified.}} | ||
}} | }} | ||
| Line 108: | Line 108: | ||
{{Navbox commands}} | {{Navbox commands}} | ||
de:Befehl/clear | |||
es:Comandos/clear | |||
fr:Commandes/clear | |||
ja:コマンド/clear | |||
ko:명령어/clear | |||
pt:Comandos/clear | |||
ru:Команды консоли/clear | |||
th:คำสั่ง/clear | |||
uk:Команди консолі/clear | |||
zh:命令/clear | |||
Latest revision as of 15:43, 9 April 2026
Clears Minecraft:items from player Minecraft:inventory, including items being dragged by the 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
- Specifies the player(s) whose items are cleared. If not specified, defaults to the player who executes the command.
- Template:Arg desc
- Specifies the item to be cleared. If not specified, all items are cleared.
- Template:Arg desc
- Specifies the data value of the item to be cleared. If not specified, or if
-1, all items that matchitemName: Itemare 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).
- Specifies the maximum number of items to be cleared. If not specified, or if
-1Template:Only, all items that matchitem, oritemName: Itemanddata: intare cleared. If0, 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 orclear @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 orclear @r minecraft:stone 0Template:Only
History
Java Edition
Bedrock Edition
See also
- Template:Cmd — can change or remove items in block or entity inventories
- Template:Cmd — give items to player
- Template:Cmd — can destroy item entities
- Template:CmdTemplate:Only — can manipulate items in block or entity inventories
- Template:CmdTemplate:Only — can replace items in block or entity inventories
External links
de:Befehl/clear es:Comandos/clear fr:Commandes/clear ja:コマンド/clear ko:명령어/clear pt:Comandos/clear ru:Команды консоли/clear th:คำสั่ง/clear uk:Команди консолі/clear zh:命令/clear