All types of coral now have fully dynamic types

This commit is contained in:
Dylan K. Taylor
2021-05-19 22:49:44 +01:00
parent 69fa8e8db7
commit af678f985d
11 changed files with 161 additions and 96 deletions

View File

@ -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];
}
}