Skip to content

BlockStateDictionary ​

final class · pocketmine\network\mcpe\convert\BlockStateDictionary · source

Handles translation of network block runtime IDs into blockstate data, and vice versa

Constants ​

UNKNOWN_BLOCK_NETWORK_ID 5.46.0 ​

php
public const UNKNOWN_BLOCK_NETWORK_ID = -2

Network ID the vanilla client uses for an unknown block when hashed IDs are in use.

Methods ​

__construct() ​

php
public function __construct(array $states)

computeNetworkId() 5.46.0 ​

php
public static function computeNetworkId(string $name, array $stateProperties) : int

Computes the hashed network runtime ID of a blockstate, as the vanilla client does when StartGamePacket::blockNetworkIdsAreHashes is true: FNV-1a 32-bit over the little-endian NBT encoding of TAG_Compound{name: TAG_String, states: TAG_Compound} with the state properties sorted by name. The result is returned as a signed 32-bit integer.

generateDataFromStateId() ​

php
public function generateDataFromStateId(int $networkRuntimeId) : ?\pocketmine\data\bedrock\block\BlockStateData

getMetaFromStateId() ​

php
public function getMetaFromStateId(int $networkRuntimeId) : ?int

Returns the blockstate meta value associated with the given blockstate runtime ID. This is used for serializing crafting recipe inputs.

getStates() ​

php
public function getStates() : array

Returns an array mapping runtime ID => blockstate data.

loadFromString() ​

php
public static function loadFromString(string $blockPaletteContents, string $metaMapContents) : self

loadPaletteFromString() ​

php
public static function loadPaletteFromString(string $blockPaletteContents) : array

lookupStateIdFromData() ​

php
public function lookupStateIdFromData(\pocketmine\data\bedrock\block\BlockStateData $data) : ?int

Searches for the appropriate state ID which matches the given blockstate NBT. Returns null if there were no matches.

lookupStateIdFromIdMeta() ​

php
public function lookupStateIdFromIdMeta(string $id, int $meta) : ?int

Returns the blockstate data associated with the given block ID and meta value. This is used for deserializing crafting recipe inputs.

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