1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

AddEntityPacket is not working

Discussion in 'Development' started by Atomization, Jul 23, 2018.

  1. Atomization

    Atomization Baby Zombie

    Messages:
    120
    GitHub:
    iAtomPlaza
    hey, im not sure why i get this error... could it be because i am using an outdated reference?

    Code:
    [Server thread/CRITICAL]: Could not pass event 'pocketmine\event\player\PlayerJoinEvent' to 'Advanced_Welcome v0.1': Argument 1 passed to pocketmine\network\mcpe\NetworkBinaryStream::putEntityUniqueId() must be of the type integer, null given, called in phar://C:/Users/steve/Desktop/MCPE server/faction server/PocketMine-MP.phar/src/pocketmine/network/mcpe/protocol/AddEntityPacket.php on line 96 on Atom\Main
    
    [Server thread/CRITICAL]: TypeError: "Argument 1 passed to pocketmine\network\mcpe\NetworkBinaryStream::putEntityUniqueId() must be of the type integer, null given, called in phar://C:/Users/steve/Desktop/MCPE server/faction server/PocketMine-MP.phar/src/pocketmine/network/mcpe/protocol/AddEntityPacket.php on line 96" (EXCEPTION) in "src/pocketmine/network/mcpe/NetworkBinaryStream" at line 286
    
    and my code:
    PHP:
    public function onJoin(PlayerJoinEvent $event){
            
    $player $event->getPlayer();
            
    $name $player->getName(); 

            
    $this->sendLightning($player);
    }

    public function 
    sendLightning(Player $player){
            
    $level $player->getLevel();

            
    $light = new AddEntityPacket();
            
    $light->type 93;
            
    $light->eid Entity::$entityCount++;
            
    $light->metadata = array();
            
    $light->speedX 0;
            
    $light->speedY 0;
            
    $light->speedZ 0;
            
    $light->yaw $player->getYaw();
            
    $light->pitch $player->getPitch();
            
    $light->$player->x;
            
    $light->$player->y;
            
    $light->$player->z;
           
           
    $this->getServer()->broadcastPacket($level->getPlayers(), $light);
    }
     
  2. byyEmirhanWSD

    byyEmirhanWSD Witch

    Messages:
    50
    GitHub:
    EmirhanWSD
    PHP:
    $x $y $z 1;
    $pk = new AddEntityPacket();
    $pk->entityRuntimeId Entity::$entityCount++;
    $pk->type 93;
    $pk->position = new Vector3($x$y$z);
    $pk->motion null;
    foreach(
    Level->getPlayers() as $players) {
      
    $players->dataPacket($pk);

    }
     
  3. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Why?
    $x = $y = $z = 1;
     
  4. byyEmirhanWSD

    byyEmirhanWSD Witch

    Messages:
    50
    GitHub:
    EmirhanWSD
    He must replace it with player x y z
     
  5. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    PHP:
            $x $player->x;
            
    $y $player->y;
            
    $z $player->z;
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.