From cc77f18ff0e7f1472055d546f2fa01669d91a8da Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 25 May 2023 17:38:39 +0100 Subject: [PATCH] =?UTF-8?q?=C3=82Block:=20added=20a=20TODO=20for=20getStat?= =?UTF-8?q?eId()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/block/Block.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/block/Block.php b/src/block/Block.php index 3ce2dc188..29990bd1c 100644 --- a/src/block/Block.php +++ b/src/block/Block.php @@ -141,6 +141,11 @@ class Block{ */ public function getStateId() : int{ $typeId = $this->getTypeId(); + //TODO: this XOR mask improves hashtable distribution, but it's only effective if the number of unique block + //type IDs is larger than the number of available state data bits. We should probably hash (e.g. using xxhash) + //the type ID to create a better mask. + //Alternatively, we could hash the whole state ID, but this is currently problematic, since we currently need + //to be able to recover the state data from the state ID because of UnknownBlock. return ($typeId << self::INTERNAL_STATE_DATA_BITS) | ($this->encodeFullState() ^ ($typeId & self::INTERNAL_STATE_DATA_MASK)); }