ÂBlock: added a TODO for getStateId()

This commit is contained in:
Dylan K. Taylor 2023-05-25 17:38:39 +01:00
parent 24e897f813
commit cc77f18ff0
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -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));
}