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

Adding Entity Packet error

Discussion in 'Development' started by rektpixel, Oct 22, 2017.

  1. rektpixel

    rektpixel Baby Zombie

    Messages:
    186
    Hello I'm trying to get this chair plugin to work, this is the code:
    PHP:
        public function onPacketReceived(DataPacketReceiveEvent $event){
            
    $pk $event->getPacket();
            switch(
    $pk::NETWORK_ID){
                case 
    ProtocolInfo::PLAYER_ACTION_PACKET;
                    
    $player $event->getPlayer();
                    if(isset(
    $this->counter[$player->getName()])){
                        if(
    $pk->action === 8){$ppk = new SetEntityLinkPacket();
                            
    $ppk->from $this->counter[$player->getName()];
                            
    $ppk->to 0;$ppk->type 0;
                            
    $player->dataPacket($ppk);
                            
    $pkc = new SetEntityLinkPacket();
                            
    $pkc->from $this->counter[$player->getName()];
                            
    $pkc->to $player->getId();$pkc->type 0;
                            
    $ps=Server::getInstance()->getOnlinePlayers();
                            
    Server::getInstance()->broadcastPacket($ps,$pkc);
                            
    $pk0 = new RemoveEntityPacket();
                            
    $pk0->eid $this->counter[$player->getName()];
                            
    $ps=Server::getInstance()->getOnlinePlayers();
                            
    Server::getInstance()->broadcastPacket($ps,$pk0);
                            unset(
    $this->counter[$player->getName()]);
                        }
                    }
            }
        }
     
        public function 
    onTouch(PlayerInteractEvent $event)
        {
            if (
    $event->getBlock()->getId() === 53) {
                
    $player $event->getPlayer();
                
    $pk = new AddEntityPacket();
                
    $this->count $this->count 1;
                
    $pk->eid $this->count;
                
    $pk->type 84;
                
    $pk->$event->getBlock()->0.6;
                
    $pk->$event->getBlock()->0.6;
                
    $pk->$event->getBlock()->0.5;
                
    $pk->speedX 0;
                
    $pk->speedY 0;
                
    $pk->speedZ 0;
                
    $pk->yaw $player->yaw;
                
    $pk->pitch $player->pitch;
                
    $pk->metadata = [Entity::DATA_FLAGS => [Entity::DATA_TYPE_BYTE<< Entity::DATA_FLAG_INVISIBLE],[Entity::DATA_TYPE_STRING << Entity::DATA_NAMETAG] , [Entity::DATA_TYPE_BYTE,<< Entity::DATA_FLAG_ALWAYS_SHOW_NAMETAG], [Entity::DATA_TYPE_BYTE,<< Entity::DATA_FLAG_NO_AI]];
                
    $ps Server::getInstance()->getOnlinePlayers();
                
    Server::getInstance()->broadcastPacket($ps$pk);
                
    $ppk = new SetEntityLinkPacket();
                
    $ppk->from $this->count;
                
    $ppk->to 0;
                
    $ppk->type 2;
                
    $player->dataPacket($ppk);
                
    $pkc = new SetEntityLinkPacket();
                
    $pkc->from $this->count;
                
    $pkc->to $player->getId();
                
    $pkc->type 2;
                
    $ps Server::getInstance()->getOnlinePlayers();
                
    Server::getInstance()->broadcastPacket($ps$pkc);
                
    $this->counter[$player->getName()] = $this->count;
            }
        }
    }
    This is the error when a player taps block ID 53:
    Code:
    [13:26:42] [Server thread/CRITICAL]: Could not pass event 'pocketmine\event\player\PlayerInteractEvent' to 'PmChair v1.3': Argument 1 passed to pocketmine\network\mcpe\protocol\DataPacket::putEntityUniqueId() must be of the type integer, null given, called in phar://C:/Users/Admin/Creative Cloud Files/Desktop/Server/Server - DEV/PocketMine-MP.phar/src/pocketmine/network/mcpe/protocol/AddEntityPacket.php on line 93 on maru\PmChair
    [13:26:42] [Server thread/CRITICAL]: TypeError: "Argument 1 passed to pocketmine\network\mcpe\protocol\DataPacket::putEntityUniqueId() must be of the type integer, null given, called in phar://C:/Users/Admin/Creative Cloud Files/Desktop/Server/Server - DEV/PocketMine-MP.phar/src/pocketmine/network/mcpe/protocol/AddEntityPacket.php on line 93" (EXCEPTION) in "src/pocketmine/network/mcpe/protocol/DataPacket" at line 317
    [13:26:42] [Server thread/DEBUG]: #0 src/pocketmine/network/mcpe/protocol/AddEntityPacket(93): pocketmine\network\mcpe\protocol\DataPacket->putEntityUniqueId(NULL )
    [13:26:42] [Server thread/DEBUG]: #1 src/pocketmine/network/mcpe/protocol/DataPacket(99): pocketmine\network\mcpe\protocol\AddEntityPacket->encodePayload()
    [13:26:42] [Server thread/DEBUG]: #2 src/pocketmine/Server(1851): pocketmine\network\mcpe\protocol\DataPacket->encode()
    [13:26:42] [Server thread/DEBUG]: #3 PmChair-master/src/maru/PmChair(69): pocketmine\Server->broadcastPacket(array Array(), pocketmine\network\mcpe\protocol\AddEntityPacket object)
    [13:26:42] [Server thread/DEBUG]: #4 src/pocketmine/plugin/MethodEventExecutor(38): maru\PmChair->onTouch(pocketmine\event\player\PlayerInteractEvent object)
    [13:26:42] [Server thread/DEBUG]: #5 src/pocketmine/plugin/RegisteredListener(98): pocketmine\plugin\MethodEventExecutor->execute(maru\PmChair object, pocketmine\event\player\PlayerInteractEvent object)
    [13:26:42] [Server thread/DEBUG]: #6 src/pocketmine/plugin/PluginManager(721): pocketmine\plugin\RegisteredListener->callEvent(pocketmine\event\player\PlayerInteractEvent object)
    [13:26:42] [Server thread/DEBUG]: #7 src/pocketmine/level/Level(1765): pocketmine\plugin\PluginManager->callEvent(pocketmine\event\player\PlayerInteractEvent object)
    [13:26:42] [Server thread/DEBUG]: #8 src/pocketmine/Player(2291): pocketmine\level\Level->useItemOn(pocketmine\math\Vector3 object, pocketmine\item\ItemBlock object, integer 5, pocketmine\math\Vector3 object, pocketmine\Player object, boolean 1)
    [13:26:42] [Server thread/DEBUG]: #9 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(132): pocketmine\Player->handleInventoryTransaction(pocketmine\network\mcpe\protocol\InventoryTransactionPacket object)
    [13:26:42] [Server thread/DEBUG]: #10 src/pocketmine/network/mcpe/protocol/InventoryTransactionPacket(149): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleInventoryTransaction(pocketmine\network\mcpe\protocol\InventoryTransactionPacket object)
    [13:26:42] [Server thread/DEBUG]: #11 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(92): pocketmine\network\mcpe\protocol\InventoryTransactionPacket->handle(pocketmine\network\mcpe\PlayerNetworkSessionAdapter object)
    [13:26:42] [Server thread/DEBUG]: #12 src/pocketmine/network/mcpe/protocol/BatchPacket(115): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(pocketmine\network\mcpe\protocol\InventoryTransactionPacket object)
    [13:26:42] [Server thread/DEBUG]: #13 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(92): pocketmine\network\mcpe\protocol\BatchPacket->handle(pocketmine\network\mcpe\PlayerNetworkSessionAdapter object)
    [13:26:42] [Server thread/DEBUG]: #14 src/pocketmine/Player(3012): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(pocketmine\network\mcpe\protocol\BatchPacket object)
    [13:26:42] [Server thread/DEBUG]: #15 src/pocketmine/network/mcpe/RakLibInterface(143): pocketmine\Player->handleDataPacket(pocketmine\network\mcpe\protocol\BatchPacket object)
    [13:26:42] [Server thread/DEBUG]: #16 src/raklib/server/ServerHandler(97): pocketmine\network\mcpe\RakLibInterface->handleEncapsulated(string 192.168.8.103:55044, raklib\protocol\EncapsulatedPacket object, integer 0)
    [13:26:42] [Server thread/DEBUG]: #17 src/pocketmine/network/mcpe/RakLibInterface(82): raklib\server\ServerHandler->handlePacket()
    [13:26:42] [Server thread/DEBUG]: #18 src/pocketmine/network/Network(89): pocketmine\network\mcpe\RakLibInterface->process()
    [13:26:42] [Server thread/DEBUG]: #19 src/pocketmine/Server(2497): pocketmine\network\Network->processInterfaces()
    [13:26:42] [Server thread/DEBUG]: #20 src/pocketmine/Server(2253): pocketmine\Server->tick()
    [13:26:42] [Server thread/DEBUG]: #21 src/pocketmine/Server(2132): pocketmine\Server->tickProcessor()
    [13:26:42] [Server thread/DEBUG]: #22 src/pocketmine/Server(1714): pocketmine\Server->start()
    [13:26:42] [Server thread/DEBUG]: #23 src/pocketmine/PocketMine(558): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string phar://C:/Users/Admin/Creative Cloud Files/Desktop/MusicalChairsServer/Server - DEV/PocketMine-MP.phar/, string C:\Users\Admin\Creative Cloud Files\Desktop\Server\Server - DEV\, string C:\Users\Admin\Creative Cloud Files\Desktop\Server\Server - DEV\plugins\)
    [13:26:42] [Server thread/DEBUG]: #24 C:/Users/Admin/Creative Cloud Files/Desktop/Server/Server - DEV/PocketMine-MP.phar(1): require(string phar://C:/Users/Admin/Creative Cloud Files/Desktop/Server/Server - DEV/PocketMine-MP.phar/src/pocketmine/PocketMine.php)
    
     
    Last edited: Oct 22, 2017
  2. Irish

    Irish Baby Zombie

    Messages:
    156
    GitHub:
    irishpacks
  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.