Replace hardcoded block metadata shifts and masks with constants

we might want to make these bigger than 4 bits in the future.
This commit is contained in:
Dylan K. Taylor
2021-06-16 12:48:09 +01:00
parent c22f793521
commit 61c59be299
9 changed files with 37 additions and 29 deletions

View File

@ -48,6 +48,8 @@ use function dechex;
use const PHP_INT_MAX;
class Block{
public const INTERNAL_METADATA_BITS = 4;
public const INTERNAL_METADATA_MASK = ~(~0 << self::INTERNAL_METADATA_BITS);
protected BlockIdentifier $idInfo;
protected string $fallbackName;
@ -90,7 +92,7 @@ class Block{
* @internal
*/
public function getFullId() : int{
return ($this->getId() << 4) | $this->getMeta();
return ($this->getId() << self::INTERNAL_METADATA_BITS) | $this->getMeta();
}
public function asItem() : Item{