32 public const TAG_COLOR =
"color";
34 private DyeColor $color = DyeColor::RED;
36 public function getColor() : DyeColor{
40 public function setColor(DyeColor $color) :
void{
41 $this->color = $color;
44 public function readSaveData(
CompoundTag $nbt) :
void{
46 ($colorTag = $nbt->
getTag(self::TAG_COLOR)) instanceof
ByteTag &&
47 ($color = DyeColorIdMap::getInstance()->fromId($colorTag->getValue())) !==
null
49 $this->color = $color;
51 $this->color = DyeColor::RED;
56 $nbt->setByte(self::TAG_COLOR,
DyeColorIdMap::getInstance()->toId($this->color));
60 $nbt->setByte(self::TAG_COLOR,
DyeColorIdMap::getInstance()->toId($this->color));