Hi, I'm trying to use rain / snow in my lobby. In this thread (https://forums.pocketmine.net/threads/how-to-use-level-event-packet.12044/), If found a code to do this, but it does not work. I'm using Pre-Dev Build 48. Here's my code: PHP: public function onCommand(CommandSender $sender, Command $command, $label, array $args) {parent::onCommand($sender, $command, $label, $args);$realcmd = $command->getName();if ($realcmd == "snow") {$pk = new LevelEventPacket();$pk->x = $sender->x; //set your own coordinates$pk->y = $sender->y;$pk->z = $sender->z;$pk->evid = LevelEventPacket::EVENT_START_RAIN;$sender->dataPacket($pk);$sender->sendMessage("§aSnow startet");$sender->sendMessage("§cYou're at".$sender->x.",".$sender->y.",".$sender->z.".");return true;}return false;} When I run /snow in game, it happens nothing. Any idea what I'm doing wrong?
Try this: PHP: public function onCommand(CommandSender $sender, Command $command, $label, array $args){ if ($command->getName() === "snow"){ $x = $sender->getX(); $y = $sender->getY(); $z = $sender->getZ(); $pk = new LevelEventPacket(); $pk->x = $x; $pk->y = $y; $pk->z = $z; $pk->evid = LevelEventPacket::EVENT_START_RAIN; $sender->dataPacket($pk); $sender->sendMessage(TextFormat::GREEN."Snow started"); $sender->sendMessage(TextFormat::RED."You're at $x,$y,$z."); return true; } return false;} And use these: PHP: use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\network\protocol\LevelEventPacket;use pocketmine\utils\TextFormat;
Server: Running PocketMine-MP 1.6dev-48 「[REDACTED]」 implementing API version 1.13.0 for Minecraft: PE v0.12.1 alpha (protocol version 34) Player: iPad with Minecraft 0.12.3
Also tried adding that, but there's an error: Code: [09:05:14] [Server thread/CRITICAL]: Unhandled exception executing command 'snow' in snow: Class jjmc\LetItSnow\Network not found [09:05:14] [Server thread/CRITICAL]: ClassNotFoundException: "Class jjmc\LetItSnow\Network not found" (EXCEPTION) in "/src/spl/BaseClassLoader" at line 144
Code: [09:10:34] [Server thread/CRITICAL]: Unhandled exception executing command 'snow' in snow: Class pocketmine\network not found [09:10:34] [Server thread/CRITICAL]: ClassNotFoundException: "Class pocketmine\network not found" (EXCEPTION) in "/src/spl/BaseClassLoader" at line 144
From looking at that code, I think THIS would work...: PHP: public function onCommand(CommandSender $sender, Command $command, $label, array $args){if ($command->getName() === "snow"){$x = $sender->getX();$y = $sender->getY();$z = $sender->getZ();$pk = new LevelEventPacket();$pk->x = $x;$pk->y = $y;$pk->z = $z;$pk->data = 10000;$pk->evid = LevelEventPacket::EVENT_START_RAIN;$sender->dataPacket($pk);$sender->sendMessage(TextFormat::GREEN."Snow started");$sender->sendMessage(TextFormat::RED."You're at $x,$y,$z.");return true;}return false;}
Packet channels were removed (backwards-compatible) in newer PocketMine versions because the optimization it does is not as good as expected.