mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 02:42:58 +00:00
All types of coral now have fully dynamic types
This commit is contained in:
@ -23,21 +23,37 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use function count;
|
||||
|
||||
class BlockIdentifierFlattened extends BlockIdentifier{
|
||||
|
||||
/** @var int */
|
||||
private $secondId;
|
||||
/** @var int[] */
|
||||
private array $additionalIds;
|
||||
|
||||
public function __construct(int $blockId, int $secondId, int $variant, ?int $itemId = null, ?string $tileClass = null){
|
||||
/**
|
||||
* @param int[] $additionalIds
|
||||
*/
|
||||
public function __construct(int $blockId, array $additionalIds, int $variant, ?int $itemId = null, ?string $tileClass = null){
|
||||
if(count($additionalIds) === 0){
|
||||
throw new \InvalidArgumentException("Expected at least 1 additional ID");
|
||||
}
|
||||
parent::__construct($blockId, $variant, $itemId, $tileClass);
|
||||
$this->secondId = $secondId;
|
||||
|
||||
$this->additionalIds = $additionalIds;
|
||||
}
|
||||
|
||||
public function getAdditionalId(int $index) : int{
|
||||
if(!isset($this->additionalIds[$index])){
|
||||
throw new \InvalidArgumentException("No such ID at index $index");
|
||||
}
|
||||
return $this->additionalIds[$index];
|
||||
}
|
||||
|
||||
public function getSecondId() : int{
|
||||
return $this->secondId;
|
||||
return $this->getAdditionalId(0);
|
||||
}
|
||||
|
||||
public function getAllBlockIds() : array{
|
||||
return [$this->getBlockId(), $this->getSecondId()];
|
||||
return [$this->getBlockId(), ...$this->additionalIds];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user