Name existing entity mc?

Ti
3

Can I somehow spawn an enderdragon called fred in minecraft? But the name fred should also be on the bar where the ender dragon is otherwise.

Be

If you go to the end you have to execute this command:

/ data merge entity @e [type = ender_dragon] {CustomNameVisible: 1b, CustomName: '{"text": "Fred"}'}

Don't forget that you have to have activated cheats in the world

Ti

I just tried the command, but it didn't work.

Be

Sorry, I forgot part

This is the new command:

/ data merge entity @e [type = ender_dragon, limit = 1] {CustomNameVisible: 1b, CustomName: '{"text": "Fred"}'}

If you only want the name in the bar, you can replace the 1b after CustomNameVisible with a 0b.