Skip to content

Commit 269e97c

Browse files
committed
Fixes
1 parent f469432 commit 269e97c

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/entity/object/FireworkRocket.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,12 @@ protected function entityBaseTick(int $tickDiff = 1) : bool{
124124
$hasUpdate = parent::entityBaseTick($tickDiff);
125125

126126
if(!$this->isFlaggedForDespawn()){
127-
$this->addMotion($this->motion->x * 0.15, 0.04, $this->motion->z * 0.15);
127+
//Don't keep accelerating long-lived fireworks - this gets very rapidly out of control and makes the server
128+
//die vanilla fireworks will only live for about 52 ticks maximum anyway, so this only makes sure plugin
129+
//created fireworks don't murder the server
130+
if($this->ticksLived < 80){
131+
$this->addMotion($this->motion->x * 0.15, 0.04, $this->motion->z * 0.15);
132+
}
128133

129134
if($this->ticksLived >= $this->maxAgeTicks){
130135
$this->flagForDespawn();

src/item/FireworkRocket.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,13 @@ public function onInteractBlock(Player $player, Block $blockReplace, Block $bloc
9898

9999
$randomDuration = (($this->flightDurationMultiplier + 1) * 10) + mt_rand(0, 12);
100100

101-
$entity = new FireworkEntity(Location::fromObject($position, $player->getWorld(), lcg_value() * 360, 90), $randomDuration, $this->explosions);
101+
$entity = new FireworkEntity(Location::fromObject($position, $player->getWorld(), Utils::getRandomFloat() * 360, 90), $randomDuration, $this->explosions);
102102
$entity->setOwningEntity($player);
103-
$entity->setMotion(new Vector3(lcg_value() * 0.001, 0.05, lcg_value() * 0.001));
103+
$entity->setMotion(new Vector3(
104+
(Utils::getRandomFloat() - Utils::getRandomFloat()) * 0.0023,
105+
0.05,
106+
(Utils::getRandomFloat() - Utils::getRandomFloat()) * 0.0023
107+
));
104108
$entity->spawnToAll();
105109

106110
$this->pop();

0 commit comments

Comments
 (0)