I am attempting to use a command block to removed a named diamond sword from players inventory. The sword is PVP_Sword.

clear @p diamond_sword 1 276 {display:{Name:"PVP_Sword"}}

This is the command I thought would work, but it's returning the error that I do not have a diamond sword.

How can I make it remove the named sword instead of the basic one? Keep in mind I don't want to clear the whole inventory.

  • Try without the quotes. – Ealhad Jul 16 '15 at 7:51
  • [08:55:14] Player [Admin] ~Joe does not have 1 of diamond_sword. still getting the same error – Joemidnight Jul 16 '15 at 7:55
  • clear @p {display:{Name:"PVP_Sword"}}, I think. All the arguments are optionnal. – Ealhad Jul 16 '15 at 8:05
  • @Ealhad Optional arguments in Minecraft commands are positional. The game does not know what argument you provide unless it's at a specific position in the command. (this is also why you may not normally have spaces in your arguments) – MrLemon Jul 16 '15 at 9:04
  • @MrLemon clear @p diamond_sword -1 -1 {display:{Name:"PVP_Sword"}}, then ? – Ealhad Jul 16 '15 at 9:08

The syntax of the clear command is

clear [player] [item] [data] [maxCount] [dataTag]

There are 5 optional, positional arguments here. Your problem is not the data tag (dataTag) but the data value, which for historical reasons corresponds to the Damage tag of the item. So what your command is doing is trying to remove up to 276 diamond swords called PVP_sword with a damage value of 1, i.e. which were used for one hit.

In order to remove the sword regardless of damage/data, use a value of -1:

clear @p diamond_sword -1 -1 {display:{Name:"PVP_Sword"}}

Using -1 for the count as well removes all of them.

  • Tried plugging this into the command block and it is kicking out the error: [10:29:31] Removed 0 of diamond_sword from [Admin] ~Joe. – Joemidnight Jul 16 '15 at 9:30
  • You do have a diamond sword named PVP_Sword (with this exact spelling)? Just to make sure... If so, try without the quotes. – MrLemon Jul 16 '15 at 9:35
  • To make sure you have a valid item, I suggest using the same tag in a give command: give @p diamond_sword 1 0 {display:{Name:PVP_Sword}} – MrLemon Jul 16 '15 at 9:51
  • I just tested this and it works well for me on 1.8.7, with and without quotes. – MrLemon Jul 16 '15 at 9:53
  • So I tried this in single player and it worked for me. When try it on my server its not working. Must be some plug in issue so I'll have to do more research. Thanks so much for the help MrLemon! – Joemidnight Jul 17 '15 at 0:50

I don't know that much about that but you could get a name tag and name it diamond sword. I actually prefer naming everything in minecraft so i don't really know how i could help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.