Skip to content

SpawnRuleParser 5.46.0 ​

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

Reads Bedrock spawn rule files (behavior_pack/spawn_rules/.json). Mojang's files are "JSON with comments": they contain // and / */ comments and sometimes trailing commas, which are removed before decoding.

Methods ​

parse() ​

php
public static function parse(string $json) : array

Parses a spawn rule file. Returns its conditions (empty for mobs without natural spawning, e.g. cats or guardians, whose rule only declares the population type).

parseDescription() ​

php
public static function parseDescription(string $json) : array

Returns the population control ("monster", "animal"...) and identifier declared by a spawn rule file.

stripJsonComments() ​

php
public static function stripJsonComments(string $json) : string

Removes comments (outside strings) and trailing commas.

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