mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
Make more item stuff dynamic
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user