Editing
MinecraftCommands
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== clear === {{/infobox |clear |op |1.4.2|12w37a }} Clears items from player inventory. ;Syntax : <code>clear [''player''] [''item''] [''data''] [''maxCount''] [''dataTag'']</code> ;Arguments : ''player'' (optional) :: Must be a player name or a [[#Target selectors|target selector]]. If not specified, defaults to the player who executed the command. Not optional in command blocks. : ''item'' (optional) :: Specifies the [[Data values|id]] of the item to be cleared. If not specified, all items in the player's inventory are cleared. : ''data'' (optional) :: Specifies the [[Data values|data value]] of the item to be cleared. If not specified, or if <code>-1</code>, all items that match ''item'' are cleared, regardless of their data. : ''maxCount'' (optional) :: Specifies the maximum number of items to be cleared. If not specified, or if <code>-1</code>, all items that match ''item'' and ''data'' are cleared. If <code>0</code>, 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). : ''dataTag'' (optional) :: Specifies the data tags of the item to be cleared (only items matching the specified data tags will be cleared β data tags not specified will not be considered). Must be a compound [[NBT tag]] (for example, <code>{display:{Name:Fred}}</code>). ;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 <code>0</code>) : On success, removes the specified items from the player(s). ;Examples : To clear your entire inventory: <code>clear</code> : To clear all items from Alice's inventory: <code>clear Alice</code> : To clear all wool items from Alice's inventory: <code>clear Alice minecraft:wool</code> : To clear all orange wool items from the inventory of all players: <code>clear @a minecraft:wool 1</code> : To clear all golden swords with the "Sharpness I" enchantment from the nearest player, regardless of their damage value: :: <code>clear @p minecraft:golden_sword -1 -1 {ench:[{id:16s,lvl:1s}]}</code> ;See also : {{cmd|blockdata}} β can change or remove items in block inventories : {{cmd|entitydata}} β can change or remove items in entity inventories : {{cmd|give}} β give items to player : {{cmd|kill}} β can destroy item entities : {{cmd|replaceitem}} β can replace items in block or entity inventories <!-- please retain double newline above for section differentiation -->
Summary:
Please note that all contributions to Hegemon Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Hegemon Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
Edit source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information