VanillaSpawnRules 5.46.0
Mojang's official Bedrock spawn rules (behavior_pack/spawn_rules/*.json of https://github.com/Mojang/bedrock-samples), downloaded on the server owner's machine the first time they are needed.
The files are (c) Mojang AB and subject to the Minecraft EULA (the repository's LICENSE.md), so they are not shipped with PocketMine-MP: like the vanilla worldgen data (\pocketmine\world\generator\vanilla\VanillaDataFetcher), each server fetches them from Mojang's repository. The download is pinned to the commit of the release tag matching the supported Bedrock version and every file is checked against its SHA-256 below, so the rules cannot change under a running server. Update TAG, COMMIT and FILES together when moving to a new Bedrock version.
Until the files are available (first start, no network), SpawnRules::builtin() is used.
Constants
BASE_URL
public const BASE_URL = "https://raw.githubusercontent.com/Mojang/bedrock-samples/" . self::COMMIT . "/behavior_pack/spawn_rules/"COMMIT
public const COMMIT = "46ba6ea985fb5a92d79a9419198f10dda14c199d"DIRECTORY
public const DIRECTORY = "bedrock-spawn-rules"FILES
public const FILES = ["armadillo.json" => "8595a294e9b7b3ed3e55798e10ad0540088cee08e1e69f2c0f5f64f88e5841a9", "axolotl.json" => "9f694b70bd39f208ac167955af84a64c1ded20e46f319bc06ee9fafcd7e097ea", "bat.json" => "5f9fc9dfb85eaa16210b21985a8183f0f92c60f31fc544d1d23bbfa01fa9ee16", "bee.json" => "ae571145c0d7c06b16a9b5bb215e0c20c5e8007d6a7fd77487a16b80dd325ff3", "blaze.json" => "a57499b34eb23ec4ce1738d …File name => SHA-256 of the file at COMMIT.
TAG
public const TAG = "v1.26.50.4"Methods
fetch()
public static function fetch(string $dir) : voidDownloads the missing or damaged files into the directory. Runs on an async worker.
get()
public static function get(\pocketmine\Server $server, bool $fetchIfMissing = true) : ?\pocketmine\world\mobs\spawn\SpawnRulesReturns the vanilla rules, loading them from the cache directory if needed. If they are not there yet and $fetchIfMissing is set, starts downloading them in the background (once) and returns null.
getDirectory()
public static function getDirectory(string $dataPath) : stringisComplete()
public static function isComplete(string $dir) : boolReturns whether every file is in the directory (checksums are checked when loading).
loadFrom()
public static function loadFrom(string $dir) : \pocketmine\world\mobs\spawn\SpawnRulesReads and checks the files of a complete directory.
