DragonFight 5.46.0
The ender dragon fight of each End world (vanilla keeps it in the "DragonFight" record of the End's level data; PocketMine keeps one table for all worlds in dragon_fights.json in the server data folder).
The fight starts the first time a player arrives in the End: the empty exit portal is built at 0,0, End crystals are placed on the obsidian pillars and the dragon appears above the island. When the dragon dies in the End, the exit portal is activated (its portal blocks lead back to the Overworld) and the dragon egg appears on the first kill only, and one of the 20 End gateways around the island appears (see EndGateways). Dragons killed after the first give 500 XP instead of 12000.
Once the dragon is dead, placing an End crystal on each of the four sides of the exit portal (on the bedrock rim, three blocks from the centre) starts the respawn sequence (see DragonRespawnStage): the exit portal closes, the crystals' beams rebuild the pillars one by one with new crystals, then the four crystals explode and a new dragon appears. Destroying one of the four crystals aborts it (the portal opens again). The sequence is saved and continues after a restart.
Constants
DRAGON_SPAWN_Y
public const DRAGON_SPAWN_Y = 128EGG_KILLS
public const EGG_KILLS = 1Number of kills that leave a dragon egg (only the first dragon drops one).
PILLAR_TICKS
public const PILLAR_TICKS = 40Ticks spent on each pillar while summoning them (the beam aims at it, then it is rebuilt).
RESPAWN_CRYSTAL_DISTANCE
public const RESPAWN_CRYSTAL_DISTANCE = 3Distance of the respawn crystals from the centre of the exit portal (one on each side, on the bedrock rim).
Methods
__construct()
public function __construct(?string $path = null)abortRespawn()
public function abortRespawn(\pocketmine\world\World $world) : voidStops the respawn sequence of this world (vanilla: when one of the four crystals is destroyed): the exit portal opens again and the rebuilt pillars' crystals become vulnerable.
getExitPortalOrigin()
public function getExitPortalOrigin(\pocketmine\world\World $world) : \pocketmine\math\Vector3Returns the centre of the exit portal's portal layer, deciding it (on the island surface at 0,0) if it was never built.
getKills()
public function getKills(\pocketmine\world\World $world) : intNumber of dragons killed in this world.
getPillars()
public static function getPillars(\pocketmine\world\World $world) : arrayThe obsidian pillars of an End world (see DragonFight::getSpikes()).
getRespawnStage()
public function getRespawnStage(\pocketmine\world\World $world) : ?\pocketmine\world\dimension\DragonRespawnStageReturns the stage of the dragon respawn sequence running in this world, or null when there is none.
getSpikes()
public static function getSpikes(\pocketmine\world\World $world) : arrayThe obsidian spikes of an End world: vanilla's spikes for the seed when the world is generated by the vanilla End generator, otherwise the pillars of the built-in End generator (without iron bar cages).
isDragonKilled()
public function isDragonKilled(\pocketmine\world\World $world) : boolWhether the dragon of this world was killed and not respawned yet (it can be respawned with End crystals).
isStarted()
public function isStarted(\pocketmine\world\World $world) : boolonCrystalDestroyed()
public function onCrystalDestroyed(\pocketmine\entity\object\EndCrystal $crystal) : voidCalled when an End crystal is destroyed: destroying one of the crystals of the respawn sequence aborts it.
onDragonKilled()
public function onDragonKilled(\pocketmine\world\World $world) : voidCalled when a dragon dies in an End world: activates the exit portal, places the egg on the first kills and counts the kill.
onPlayerArrived()
public function onPlayerArrived(\pocketmine\world\World $world) : voidCalled when a player arrives in an End world: starts the fight the first time.
placeCrystals()
public static function placeCrystals(\pocketmine\world\World $world) : arrayPlaces an End crystal on top of each obsidian pillar (on its bedrock block), like vanilla's spike feature.
rebuildSpike()
public static function rebuildSpike(\pocketmine\world\World $world, \pocketmine\world\generator\vanilla\EndSpike $spike, ?\pocketmine\math\Vector3 $beamTarget) : ?\pocketmine\entity\object\EndCrystalRebuilds a pillar during the respawn sequence (vanilla SUMMONING_PILLARS): the blocks within 10 of its top are removed, an explosion goes off there, and the spike is placed again like the world generator does (obsidian column, iron bar cage on the guarded ones, bedrock and fire on top) with an invulnerable crystal aiming at the given target. Returns the new crystal, or null if the spike's chunks are not generated.
spawnNextGateway()
public function spawnNextGateway(\pocketmine\world\World $world) : ?\pocketmine\math\Vector3Spawns the next of the 20 End gateways around the main island (vanilla: one per dragon kill, see EndGateways). Returns its position, or null when all 20 are there.
start()
public function start(\pocketmine\world\World $world) : \pocketmine\entity\boss\EnderDragonSets up the fight in a loaded End: empty exit portal, crystals on the pillars, and the dragon.
tickRespawn()
public function tickRespawn(\pocketmine\world\World $world) : voidRuns one tick of the respawn sequence of this world, if there is one. It waits while the exit portal's chunk is not loaded (vanilla only runs it while players are around).
tryRespawn()
public function tryRespawn(\pocketmine\world\World $world) : boolStarts the dragon respawn sequence if the dragon of this End world is dead and there is an End crystal on each of the four sides of the exit portal (vanilla tryRespawn(), called when a crystal is placed). Returns whether it started.
