97 $position = $blockClicked->getPosition()->addVector($clickVector)->addVector(
Vector3::zero()->getSide($face)->multiply(0.15));
99 $randomDuration = (($this->flightTimeMultiplier + 1) * 10) + mt_rand(0, 12);
101 $entity =
new FireworkEntity(Location::fromObject($position, $player->getWorld(), Utils::getRandomFloat() * 360, 90), $randomDuration, $this->explosions);
102 $entity->setOwningEntity($player);
103 $entity->setMotion(
new Vector3(
104 (Utils::getRandomFloat() - Utils::getRandomFloat()) * 0.0023,
106 (Utils::getRandomFloat() - Utils::getRandomFloat()) * 0.0023
108 $entity->spawnToAll();
112 return ItemUseResult::SUCCESS;
116 parent::deserializeCompoundTag($tag);
119 if($fireworkData ===
null){
123 $this->setFlightTimeMultiplier($fireworkData->getByte(self::TAG_FLIGHT_TIME_MULTIPLIER, 1));
125 if(($explosions = $fireworkData->getListTag(self::TAG_EXPLOSIONS, CompoundTag::class)) !==
null){
126 foreach($explosions as $explosion){
127 $this->explosions[] = FireworkRocketExplosion::fromCompoundTag($explosion);
137 $fireworkData->setTag(self::TAG_EXPLOSIONS,
new ListTag(array_map(fn(FireworkRocketExplosion $e) => $e->toCompoundTag(), $this->explosions)));