Block: added getTypeId()

This commit is contained in:
Dylan K. Taylor 2022-01-07 21:03:19 +00:00
parent 661848c5e7
commit 0bc578b8fc
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -166,13 +166,21 @@ class Block{
}
/**
* Returns whether the given block has an equivalent type to this one. This compares base legacy ID and variant.
* Returns a type ID that identifies this type of block. This does not include information like facing, colour,
* powered/unpowered, etc.
*/
public function getTypeId() : int{
return ($this->idInfo->getBlockId() << Block::INTERNAL_METADATA_BITS) | $this->idInfo->getVariant();
}
/**
* Returns whether the given block has an equivalent type to this one. This compares the type IDs.
*
* Note: This ignores additional IDs used to represent additional states. This means that, for example, a lit
* furnace and unlit furnace are considered the same type.
*/
public function isSameType(Block $other) : bool{
return $this->idInfo->getBlockId() === $other->idInfo->getBlockId() and $this->idInfo->getVariant() === $other->idInfo->getVariant();
return $this->getTypeId() === $other->getTypeId();
}
/**