Skip to content

SpawnCondition 5.46.0 ​

final class · pocketmine\world\mobs\spawn\SpawnCondition · source

One entry of the "conditions" list of a Bedrock spawn rule (behavior_pack/spawn_rules/<mob>.json): where, when and how a mob may spawn. A mob spawns if any of its conditions matches; each condition has its own weight and herd size.

Supported components: spawns_on_surface, spawns_underground, spawns_underwater, spawns_lava, brightness_filter (with adjust_for_weather), difficulty_filter, height_filter, distance_filter, density_limit, biome_filter, spawns_on_block_filter, spawns_on_block_prevented_filter, disallow_spawns_in_bubble, weight, herd, permute_type, spawn_event. Conditions with delay_filter, world_age_filter, mob_event_filter or player_in_village_filter (pillager patrols) are "timed": they are spawned by their own spawner, not by the cluster spawning around players.

Constants ​

DEFAULT_MAX_DISTANCE ​

php
public const DEFAULT_MAX_DISTANCE = 44

DEFAULT_MIN_DISTANCE ​

php
public const DEFAULT_MIN_DISTANCE = 24

POPULATION_AMBIENT ​

php
public const POPULATION_AMBIENT = "ambient"

POPULATION_ANIMAL ​

php
public const POPULATION_ANIMAL = "animal"

POPULATION_CAT ​

php
public const POPULATION_CAT = "cat"

POPULATION_MONSTER ​

php
public const POPULATION_MONSTER = "monster"

POPULATION_PILLAGER ​

php
public const POPULATION_PILLAGER = "pillager"

POPULATION_WATER_ANIMAL ​

php
public const POPULATION_WATER_ANIMAL = "water_animal"

Properties ​

$adjustForWeather ​

php
public readonly bool $adjustForWeather

$biomeFilter ​

php
public readonly mixed $biomeFilter

$brightnessMax ​

php
public readonly ?int $brightnessMax

$brightnessMin ​

php
public readonly ?int $brightnessMin

$densitySurface ​

php
public readonly ?int $densitySurface

$densityUnderground ​

php
public readonly ?int $densityUnderground

$difficultyMax ​

php
public readonly int $difficultyMax

$difficultyMin ​

php
public readonly int $difficultyMin

$disallowBubble ​

php
public readonly bool $disallowBubble

$distanceMax ​

php
public readonly ?int $distanceMax

$distanceMin ​

php
public readonly ?int $distanceMin

$heightMax ​

php
public readonly ?int $heightMax

$heightMin ​

php
public readonly ?int $heightMin

$herds ​

php
public readonly array $herds

$identifier ​

php
public readonly string $identifier

$lava ​

php
public readonly bool $lava

$onBlocks ​

php
public readonly ?array $onBlocks

$onSurface ​

php
public readonly bool $onSurface

$permuteTypes ​

php
public readonly array $permuteTypes

$population ​

php
public readonly string $population

$preventedBlocks ​

php
public readonly array $preventedBlocks

$spawnEvent ​

php
public readonly ?string $spawnEvent

$timed ​

php
public readonly bool $timed

$underground ​

php
public readonly bool $underground

$underwater ​

php
public readonly bool $underwater

$weight ​

php
public readonly int $weight

Methods ​

__construct() ​

php
public function __construct(string $identifier, string $population, bool $onSurface, bool $underground, bool $underwater, bool $lava, int $weight, array $herds = [], ?int $brightnessMin = null, ?int $brightnessMax = null, bool $adjustForWeather = false, int $difficultyMin = 0, int $difficultyMax = 3, ?int $heightMin = null, ?int $heightMax = null, ?int $distanceMin = null, ?int $distanceMax = null …

getDensityLimit() ​

php
public function getDensityLimit(bool $surface) : ?int

Density limit (maximum number of this mob in the area) for surface or underground spawns, or null if none.

matchesBiome() ​

php
public function matchesBiome(array $tags, bool $snowCovered) : bool

matchesPlacement() ​

php
public function matchesPlacement(\pocketmine\world\mobs\spawn\SpawnSpot $spot) : bool

Whether the rule allows a spot of this kind: in water only with spawns_underwater, above lava only with spawns_lava, then surface spots need spawns_on_surface and the others spawns_underground.

matchesSpot() ​

php
public function matchesSpot(\pocketmine\world\mobs\spawn\SpawnSpot $spot, \pocketmine\world\mobs\spawn\SpawnContext $context) : bool

Checks everything except the biome (see SpawnCondition::matchesBiome()) and the population caps.

pickEntityType() ​

php
public function pickEntityType() : string

Picks the entity type of one spawned mob ("minecraft:permute_type": e.g. 5% of zombies are zombie villagers).

pickHerd() ​

php
public function pickHerd() : \pocketmine\world\mobs\spawn\SpawnHerd

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