mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Assign new IDs to every block
This commit is contained in:
@ -31,16 +31,20 @@ class BlockIdentifier{
|
||||
* @phpstan-param class-string<Tile>|null $tileClass
|
||||
*/
|
||||
public function __construct(
|
||||
private int $blockId,
|
||||
private int $variant,
|
||||
private ?int $itemId = null,
|
||||
private int $blockTypeId,
|
||||
private int $legacyBlockId,
|
||||
private int $legacyVariant,
|
||||
private ?int $legacyItemId = null,
|
||||
private ?string $tileClass = null
|
||||
){
|
||||
if($blockId < 0){
|
||||
throw new \InvalidArgumentException("Block ID may not be negative");
|
||||
if($blockTypeId < 0){
|
||||
throw new \InvalidArgumentException("Block type ID may not be negative");
|
||||
}
|
||||
if($variant < 0){
|
||||
throw new \InvalidArgumentException("Block variant may not be negative");
|
||||
if($legacyBlockId < 0){
|
||||
throw new \InvalidArgumentException("Legacy block ID may not be negative");
|
||||
}
|
||||
if($legacyVariant < 0){
|
||||
throw new \InvalidArgumentException("Legacy block variant may not be negative");
|
||||
}
|
||||
|
||||
if($tileClass !== null){
|
||||
@ -48,23 +52,35 @@ class BlockIdentifier{
|
||||
}
|
||||
}
|
||||
|
||||
public function getBlockId() : int{
|
||||
return $this->blockId;
|
||||
public function getBlockTypeId() : int{ return $this->blockTypeId; }
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function getLegacyBlockId() : int{
|
||||
return $this->legacyBlockId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return int[]
|
||||
*/
|
||||
public function getAllBlockIds() : array{
|
||||
return [$this->blockId];
|
||||
public function getAllLegacyBlockIds() : array{
|
||||
return [$this->legacyBlockId];
|
||||
}
|
||||
|
||||
public function getVariant() : int{
|
||||
return $this->variant;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function getLegacyVariant() : int{
|
||||
return $this->legacyVariant;
|
||||
}
|
||||
|
||||
public function getItemId() : int{
|
||||
return $this->itemId ?? ($this->blockId > 255 ? 255 - $this->blockId : $this->blockId);
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function getLegacyItemId() : int{
|
||||
return $this->legacyItemId ?? ($this->legacyBlockId > 255 ? 255 - $this->legacyBlockId : $this->legacyBlockId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user