Exterminate legacy item IDs

This commit is contained in:
Dylan K. Taylor
2022-07-05 15:12:55 +01:00
parent c5282b059b
commit 68cbe46600
19 changed files with 375 additions and 1180 deletions

View File

@@ -27,24 +27,25 @@ use pocketmine\block\Block;
use pocketmine\block\utils\CoralType;
use pocketmine\block\utils\CoralTypeTrait;
use pocketmine\block\VanillaBlocks;
use pocketmine\data\bedrock\CoralTypeIdMap;
use pocketmine\data\runtime\RuntimeDataWriter;
use pocketmine\math\Axis;
use pocketmine\math\Facing;
final class CoralFan extends Item{
use CoralTypeTrait;
use CoralTypeTrait {
encodeType as encodeCoralType;
}
public function __construct(private ItemIdentifierFlattened $identifierFlattened){
public function __construct(ItemIdentifier $identifier){
$this->coralType = CoralType::TUBE();
parent::__construct($this->identifierFlattened, VanillaBlocks::CORAL_FAN()->getName());
parent::__construct($identifier, VanillaBlocks::CORAL_FAN()->getName());
}
public function getId() : int{
return $this->dead ? $this->identifierFlattened->getAdditionalLegacyIds()[0] : $this->identifierFlattened->getLegacyId();
}
public function getMeta() : int{
return CoralTypeIdMap::getInstance()->toId($this->coralType);
protected function encodeType(RuntimeDataWriter $w) : void{
//this is aliased to ensure a compile error in case the functions in Item or Block start to differ in future
//right now we can directly reuse encodeType from CoralTypeTrait, but that might silently stop working if Item
//were to be altered. CoralTypeTrait was originally intended for blocks, so it's better not to assume anything.
$this->encodeCoralType($w);
}
public function getBlock(?int $clickedFace = null) : Block{