Make more item stuff dynamic

This commit is contained in:
Dylan K. Taylor
2022-06-29 00:26:16 +01:00
parent 6058032807
commit 56428e8a4e
8 changed files with 116 additions and 217 deletions

View File

@ -26,19 +26,32 @@ namespace pocketmine\item;
use pocketmine\block\Block;
use pocketmine\block\utils\DyeColor;
use pocketmine\block\VanillaBlocks;
use pocketmine\data\bedrock\DyeColorIdMap;
class Bed extends Item{
private DyeColor $color;
public function __construct(ItemIdentifier $identifier, string $name, DyeColor $color){
public function __construct(ItemIdentifier $identifier, string $name){
$this->color = DyeColor::WHITE();
parent::__construct($identifier, $name);
$this->color = $color;
}
public function getMeta() : int{
return DyeColorIdMap::getInstance()->toId($this->color);
}
public function getColor() : DyeColor{
return $this->color;
}
/**
* @return $this
*/
public function setColor(DyeColor $color) : self{
$this->color = $color;
return $this;
}
public function getBlock(?int $clickedFace = null) : Block{
return VanillaBlocks::BED()->setColor($this->color);
}