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

Packet Send Issue

Comments in 'Plugin Development' started by Skullex, Apr 28, 2016.

  1. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    Everything works, but once building turrain gets close to being done it stops and does nothing. Does anyone know how to help me with this here?

    PHP:
    <?php

    namespace PacketSend;

    use 
    pocketmine\event\entity\EntityLevelChangeEvent;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\entity\Entity;
    use 
    pocketmine\Player;
    use 
    pocketmine\network\protocol\StartGamePacket;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\event\server\DataPacketReceiveEvent;
    use 
    pocketmine\event\server\DataPacketSendEvent;
    use 
    pocketmine\level\Position;
    use 
    pocketmine\level\Level;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\utils\TextFormat as C;

    class 
    Main extends PluginBase implements Listener{
       
        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->registerEvents ($this$this);
        }
       
        public function 
    sendChangeDimension(Player $player$dimension 0) {
            echo 
    "sendChangeDimension\n";
            
    $pk = new StartGamePacket();
            
    $pk->seed = - 1;
            
    $pk->dimension $dimension;
            
    $pk->$player->x;
            
    $pk->$player->y;
            
    $pk->$player->z;
            
    $spawnPosition $player->getSpawn();
            
    $pk->spawnX = (int) $spawnPosition->x;
            
    $pk->spawnY = (int) $spawnPosition->y;
            
    $pk->spawnZ = (int) $spawnPosition->z;
            
    $pk->generator 1;
            
    $pk->gamemode $player->gamemode 0x01;
            
    $pk->eid 0;
            
    $player->dataPacket($pk);
            
    $player->sendSettings();
        }
       
        public function 
    onLevelChange(EntityLevelChangeEvent $event){
            
    $player $event->getEntity();
            
    $pk = new ChangeDimensionPacket();
            
    $pk->eid 0;
            
    $pk->dimensionId 1;
            
    $this->sendChangeDimension($player1);
            
    $player->dataPacket($pk);
            
    $player->chunk null;
            
    $player->checkNetwork();
        }
    }

    class 
    ChangeDimensionPacket extends DataPacket {
       
        const 
    CHANGE_DIMENSION_PACKET 0xc1;
        const 
    NETWORK_ID self::CHANGE_DIMENSION_PACKET;
        public 
    $eid;
        public 
    $dimensionId;
       
        public function 
    decode(){
            
    $this->dimensionId = (\PHP_INT_SIZE === ? \unpack ("N"$this->get(4)) [1] << 32 >> 32 : \unpack ("N"$this->get (4)) [1]);
        }
       
        public function 
    encode(){
            
    $this->buffer = \chr (self::NETWORK_ID);
            
    $this->offset 0;
            
    $this->buffer .= \pack "NN"$this->eid >> 32$this->eid 0xFFFFFFFF );
            
    $this->buffer .= Binary::writeLong($this->eid);
            
    $this->buffer .= \chr$this->dimensionId);
            
    $this->buffer .= \pack("N"$this->dimensionId);
        }
    }

Share This Page

Advertisement