mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
Assign new IDs to every block
This commit is contained in:
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user