BlockStateDictionary
Handles translation of network block runtime IDs into blockstate data, and vice versa
Constants
UNKNOWN_BLOCK_NETWORK_ID 5.46.0
public const UNKNOWN_BLOCK_NETWORK_ID = -2Network ID the vanilla client uses for an unknown block when hashed IDs are in use.
Methods
__construct()
public function __construct(array $states)computeNetworkId() 5.46.0
public static function computeNetworkId(string $name, array $stateProperties) : intComputes 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()
public function generateDataFromStateId(int $networkRuntimeId) : ?\pocketmine\data\bedrock\block\BlockStateDatagetMetaFromStateId()
public function getMetaFromStateId(int $networkRuntimeId) : ?intReturns the blockstate meta value associated with the given blockstate runtime ID. This is used for serializing crafting recipe inputs.
getStates()
public function getStates() : arrayReturns an array mapping runtime ID => blockstate data.
loadFromString()
public static function loadFromString(string $blockPaletteContents, string $metaMapContents) : selfloadPaletteFromString()
public static function loadPaletteFromString(string $blockPaletteContents) : arraylookupStateIdFromData()
public function lookupStateIdFromData(\pocketmine\data\bedrock\block\BlockStateData $data) : ?intSearches for the appropriate state ID which matches the given blockstate NBT. Returns null if there were no matches.
lookupStateIdFromIdMeta()
public function lookupStateIdFromIdMeta(string $id, int $meta) : ?intReturns the blockstate data associated with the given block ID and meta value. This is used for deserializing crafting recipe inputs.
