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

DataPacket not working or something changed?

Discussion in 'Development' started by rektpixel, Jan 10, 2018.

  1. rektpixel

    rektpixel Baby Zombie

    Messages:
    186
    This code did work but since pmmp updates, it no longer works.
    PHP:
        public function onTouch(PlayerInteractEvent $event){
            
    $player $event->getPlayer();
            if(
    $event->getBlock()->getID() === 53){
                if(
    $player->hasPermission("game.sit")) {
                    
    $block $event->getBlock();
                    
    $player $event->getPlayer();
                    
    $player->setMotion(new Vector3(10.20));
                
                    
    $add = new AddEntityPacket;
                    
    $add->entityRuntimeId 666;
                    
    $add->type 95;
                    
    $add->position = new Vector3($block->0.6$block->1.6$block->0.5);
                    
    $player->dataPacket($add);
                    
    $ps Server::getInstance()->getOnlinePlayers();
                    
    Server::getInstance()->broadcastPacket($ps,$add);
                    
    $link = new SetEntityLinkPacket;
                    
    $link->link = [666$player->getId(), 11];
                    
    $player->dataPacket($link);
                    return 
    true;
                    }else{
                        
    $player->sendMessage("§9[GAME] §eThe music is still playing, you cannot sit on a chair!");
                        return 
    true;
                    }
            }
        }
    Everything seems fine. I don't understand :eek:
    Code:
    [12:48:39] [Server thread/CRITICAL]: Could not pass event 'pocketmine\event\player\PlayerInteractEvent' to 'PmChair v1.3': Argument 1 passed to pocketmine\network\mcpe\protocol\DataPacket::putEntityLink() must be an instance of pocketmine\network\mcpe\protocol\types\EntityLink, array given, called in phar://C:/Users/Admin/Creative Cloud Files/Desktop/Lobby - DEV/PocketMine-MP.phar/src/pocketmine/network/mcpe/protocol/SetEntityLinkPacket.php on line 43 on maru\PmChair
    [12:48:39] [Server thread/CRITICAL]: TypeError: "Argument 1 passed to pocketmine\network\mcpe\protocol\DataPacket::putEntityLink() must be an instance of pocketmine\network\mcpe\protocol\types\EntityLink, array given, called in phar://C:/Users/Admin/Creative Cloud Files/Desktop/Lobby - DEV/PocketMine-MP.phar/src/pocketmine/network/mcpe/protocol/SetEntityLinkPacket.php on line 43" (EXCEPTION) in "src/pocketmine/network/mcpe/protocol/DataPacket" at line 535
    [12:48:39] [Server thread/DEBUG]: #0 src/pocketmine/network/mcpe/protocol/SetEntityLinkPacket(43): pocketmine\network\mcpe\protocol\DataPacket->putEntityLink(array Array())
    [12:48:39] [Server thread/DEBUG]: #1 src/pocketmine/network/mcpe/protocol/DataPacket(100): pocketmine\network\mcpe\protocol\SetEntityLinkPacket->encodePayload()
    [12:48:39] [Server thread/DEBUG]: #2 src/pocketmine/network/mcpe/RakLibInterface(208): pocketmine\network\mcpe\protocol\DataPacket->encode()
    [12:48:39] [Server thread/DEBUG]: #3 src/pocketmine/Player(3036): pocketmine\network\mcpe\RakLibInterface->putPacket(pocketmine\Player object, pocketmine\network\mcpe\protocol\SetEntityLinkPacket object, boolean , boolean )
    [12:48:39] [Server thread/DEBUG]: #4 src/pocketmine/Player(3056): pocketmine\Player->sendDataPacket(pocketmine\network\mcpe\protocol\SetEntityLinkPacket object, boolean , boolean )
    [12:48:39] [Server thread/DEBUG]: #5 PmChair-master/src/maru/PmChair(48): pocketmine\Player->dataPacket(pocketmine\network\mcpe\protocol\SetEntityLinkPacket object)
    [12:48:39] [Server thread/DEBUG]: #6 src/pocketmine/plugin/MethodEventExecutor(38): maru\PmChair->onTouch(pocketmine\event\player\PlayerInteractEvent object)
    [12:48:39] [Server thread/DEBUG]: #7 src/pocketmine/plugin/RegisteredListener(98): pocketmine\plugin\MethodEventExecutor->execute(maru\PmChair object, pocketmine\event\player\PlayerInteractEvent object)
    [12:48:39] [Server thread/DEBUG]: #8 src/pocketmine/plugin/PluginManager(721): pocketmine\plugin\RegisteredListener->callEvent(pocketmine\event\player\PlayerInteractEvent object)
    [12:48:39] [Server thread/DEBUG]: #9 src/pocketmine/level/Level(1881): pocketmine\plugin\PluginManager->callEvent(pocketmine\event\player\PlayerInteractEvent object)
    [12:48:39] [Server thread/DEBUG]: #10 src/pocketmine/Player(2286): pocketmine\level\Level->useItemOn(pocketmine\math\Vector3 object, pocketmine\item\ItemBlock object, integer 4, pocketmine\math\Vector3 object, pocketmine\Player object, boolean 1)
    [12:48:39] [Server thread/DEBUG]: #11 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(132): pocketmine\Player->handleInventoryTransaction(pocketmine\network\mcpe\protocol\InventoryTransactionPacket object)
    [12:48:39] [Server thread/DEBUG]: #12 src/pocketmine/network/mcpe/protocol/InventoryTransactionPacket(149): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleInventoryTransaction(pocketmine\network\mcpe\protocol\InventoryTransactionPacket object)
    [12:48:39] [Server thread/DEBUG]: #13 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(92): pocketmine\network\mcpe\protocol\InventoryTransactionPacket->handle(pocketmine\network\mcpe\PlayerNetworkSessionAdapter object)
    [12:48:39] [Server thread/DEBUG]: #14 src/pocketmine/network/mcpe/protocol/BatchPacket(115): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(pocketmine\network\mcpe\protocol\InventoryTransactionPacket object)
    [12:48:39] [Server thread/DEBUG]: #15 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(92): pocketmine\network\mcpe\protocol\BatchPacket->handle(pocketmine\network\mcpe\PlayerNetworkSessionAdapter object)
    [12:48:39] [Server thread/DEBUG]: #16 src/pocketmine/Player(2982): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(pocketmine\network\mcpe\protocol\BatchPacket object)
    [12:48:39] [Server thread/DEBUG]: #17 src/pocketmine/network/mcpe/RakLibInterface(143): pocketmine\Player->handleDataPacket(pocketmine\network\mcpe\protocol\BatchPacket object)
    [12:48:39] [Server thread/DEBUG]: #18 vendor/pmmp/raklib/server/ServerHandler(99): pocketmine\network\mcpe\RakLibInterface->handleEncapsulated(string 192.168.8.102:60436, raklib\protocol\EncapsulatedPacket object, integer 0)
    [12:48:39] [Server thread/DEBUG]: #19 src/pocketmine/network/mcpe/RakLibInterface(84): raklib\server\ServerHandler->handlePacket()
    [12:48:39] [Server thread/DEBUG]: #20 src/pocketmine/network/Network(89): pocketmine\network\mcpe\RakLibInterface->process()
    [12:48:39] [Server thread/DEBUG]: #21 src/pocketmine/Server(2522): pocketmine\network\Network->processInterfaces()
    [12:48:39] [Server thread/DEBUG]: #22 src/pocketmine/Server(2274): pocketmine\Server->tick()
    [12:48:39] [Server thread/DEBUG]: #23 src/pocketmine/Server(2149): pocketmine\Server->tickProcessor()
    [12:48:39] [Server thread/DEBUG]: #24 src/pocketmine/Server(1737): pocketmine\Server->start()
    [12:48:39] [Server thread/DEBUG]: #25 src/pocketmine/PocketMine(554): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string C:\Users\Admin\Creative Cloud Files\Desktop\Lobby - DEV\, string C:\Users\Admin\Creative Cloud Files\Desktop\Lobby - DEV\plugins\)
    [12:48:39] [Server thread/DEBUG]: #26 C:/Users/Admin/Creative Cloud Files/Desktop/Lobby - DEV/PocketMine-MP.phar(1): require(string phar://C:/Users/Admin/Creative Cloud Files/Desktop/Lobby - DEV/PocketMine-MP.phar/src/pocketmine/PocketMine.php)
    
    This is the error. could someone help me out
     
  2. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    $link->link should be an EntityLink object, not an array.
     
    rektpixel likes this.
  3. rektpixel

    rektpixel Baby Zombie

    Messages:
    186
    I'm still unclear of what $link->link should be replaced with :/
     
  4. Eduardo

    Eduardo Baby Zombie

    Messages:
    100
    GitHub:
    xBeastMode
  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.