I'm creating a system so when a player dies, an XPOrb is dropped at that location with a special name then the player can choose to teleport to that named XPOrb if they choose.

This system is already working, but I would like to improve it. Right now the name of that XPOrb is "bob" but I would like to make it something better like a face such as: (ಥ﹏ಥ)

And I'm able to spawn an entity with that custom name, but I'm not able to teleport to it using:


Because Minecraft recognizes some of the characters as invalid they way that I have entered them. I would greatly prefer having this face instead of text for the XPOrb, so it would be a big help if someone knew how to format this properly.

The following commands are the entire list of commands for my system:

/scoreboard objectives add deaths deathCount

/testfor @a[score_deaths_min=1]

/execute @a[score_deaths_min=1] ~ ~ ~ /summon XPOrb ~0 ~0 ~0 {CustomName:bob,CustomNameVisible:1}

/scoreboard players set @a[score_deaths_min=1] deaths 0

Now if the player chooses to teleport to that orb the command is:

/execute @e[name=bob] ~ ~ ~ /tp @p @e[name=bob]

You can't put special characters in target selectors (it pretty much only supports names that players can have), but you can match them in NBT data.

/scoreboard players tag supports NBT data matching and adds a tag to an entity which can then be used in a selector. For example:

/scoreboard players tag @e[type=XPOrb] add DeathOrb {CustomName:"(ಥ﹏ಥ)"}

Which means: "add a 'DeathOrb' scoreboard tag to any XPOrbs with a CustomName of (ಥ﹏ಥ)"

Then you can select it like:

/execute @e[tag=DeathOrb] ~ ~ ~ /tp @p @e[tag=DeathOrb]

If you're always going to be summoning in the orbs, then you could also summon it with the DeathOrb tag, like so:

/execute @a[score_deaths_min=1] ~ ~ ~ /summon XPOrb ~ ~ ~ {CustomName:(ಥ﹏ಥ),CustomNameVisible:1,Tags:[DeathOrb]}

Then select it with @e[tag=DeathOrb] as above.

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.