tgwaste / Weather

Weather Plugin for PocketMine-MP Version 4
Apache License 2.0
4 stars 1 forks source link

Teleporting between worlds #10

Closed CoolCuzzy closed 2 years ago

CoolCuzzy commented 2 years ago

It will not allow me to teleport between worlds if this plugin is installed without leaving the game. for exmaple i have multiworld installed and when i do /mw tp (world) it wont let me teleport to the assigned world. although when i rejoin, im found in that world i wanted to teleport to. can u pls fix this!!

tgwaste commented 2 years ago

Hmm I'm not sure what the issue could be.

I assume that is happening here

  public function onEntityTeleportEvent(EntityTeleportEvent $event) {
    $player = $event->getEntity();
    $world = $event->getTo()->world;

    if ($player instanceof Player) {
      Main::$instance->weatherobj->sendWeatherToPlayer($player, $world);
    }
  }

  public function sendWeatherToPlayer(Player $player, World $world) {
    foreach ($this->getWeatherPackets($world) as $pk) {
      $player->getNetworkSession()->sendDataPacket($pk);
    }
  }

But I dont see any issue with that code. Maybe it needs to make sure the players teleport is complete but I have no idea how to check for that or if thats even possible.

CoolCuzzy commented 2 years ago

Hm. Well what happens is that the teleport doesn’t work unless the player rejoins the server. So maybe the weather needs to be set before teleportation? Like the weather in the assigned world should exist prior. Because what might be happening is that, the server is trying to load the wether in a world it wasnt prior in. And so it needs to load it in and when the player rejoins, it loads it properly. Thats what might be happening?? (Sorry im not a developer so i cant exactly read code so im not sure if thats what your showing, but im able to understand and explain possible solutions that may help.)

tgwaste commented 2 years ago

Here is a copy with the onEntityTeleportEvent removed. Please let me know if this fixes the issue and we can go from there. Weather.phar.zip

CoolCuzzy commented 2 years ago

Works fine now thank you!

tgwaste commented 2 years ago

So I can actually reproduce this still.

I'm not convinced this is fixed

tgwaste commented 2 years ago

It looks like the problem is with the lightning here

Main::$instance->getServer()->broadcastPackets($player->getWorld()->getPlayers(), [$light, $sound]);

When I remove this, things seem really fixed.

tgwaste commented 2 years ago

Version with lightning disabled Weather.phar.zip

tgwaste commented 2 years ago

1.0.8 submitted on poggit. this should fix lightning and teleportation.