Minecraft: How can I test whether an entity exists?

la
2

I'm playing in version 1.15.2 and am currently working on a map where you should fight the ender dragon in the end. How can I check whether the Ender kite is present? And how can you get the life of the ender dragon displayed above (in a bar) (I think it's called the boss bar)?

Po

The ender dragon is actually always there, but you can also spawn it with a command. For the boss bar you have to get close enough to the boss, then it will appear automatically

gl

With this command you test whether there's an end dragon in the end:

/ execute in the_end if entity @e [type = ender_dragon]

you can execute this command in every dimension btw

With this command you can create the boss bar:

/ bossbar add name optionalJsonText

the boss bar can then still be adjusted

You can see how this works here: https://minecraft.fandom.com/de/wiki/Befehl/bossbar

Then you have to put the number of lives in the boss bar

To do this, you have to insert this command into a command block (repeat | essential | always active):

/ execute store result bossbar name value in the_end run data get entity @e [type = ender_dragon, sort = nearest, limit = 1] Health