Skip to content

MaterialRuleCompiler 5.46.0 ​

final class · pocketmine\world\generator\vanilla\surface\MaterialRuleCompiler · source

Turns a material rule tree into one PHP method (nested ifs, conditions inlined), which the JIT compiles well: evaluating the object tree costs a method call per node and block. Same results as MaterialRule::apply().

Constants ​

NAMESPACE ​

php
public const NAMESPACE = "pocketmine\\world\\generator\\vanilla\\compiled"

Methods ​

bind() ​

php
public function bind(mixed $value) : string

Index of a value in the bindings array of the generated class ($b[index] in the generated code).

create() ​

php
public static function create(\pocketmine\world\generator\vanilla\surface\rule\MaterialRule $rule, string $cacheDir) : \pocketmine\world\generator\vanilla\surface\rule\MaterialRule

density() ​

php
public function density(\pocketmine\world\generator\vanilla\density\DensityFunction $f, \pocketmine\world\generator\vanilla\surface\InterpolationCache $cache) : string

PHP expression computing a density function at the block ($x, $y, $z) with the same operations (and float results) as DensityFunction::compute(). Interpolated nodes take their value from the chunk's interpolation cache, once per block; node types without an inline form are called through their compute().

float() ​

php
public static function float(float $value) : string

lazy() ​

php
public function lazy(string $expression) : string

Expression evaluated at most once per block: a local variable of the generated method, set on first use.

temp() ​

php
public function temp() : string

A new temporary variable name for the generated code.

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