Skip to content

FeatureLevel 5.46.0 ​

final class · pocketmine\world\generator\vanilla\feature\FeatureLevel · source

The decoration region (vanilla's WorldGenRegion for the FEATURES step): the 3x3 chunks around the decorated chunk, read and written as Java block states. Blocks written by features are remembered as Java states, so later reads see exactly what was written (the Bedrock mapping is lossy for a few properties, e.g. leaf distance); other blocks are mapped back from the PocketMine states.

Heightmaps are computed from the current blocks on first use and kept up to date on writes, like vanilla's chunk heightmaps (Heightmap.update()).

Constants ​

MOTION_BLOCKING ​

php
public const MOTION_BLOCKING = 4

MOTION_BLOCKING_NO_LEAVES ​

php
public const MOTION_BLOCKING_NO_LEAVES = 5

OCEAN_FLOOR ​

php
public const OCEAN_FLOOR = 3

OCEAN_FLOOR_WG ​

php
public const OCEAN_FLOOR_WG = 2

SIZE ​

php
public const SIZE = 48

WORLD_SURFACE ​

php
public const WORLD_SURFACE = 1

WORLD_SURFACE_WG ​

php
public const WORLD_SURFACE_WG = 0

Properties ​

$biomes ​

php
public readonly \pocketmine\world\generator\vanilla\feature\FeatureBiomes $biomes

$blocks ​

php
public readonly \pocketmine\world\generator\vanilla\feature\block\JavaBlocks $blocks

$centerChunkX ​

php
public int $centerChunkX

$centerChunkZ ​

php
public int $centerChunkZ

$height ​

php
public readonly int $height

$logWrites ​

php
public bool $logWrites

Whether writes are logged in $writeLog (the native decoration mirrors the region and needs the writes made on the PHP side).

$maxY ​

php
public readonly int $maxY

$minX ​

php
public int $minX

$minY ​

php
public readonly int $minY

$minZ ​

php
public int $minZ

$regionRandom ​

php
public ?\pocketmine\world\generator\vanilla\random\RandomSource $regionRandom

Positional random of this region (WorldGenRegion.getRandom()), set by the decorator.

$seaLevel ​

php
public readonly int $seaLevel

$seed ​

php
public readonly int $seed

$terrainHeightProvider ​

php
public ?\Closure $terrainHeightProvider

$writeLog ​

php
public array $writeLog

Logged writes: key, Java state pairs (key bit 31: written by setPmState(), which does not update heightmaps).

Methods ​

__construct() ​

php
public function __construct(\pocketmine\world\generator\vanilla\feature\block\JavaBlocks $blocks, int $minY, int $height, int $seaLevel, int $seed, \pocketmine\world\generator\vanilla\feature\FeatureBiomes $biomes)

addEntity() ​

php
public function addEntity(int $x, int $z, \pocketmine\nbt\tag\CompoundTag $nbt) : bool

Adds an entity to spawn with the chunk of its position (Chunk::addPendingEntityNBT()). Returns false if the position is outside the region.

applyNativeWrites() ​

php
public function applyNativeWrites(array $keys, array $states, array $blockEntities = []) : void

Applies writes made by the native decoration (which already applied them to its own copy of the region): each one exactly like setState(), without logging.

begin() ​

php
public function begin(\pocketmine\world\ChunkManager $world, int $chunkX, int $chunkZ) : void

ensureCanWrite() ​

php
public function ensureCanWrite(int $x, int $y, int $z) : bool

Whether a block can be written (inside the 3x3 chunks and the build height), WorldGenRegion.ensureCanWrite().

finish() ​

php
public function finish() : void

Marks the modified chunks as dirty, so PocketMine sends them back from the worker.

getBiome() ​

php
public function getBiome(int $x, int $y, int $z) : int

getHeight() ​

php
public function getHeight(int $type, int $x, int $z) : int

First free y above the highest block matching the heightmap type (vanilla's getHeight()).

getKnownTerrainHeights() ​

php
public function getKnownTerrainHeights() : array

Terrain heightmaps computed so far in this decoration, by region chunk index.

getRegionChunk() ​

php
public function getRegionChunk(int $dx, int $dz) : \pocketmine\world\format\Chunk

Index of the chunk at the given offset from the centre chunk (dx, dz in -1..1).

getRegionSubChunk() ​

php
public function getRegionSubChunk(int $chunkIndex, int $section) : \pocketmine\world\format\SubChunk

Section of a chunk of the region (chunk index (dx + 1) * 3 + dz + 1, section 0 = minY).

getState() ​

php
public function getState(int $x, int $y, int $z) : int

isEmptyBlock() ​

php
public function isEmptyBlock(int $x, int $y, int $z) : bool

isInRegion() ​

php
public function isInRegion(int $x, int $z) : bool

isInsideBuildHeight() ​

php
public function isInsideBuildHeight(int $y) : bool

isOutsideBuildHeight() ​

php
public function isOutsideBuildHeight(int $y) : bool

isWaterAt() ​

php
public function isWaterAt(int $x, int $y, int $z) : bool

setBlockEntity() ​

php
public function setBlockEntity(int $x, int $y, int $z, \pocketmine\nbt\tag\CompoundTag $nbt) : bool

Gives the block at a position its block entity data (a tile's saved data, created when the chunk reaches the world, see Chunk::addPendingTileNBT()). Returns false if the position cannot be written.

setPmState() ​

php
public function setPmState(int $x, int $y, int $z, int $pmState) : bool

Sets a Bedrock-only block (a PocketMine state id with no Java block state, e.g. an item frame, which is an entity in Java). Later reads of the position see the Java state the Bedrock state maps back to. Heightmaps are not updated (only meant for blocks without collision). Returns false if the position cannot be written.

setState() ​

php
public function setState(int $x, int $y, int $z, int $state) : bool

Sets a block (WorldGenRegion.setBlock()). Returns false if the position cannot be written.

setTerrainHeights() ​

php
public function setTerrainHeights(int $chunkIndex, array $heights) : void

Sets the terrain heightmaps of a chunk of the region (computed by the native decoration).

terrainHeightsOf() ​

php
public function terrainHeightsOf(int $chunkIndex) : array

Terrain heightmaps (WORLD_SURFACE_WG, OCEAN_FLOOR_WG) of a chunk of the region (index (dx + 1) * 3 + dz + 1), computed on first use and then kept for the rest of the decoration.

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