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

AddEntityPacket error

Comments in 'Plugin Development' started by Asidert, Jun 20, 2015.

  1. Asidert
    Offline

    Asidert Active Member Plugin Developer

    Joined:
    Oct 21, 2014
    Posts:
    123
    Plugins:
    1
    Minecraft User:
    Asidert
    Hello everybody, in my plugin I use some code from one's plugin and my server will crash.
    Console log:
    Code:
    [Server] [11:08:58] [Server thread/CRITICAL]: Could not execute task Asidert\FineTask: Argument 1 passed to pocketmine\utils\Binary::writeMetadata() must be of the type array, null given, called in phar:///storage/emulated/0/PocketMine/PocketMine-MP.phar/src/pocketmine/network/protocol/AddEntityPacket__32bit.php on line 68 and defined
    [Server] [11:08:58] [Server thread/NOTICE]: InvalidArgumentException: "Argument 1 passed to pocketmine\utils\Binary::writeMetadata() must be of the type array, null given, called in phar:///storage/emulated/0/PocketMine/PocketMine-MP.phar/src/pocketmine/network/protocol/AddEntityPacket__32bit.php on line 68 and defined" (E_RECOVERABLE_ERROR) in "/src/pocketmine/utils/Binary" at line 84
    
    Plugin code for add entity packet:
    PHP:
        public function BlockPacket(Player $player$blockId){
            
    $this->BlockBlock($player);
            
    $player->despawnFromAll();
            
    $pk = new AddEntityPacket();
            
    $pk->type FallingSand::NETWORK_ID;
            
    $pk->eid $player->getId();
            
    $pk->$player->getX();
            
    $pk->$player->getY();
            
    $pk->$player->getZ();
            
    $pk->did = -$blockId;

            foreach(
    $player->getLevel()->getPlayers() as $p)
            {
                
    $p->dataPacket($pk);
            }
            
    $this->getLogger()->warning("Игрок:".$player->getName().",Блок:".$blockId);
            
    $this->players[$player->getName()]=$player;
            
    $this->players[$player->getName()]->gameInfo=new gameInfo();
            
    $this->players[$player->getName()]->gameInfo->hideID=$blockId;
        }
       
        public function 
    BlockBlock(Player $player)
        {
            if(
    $this->playerIsInGame($player->getName())!==2)
            {
                return;
            }
            
    $player->despawnFromAll();
            
    $pk=new RemoveEntityPacket();
            
    $pk->eid=$player->getId();
            if(
    $this->gameStatus>1)
            {
                foreach(
    $player->getLevel()->getPlayers() as $p)
                {
                    
    $p->dataPacket($pk);
                }
            }
            unset(
    $this->players[$player->getName()]);
            
    $player->spawnToAll();
            if(
    $player->gameInfo->isHide)
            {
                
    $pk=new UpdateBlockPacket();
                
    $pk->x=$player->gameInfo->hideX;
                
    $pk->y=$player->gameInfo->hideY;
                
    $pk->z=$player->gameInfo->hideZ;
                
    $pk->block=$player->gameInfo->oldID;
                
    $pk->meta=$player->gameInfo->oldData;
                
    $this->packetToAll($pk);
                
    $player->gameInfo->isHide=false;
            }
        }

    This code for PM 1.4
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
  3. Asidert
    Offline

    Asidert Active Member Plugin Developer

    Joined:
    Oct 21, 2014
    Posts:
    123
    Plugins:
    1
    Minecraft User:
    Asidert

Share This Page

Advertisement