BlockIdentifier: enforce that ID and variant must be non-negative

This commit is contained in:
Dylan K. Taylor 2022-03-23 14:39:02 +00:00
parent 310104f786
commit b52bb5016c
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -38,6 +38,12 @@ class BlockIdentifier{
* @phpstan-param class-string<Tile>|null $tileClass
*/
public function __construct(int $blockId, int $variant, ?int $itemId = null, ?string $tileClass = null){
if($blockId < 0){
throw new \InvalidArgumentException("Block ID may not be negative");
}
if($variant < 0){
throw new \InvalidArgumentException("Block variant may not be negative");
}
$this->blockId = $blockId;
$this->variant = $variant;
$this->itemId = $itemId;