SpawnCondition 5.46.0
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
public const DEFAULT_MAX_DISTANCE = 44DEFAULT_MIN_DISTANCE
public const DEFAULT_MIN_DISTANCE = 24POPULATION_AMBIENT
public const POPULATION_AMBIENT = "ambient"POPULATION_ANIMAL
public const POPULATION_ANIMAL = "animal"POPULATION_CAT
public const POPULATION_CAT = "cat"POPULATION_MONSTER
public const POPULATION_MONSTER = "monster"POPULATION_PILLAGER
public const POPULATION_PILLAGER = "pillager"POPULATION_WATER_ANIMAL
public const POPULATION_WATER_ANIMAL = "water_animal"Properties
$adjustForWeather
public readonly bool $adjustForWeather$biomeFilter
public readonly mixed $biomeFilter$brightnessMax
public readonly ?int $brightnessMax$brightnessMin
public readonly ?int $brightnessMin$densitySurface
public readonly ?int $densitySurface$densityUnderground
public readonly ?int $densityUnderground$difficultyMax
public readonly int $difficultyMax$difficultyMin
public readonly int $difficultyMin$disallowBubble
public readonly bool $disallowBubble$distanceMax
public readonly ?int $distanceMax$distanceMin
public readonly ?int $distanceMin$heightMax
public readonly ?int $heightMax$heightMin
public readonly ?int $heightMin$herds
public readonly array $herds$identifier
public readonly string $identifier$lava
public readonly bool $lava$onBlocks
public readonly ?array $onBlocks$onSurface
public readonly bool $onSurface$permuteTypes
public readonly array $permuteTypes$population
public readonly string $population$preventedBlocks
public readonly array $preventedBlocks$spawnEvent
public readonly ?string $spawnEvent$timed
public readonly bool $timed$underground
public readonly bool $underground$underwater
public readonly bool $underwater$weight
public readonly int $weightMethods
__construct()
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()
public function getDensityLimit(bool $surface) : ?intDensity limit (maximum number of this mob in the area) for surface or underground spawns, or null if none.
matchesBiome()
public function matchesBiome(array $tags, bool $snowCovered) : boolmatchesPlacement()
public function matchesPlacement(\pocketmine\world\mobs\spawn\SpawnSpot $spot) : boolWhether 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()
public function matchesSpot(\pocketmine\world\mobs\spawn\SpawnSpot $spot, \pocketmine\world\mobs\spawn\SpawnContext $context) : boolChecks everything except the biome (see SpawnCondition::matchesBiome()) and the population caps.
pickEntityType()
public function pickEntityType() : stringPicks the entity type of one spawned mob ("minecraft:permute_type": e.g. 5% of zombies are zombie villagers).
pickHerd()
public function pickHerd() : \pocketmine\world\mobs\spawn\SpawnHerd