Skip to content

DragonFight 5.46.0 ​

final class · pocketmine\world\dimension\DragonFight · source

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 ​

php
public const DRAGON_SPAWN_Y = 128

EGG_KILLS ​

php
public const EGG_KILLS = 1

Number of kills that leave a dragon egg (only the first dragon drops one).

PILLAR_TICKS ​

php
public const PILLAR_TICKS = 40

Ticks spent on each pillar while summoning them (the beam aims at it, then it is rebuilt).

RESPAWN_CRYSTAL_DISTANCE ​

php
public const RESPAWN_CRYSTAL_DISTANCE = 3

Distance of the respawn crystals from the centre of the exit portal (one on each side, on the bedrock rim).

Methods ​

__construct() ​

php
public function __construct(?string $path = null)

abortRespawn() ​

php
public function abortRespawn(\pocketmine\world\World $world) : void

Stops 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() ​

php
public function getExitPortalOrigin(\pocketmine\world\World $world) : \pocketmine\math\Vector3

Returns the centre of the exit portal's portal layer, deciding it (on the island surface at 0,0) if it was never built.

getKills() ​

php
public function getKills(\pocketmine\world\World $world) : int

Number of dragons killed in this world.

getPillars() ​

php
public static function getPillars(\pocketmine\world\World $world) : array

The obsidian pillars of an End world (see DragonFight::getSpikes()).

getRespawnStage() ​

php
public function getRespawnStage(\pocketmine\world\World $world) : ?\pocketmine\world\dimension\DragonRespawnStage

Returns the stage of the dragon respawn sequence running in this world, or null when there is none.

getSpikes() ​

php
public static function getSpikes(\pocketmine\world\World $world) : array

The 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() ​

php
public function isDragonKilled(\pocketmine\world\World $world) : bool

Whether the dragon of this world was killed and not respawned yet (it can be respawned with End crystals).

isStarted() ​

php
public function isStarted(\pocketmine\world\World $world) : bool

onCrystalDestroyed() ​

php
public function onCrystalDestroyed(\pocketmine\entity\object\EndCrystal $crystal) : void

Called when an End crystal is destroyed: destroying one of the crystals of the respawn sequence aborts it.

onDragonKilled() ​

php
public function onDragonKilled(\pocketmine\world\World $world) : void

Called when a dragon dies in an End world: activates the exit portal, places the egg on the first kills and counts the kill.

onPlayerArrived() ​

php
public function onPlayerArrived(\pocketmine\world\World $world) : void

Called when a player arrives in an End world: starts the fight the first time.

placeCrystals() ​

php
public static function placeCrystals(\pocketmine\world\World $world) : array

Places an End crystal on top of each obsidian pillar (on its bedrock block), like vanilla's spike feature.

rebuildSpike() ​

php
public static function rebuildSpike(\pocketmine\world\World $world, \pocketmine\world\generator\vanilla\EndSpike $spike, ?\pocketmine\math\Vector3 $beamTarget) : ?\pocketmine\entity\object\EndCrystal

Rebuilds 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() ​

php
public function spawnNextGateway(\pocketmine\world\World $world) : ?\pocketmine\math\Vector3

Spawns 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() ​

php
public function start(\pocketmine\world\World $world) : \pocketmine\entity\boss\EnderDragon

Sets up the fight in a loaded End: empty exit portal, crystals on the pillars, and the dragon.

tickRespawn() ​

php
public function tickRespawn(\pocketmine\world\World $world) : void

Runs 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() ​

php
public function tryRespawn(\pocketmine\world\World $world) : bool

Starts 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.

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.