34 protected const TAG_EXPLOSION =
"FireworksItem";
35 protected const TAG_CUSTOM_COLOR =
"customColor";
39 protected ?
Color $customColor =
null;
41 public function __construct(
ItemIdentifier $identifier,
string $name){
42 parent::__construct($identifier, $name);
45 FireworkRocketType::SMALL_BALL,
46 colors: [DyeColor::BLACK],
54 return $this->explosion;
59 $this->explosion = $explosion;
68 return $this->customColor ?? $this->explosion->getColorMix();
76 return $this->customColor;
86 $this->customColor = $color;
91 parent::deserializeCompoundTag($tag);
93 $explosionTag = $tag->
getTag(self::TAG_EXPLOSION);
97 $this->explosion = FireworkRocketExplosion::fromCompoundTag($explosionTag);
99 $customColor = Color::fromARGB(Binary::unsignInt($tag->getInt(self::TAG_CUSTOM_COLOR)));
100 $color = $this->explosion->getColorMix();
101 if(!$customColor->
equals($color)){
102 $this->customColor = $customColor;
106 protected function serializeCompoundTag(CompoundTag $tag) : void{
107 parent::serializeCompoundTag($tag);
109 $tag->setTag(self::TAG_EXPLOSION, $this->explosion->toCompoundTag());
110 $tag->setInt(self::TAG_CUSTOM_COLOR, Binary::signInt($this->getColor()->toARGB()));