Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to use rain?

Comments in 'Plugin Development' started by jjmc, Oct 25, 2015.

  1. jjmc
    Offline

    jjmc New Member

    Joined:
    Oct 18, 2015
    Posts:
    41
    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 $senderCommand $command$label, array $args) {parent::onCommand($sender$command$label$args);
    $realcmd $command->getName();
    if (
    $realcmd == "snow") {$pk = new LevelEventPacket();$pk->$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?
  2. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    maybe
    PHP:
    $pk->setChannel(Network::CHANNEL_WORLD_EVENTS);
  3. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777

    Try this:

    PHP:
    public function onCommand(CommandSender $senderCommand $command$label, array $args){
        if (
    $command->getName() === "snow"){
            
    $x $sender->getX();
            
    $y $sender->getY();
            
    $z $sender->getZ();
            
    $pk = new LevelEventPacket();
            
    $pk->$x;
            
    $pk->$y;
            
    $pk->$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;
  4. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    is there a one for sunny?
  5. jjmc
    Offline

    jjmc New Member

    Joined:
    Oct 18, 2015
    Posts:
    41
    Does not work, it happens nothing
  6. jjmc
    Offline

    jjmc New Member

    Joined:
    Oct 18, 2015
    Posts:
    41
    I think you can use EVENT_STOP_RAIN instead of EVENT_START_RAIN.
  7. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    Did you register the command in the plugin.yml file?
  8. jjmc
    Offline

    jjmc New Member

    Joined:
    Oct 18, 2015
    Posts:
    41
    Yes :), sure, the "Snow started" message is there, but there's no weather effect.
  9. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    I assume you are running MCPE 0.12.*?
  10. jjmc
    Offline

    jjmc New Member

    Joined:
    Oct 18, 2015
    Posts:
    41
    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
  11. jjmc
    Offline

    jjmc New Member

    Joined:
    Oct 18, 2015
    Posts:
    41
    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
  12. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    Add
    PHP:
    use pocketmine\network\Network;
    Last edited: Oct 25, 2015
  13. jjmc
    Offline

    jjmc New Member

    Joined:
    Oct 18, 2015
    Posts:
    41
    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
  14. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    PHP:
    use pocketmine\network\Network;
    jojoe77777 likes this.
  15. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    Oops...
  16. jjmc
    Offline

    jjmc New Member

    Joined:
    Oct 18, 2015
    Posts:
    41
    That works, there are no more errors, but the same problem like before: no rain.
  17. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
  18. jjmc
    Offline

    jjmc New Member

    Joined:
    Oct 18, 2015
    Posts:
    41
  19. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    From looking at that code, I think THIS would work...:

    PHP:
    public function onCommand(CommandSender $senderCommand $command$label, array $args){
    if (
    $command->getName() === "snow"){
    $x $sender->getX();
    $y $sender->getY();
    $z $sender->getZ();
    $pk = new LevelEventPacket();
    $pk->$x;
    $pk->$y;
    $pk->$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;
    }
  20. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Packet channels were removed (backwards-compatible) in newer PocketMine versions because the optimization it does is not as good as expected.
    jjmc, CrazedMiner and jojoe77777 like this.

Share This Page

Advertisement