Boss Fight

Script Description

When an Ender Dragon is killed in the end, a wither is spawned. Players cannot go back to the overworld without killing the wither as well.

Part 1: Creating The Event

First, we're going to create a new event which is called when an Ender Dragon is killed in the event. We'll be using the Entity Death Event for this.

on death:
    if victim is a ender dragon:

Part 2: Spawning The Wither

We're going to check if the killed dragon was in the end dimension, if it was, then we're going to set a global variable (witherspawned for the sake of this tutorial) to true. Now we're going to add an elseif statementto our previous if statement where we confirmed that the killed entity was a dragon. This time, in the else if statement, we're going to confirm that the killed entity is a wither. Next, let's check if the variable we created earlier (witherspawned) is true, and if it is, then delete it. And that's it for this part.

on death:
    if victim is a ender dragon:
        attacker's world = "world_the_end"
        spawn a wither at location of victim
        set {witherspawned} to true
    else if victim is a wither:
        attacker's world = "world_the_end"
        delete {witherspawned}

Part 3: Disabling Portal Teleportation

Now finally, we're going to add a new event which is called when a player enters the end dimension. We're going to do this with the Player Portal Event. Now, we're going to add an if statement to confirm that the player was previously in the end world, to do this we're going add an if statement to confirm that event-world is world_the_end. Finally, if our variable (witherspawned) is true, then cancel the event.

on player portal:
    if player's world = "world_the_end":
        {witherspawned} is true
        cancel event

Last updated