Skip to content

VanillaNativeBackend 5.46.0 ​

final class · pocketmine\world\generator\vanilla\native\VanillaNativeBackend · source

The vanillagen helper process: native terrain core of the "vanilla" generator (Go program in native/vanillagen).

The server's main thread starts one process (when the first vanilla world is loaded) and publishes its loopback endpoint in the process environment; every generator instance, in every async worker thread, opens its own connection to it (see NativeTerrainFiller). The helper exits when its stdin pipe is closed, so it never outlives the server. If it cannot be started, nothing is published and the generator uses the PHP code.

Constants ​

ALGORITHM_VERSION ​

php
public const ALGORITHM_VERSION = 4

Version of the generated terrain. Must match algorithmVersion in native/vanillagen/protocol.go: bump both whenever the chunks produced by the PHP stages (terrain, material rules, carvers), and so by the native ones, change.

ENV_ENDPOINT ​

php
public const ENV_ENDPOINT = "PM_VANILLAGEN_ENDPOINT"

ENV_TOKEN ​

php
public const ENV_TOKEN = "PM_VANILLAGEN_TOKEN"

PROTOCOL_VERSION ​

php
public const PROTOCOL_VERSION = 6

Wire protocol version (must match native/vanillagen/protocol.go).

Methods ​

binaryName() ​

php
public static function binaryName() : string

endpoint() ​

php
public static function endpoint() : ?array

Endpoint published by the main thread, if the helper is running.

getInstance() ​

php
public static function getInstance() : ?self

isRunning() ​

php
public function isRunning() : bool

locateBinary() ​

php
public static function locateBinary(string $configured, string $dataPath) : ?string

Finds the program: the configured path if any, otherwise the binary shipped with the server for this platform (native/vanillagen/bin, copied out of the phar since a program cannot run from inside it), otherwise one placed by the server owner in <data>/bin/.

platformName() ​

php
public static function platformName() : string

Platform suffix of the shipped binaries, e.g. "windows-amd64" or "linux-arm64".

prepareForServer() ​

php
public static function prepareForServer() : void

Main thread: starts the helper once, according to pocketmine.yml, and publishes its endpoint for the worker threads. Failures are logged and leave the PHP implementation in use.

publish() ​

php
public function publish() : void

Makes the endpoint visible to every thread of this process (worker threads read it with endpoint()).

start() ​

php
public static function start(string $binary, string $logFile, float $timeout = 10.0) : self

Starts the helper and waits until it listens.

stop() ​

php
public function stop() : void

Closes the helper's stdin (it exits), then kills it if it does not exit within two seconds.

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