WanderingTraderSpawner 5.46.0
Spawns wandering traders (https://minecraft.wiki/w/Wandering_Trader#Spawning):
- every 24000 ticks (one day) an attempt is made, which goes ahead 25% of the time, then 50%, then 75% after failures (back to 25% after a trader spawns);
- a random player is picked, and only 1 attempt in 10 goes on from there;
- the trader spawns on the top block of a random column within 48 blocks of the bell nearest to the player (within 48 blocks), or of the player if there is none, with two trader llamas on the same block (Bedrock);
- it despawns after 2 or 3 days once nobody is within 24 blocks (see
WanderingTrader::setDespawnDelay()).
Overworld only. The countdown is not saved: it starts again when the world is loaded.
Constants
BELL_RANGE
php
public const BELL_RANGE = 48DELAY
php
public const DELAY = 24000DESPAWN_DELAYS
php
public const DESPAWN_DELAYS = [48000, 72000]MAX_CHANCE
php
public const MAX_CHANCE = 75MIN_CHANCE
php
public const MIN_CHANCE = 25SPAWN_RANGE
php
public const SPAWN_RANGE = 48TRADER_ROLL
php
public const TRADER_ROLL = 101 in this many attempts that went ahead spawn a trader.
Methods
__construct()
php
public function __construct(\pocketmine\world\World $world)getChance()
php
public function getChance() : intgetDelay()
php
public function getDelay() : intspawnNear()
php
public function spawnNear(\pocketmine\player\Player $player) : ?\pocketmine\entity\npc\WanderingTraderTries to spawn a trader and its llamas near the player (or the nearest bell within 48 blocks). Returns the trader, or null if no spot was found.
tick()
php
public function tick() : void