Assign new IDs to every block

This commit is contained in:
Dylan K. Taylor
2022-05-27 16:51:35 +01:00
parent adfabca684
commit bd8dd48dee
9 changed files with 1276 additions and 567 deletions

View File

@ -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);
}
/**