Skip to content

Raid 5.46.0 ​

final class · pocketmine\world\raid\Raid · source

A raid on a village (Bedrock rules, see https://minecraft.wiki/w/Raid):

  • it starts when the Raid Omen of a player in the village runs out; the red "Raid" bar charges for 15 seconds while the village bells ring, then the first wave comes, and 15 seconds pass between waves;
  • each wave (RaidWaves) spawns at once on a free spot at the edge of the village (up to 64 blocks from its centre horizontally, 16 vertically) with the raid horn; illagers, witches and ravagers already within 96 blocks join it; raiders walk to the village centre and attack villagers, players and iron golems;
  • the bar shows the raiders left in the wave (and their number once fewer than 3 remain), for players within 64 blocks horizontally and 44 vertically of the centre;
  • when the last wave is defeated, players who killed a raider get Hero of the Village (40 minutes) and villagers celebrate; when the village stops being a village (beds gone, or all its villagers dead) the raiders win and celebrate; after 48000 ticks (or when the difficulty is set to peaceful) the raid expires.

Waves only progress while a player is near the village (the raiders would be in unloaded chunks otherwise); the expiry time keeps running.

Constants ​

BAR_RANGE_HORIZONTAL ​

php
public const BAR_RANGE_HORIZONTAL = 64.0

BAR_RANGE_VERTICAL ​

php
public const BAR_RANGE_VERTICAL = 44.0

END_TICKS ​

php
public const END_TICKS = 600

HERO_DURATION ​

php
public const HERO_DURATION = 48000

HORN_INTERVAL ​

php
public const HORN_INTERVAL = 600

JOIN_RANGE ​

php
public const JOIN_RANGE = 96.0

LEAVE_RANGE ​

php
public const LEAVE_RANGE = 112.0

MAX_TICKS ​

php
public const MAX_TICKS = 48000

PREPARE_TICKS ​

php
public const PREPARE_TICKS = 300

SPAWN_RANGE_HORIZONTAL ​

php
public const SPAWN_RANGE_HORIZONTAL = 64

SPAWN_RANGE_VERTICAL ​

php
public const SPAWN_RANGE_VERTICAL = 16

Methods ​

__construct() ​

php
public function __construct(int $id, \pocketmine\math\Vector3 $center, int $omenLevel, int $difficulty, bool $hadVillagers)

addHero() ​

php
public function addHero(\pocketmine\player\Player $player) : void

checkVillage() ​

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

Returns whether the village still stands (and remembers its beds for the villagers to hide in).

countRaiders() ​

php
public function countRaiders(\pocketmine\world\World $world, bool $leaveFar = false) : int

Counts the living raiders of this raid in the world; with $leaveFar, raiders too far from the village (or in another world) leave the raid.

end() ​

php
public function end(\pocketmine\world\World $world, \pocketmine\world\raid\RaidStatus $status) : void

Ends the raid: shows the result on the bar, rewards the heroes or makes the raiders celebrate.

findSpawnSpot() ​

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

Finds where a wave spawns: a free spot on any block but leaves or scaffolding, at the edge of the village if possible, at most 64 blocks away horizontally and 16 vertically.

finish() ​

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

Called when the result has been shown long enough, or when the raid is dropped.

fromArray() ​

php
public static function fromArray(array $data) : ?self

getBeds() ​

php
public function getBeds() : array

getBossBar() ​

php
public function getBossBar() : \pocketmine\world\raid\RaidBossBar

getCenter() ​

php
public function getCenter() : \pocketmine\math\Vector3

getCooldown() ​

php
public function getCooldown() : int

Ticks before the next wave, or -1 while a wave is being fought.

getHeroes() ​

php
public function getHeroes() : array

getId() ​

php
public function getId() : int

getMountedRiders() ​

php
public function getMountedRiders() : int

getOmenLevel() ​

php
public function getOmenLevel() : int

getRaidersAlive() ​

php
public function getRaidersAlive() : int

getStatus() ​

php
public function getStatus() : \pocketmine\world\raid\RaidStatus

getTicks() ​

php
public function getTicks() : int

getTotalWaves() ​

php
public function getTotalWaves() : int

getWave() ​

php
public function getWave() : int

Number of waves spawned so far.

isInBarRange() ​

php
public function isInBarRange(\pocketmine\math\Vector3 $pos) : bool

Whether the position is close enough to the centre to see the raid bar.

isOngoing() ​

php
public function isOngoing() : bool

onRaiderDeath() ​

php
public function onRaiderDeath(?\pocketmine\player\Player $killer) : void

Called when a raider of this raid dies.

setBeds() ​

php
public function setBeds(array $beds) : void

setCooldown() ​

php
public function setCooldown(int $ticks) : void

Changes the wait before the next wave (only between waves).

spawnNextWave() ​

php
public function spawnNextWave(\pocketmine\world\World $world, array $players) : void

Spawns the next wave. If no spawn spot is found, the wave is skipped (Bedrock).

tick() ​

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

Called every tick by the RaidManager. Returns false when the raid is over and can be forgotten.

toArray() ​

php
public function toArray() : array

tryMountRider() ​

php
public static function tryMountRider(\pocketmine\entity\monster\Ravager $ravager, \pocketmine\entity\Living $rider) : bool

Hook for ravager riders (a pillager or an evoker on some ravagers of waves 5 and 7). Returns whether the rider was mounted; if not, it raids on foot next to the ravager.

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