Skip to content

Commit 7c30985

Browse files
committed
Fixed #16
1 parent 989375f commit 7c30985

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

src/LightningListener.php

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,13 @@ public function onDeath(PlayerDeathEvent $event) :bool{
3434
}
3535
public function Lightning(Player $player) :void{
3636
if(in_array($player->getWorld()->getFolderName(), $this->getOwner()->getConfig()->get("worlds"))){
37-
$pos = $player->getPosition();
38-
$light = new AddActorPacket();
39-
$light->type = "minecraft:lightning_bolt";
40-
$light->actorRuntimeId = 1;
41-
$light->metadata = [];
42-
$light->motion = null;
43-
$light->yaw = $player->getLocation()->getYaw();
44-
$light->pitch = $player->getLocation()->getPitch();
45-
$light->position = new Vector3($pos->getX(), $pos->getY(), $pos->getZ());
37+
$pos = $player->getPosition();
38+
$light2 = AddActorPacket::create(Entity::nextRuntimeId(), 1, "minecraft:lightning_bolt", $player->getPosition()->asVector3(), null, $player->getLocation()->getYaw(), $player->getLocation()->getPitch(), 0.0, [], [], []);
4639
$block = $player->getWorld()->getBlock($player->getPosition()->floor()->down());
4740
$particle = new BlockBreakParticle($block);
48-
$player->getWorld()->addParticle($pos->asVector3(), $particle, $player->getWorld()->getPlayers());
49-
$sound = new PlaySoundPacket();
50-
$sound->soundName = "ambient.weather.thunder";
51-
$sound->x = $pos->getX();
52-
$sound->y = $pos->getY();
53-
$sound->z = $pos->getZ();
54-
$sound->volume = 1;
55-
$sound->pitch = 1;
56-
Server::getInstance()->broadcastPackets($player->getWorld()->getPlayers(), [$light, $sound]);
41+
$player->getWorld()->addParticle($pos, $particle, $player->getWorld()->getPlayers());
42+
$sound2 = PlaySoundPacket::create("ambient.weather.thunder", $pos->getX(), $pos->getY(), $pos->getZ(), 1, 1);
43+
Server::getInstance()->broadcastPackets($player->getWorld()->getPlayers(), [$light2, $sound2]);
5744
}
5845
}
5946

0 commit comments

Comments
 (0)