4

How can I test for mob who has a name with two words? For example villager named Grumpy Bill. For example I want to kill this villager.

This command

/kill @e[name=Bill]

would work just fine but when I try

/kill @e[name=Grumpy Bill]

it says "The entity UUID provided is in an invalid format"

What is the proper command for this action?

  • 4
    Have you tried /kill @e[name="Grumpy Bill"]? – Bob R. Shake Feb 9 '15 at 17:06
  • 1
    @BobR.Shake That doesn't work. – SirBenet Feb 9 '15 at 17:22
  • This is out of curiosity (I've never used Minecraft commands) - a lot of command structures use backslash \ To 'escape' the special meaning of symbols and use the literal meaning. In this case, whitespace represents the end of one 'object' or command and the start of another. If we escape the space to use the literal space character, would it work? I.e. /kill @e[name=Grumpy\ Bill] – Robotnik Feb 10 '15 at 7:29
10

With a selector you cannot test for a name with spaces, symbols, or most things that a name cannot normally have; it is marked on the bug tracker as "Won't Fix".

You can however select them by NBT data with their "CustomName" tag. Like this:

/testfor @e {CustomName:"Grumpy Bill"}

If you want to do something other than test for them existing, you'll need to create a dummy scoreboard objective, objectiveName, and then run something like this:

/scoreboard players set @e objectiveName 1 {CustomName:"Grumpy Bill"}

And then:

/kill @e[score_objectiveName_min=1]
0

Use the NBT Tag "CustomName", and to make it for /kill use: /scoreboard objectives add KillSpacedName dummy KillSpacedName /scoreboard players set @e KillSpacedName 1 {CustomName:Grumpy Bill} /kill @e[score_KillSpacedName_min=1]

  • This is identical to the accepted answer and adds nothing beyond what was there already. Contrary to the existing answers, it's not formatted, and doesn't describe what it does. – MrLemon Aug 23 '15 at 14:29
  • Exactly what @MrLemon said. Duplicate answers are frowned upon here and may be subject to deletion. – nine Aug 23 '15 at 14:48
  • Sorry, I'm new to this site. Delete it. – TheGamerGhast Aug 23 '15 at 14:49
  • @TheGamerGhast hope we didn't alienate you. This site is quite a bit stricter than your typical forum (which this isn't!). Check out the help center and the tour for new users. – MrLemon Aug 23 '15 at 15:16
-1

I've learned that you cannot have a space between the words of the name, such as Do not touch.

Instead you will need to fill those spaces with underscores. For example, Do_not_touch.

-1

In commands, you can't have spaces. Use the underscore. Something like

Grumpy_Bill

  • 2
    This is the same answer already left by someone else. New answers should contribute new or helpful information – Son of a Sailor Aug 5 '15 at 18:16

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.