Assign new IDs to every block

This commit is contained in:
Dylan K. Taylor
2022-05-27 16:51:35 +01:00
parent adfabca684
commit bd8dd48dee
9 changed files with 1276 additions and 567 deletions

View File

@ -65,8 +65,8 @@ class Block{
* @param string $name English name of the block type (TODO: implement translations)
*/
public function __construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo){
if(($idInfo->getVariant() & $this->getStateBitmask()) !== 0){
throw new \InvalidArgumentException("Variant 0x" . dechex($idInfo->getVariant()) . " collides with state bitmask 0x" . dechex($this->getStateBitmask()));
if(($idInfo->getLegacyVariant() & $this->getStateBitmask()) !== 0){
throw new \InvalidArgumentException("Variant 0x" . dechex($idInfo->getLegacyVariant()) . " collides with state bitmask 0x" . dechex($this->getStateBitmask()));
}
$this->idInfo = $idInfo;
$this->fallbackName = $name;
@ -86,8 +86,11 @@ class Block{
return $this->fallbackName;
}
/**
* @deprecated
*/
public function getId() : int{
return $this->idInfo->getBlockId();
return $this->idInfo->getLegacyBlockId();
}
/**
@ -99,15 +102,18 @@ class Block{
public function asItem() : Item{
return ItemFactory::getInstance()->get(
$this->idInfo->getItemId(),
$this->idInfo->getVariant() | $this->writeStateToItemMeta()
$this->idInfo->getLegacyItemId(),
$this->idInfo->getLegacyVariant() | $this->writeStateToItemMeta()
);
}
/**
* @deprecated
*/
public function getMeta() : int{
$stateMeta = $this->writeStateToMeta();
assert(($stateMeta & ~$this->getStateBitmask()) === 0);
return $this->idInfo->getVariant() | $stateMeta;
return $this->idInfo->getLegacyVariant() | $stateMeta;
}
protected function writeStateToItemMeta() : int{
@ -171,7 +177,7 @@ class Block{
* powered/unpowered, etc.
*/
public function getTypeId() : int{
return ($this->idInfo->getBlockId() << Block::INTERNAL_METADATA_BITS) | $this->idInfo->getVariant();
return $this->idInfo->getBlockTypeId();
}
/**