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

InventoryTransactionPacket

Discussion in 'Plugin Help' started by Herox, Apr 14, 2021.

  1. Herox

    Herox Creeper

    Messages:
    4
    Error: "Undefined property: pocketmine\network\mcpe\protocol\InventoryTransactionPacket::$transactionType" (EXCEPTION) in "pmsrc/src/pocketmine/network/mcpe/protocol/DataPacket" at line 195

    #0 plugins/VortexCore/src/core/entity/npc/NPCListener(75): pocketmine\network\mcpe\protocol\DataPacket->__get(string[15] transactionType)
    LINE 75:
    PHP:
    [/B][/U][/B]
    [
    B][U][B]if($pk instanceof InventoryTransactionPacket and $pk->transactionType === InventoryTransactionPacket::TYPE_USE_ITEM_ON_ENTITY) {


    PHP:
    public function onDataPacketReceive(DataPacketReceiveEvent $event): void {
        
    $pk $event->getPacket();
        
    $player $event->getPlayer();
        if(!
    $player instanceof VortexPlayer) {
            return;
        }
        if(
    $pk instanceof InventoryTransactionPacket and $pk->transactionType === InventoryTransactionPacket::TYPE_USE_ITEM_ON_ENTITY) {
            
    $npc $this->core->getEntityManager()->getNPC($pk->trData->entityRuntimeId);
            if(
    $npc === null) {
                return;
            }
            
    $callable $npc->getCallable();
            
    $callable($player);
        }
    }

     
  2. DavyCraft648

    DavyCraft648 Spider Jockey

    Messages:
    40
    GitHub:
    DavyCraft648
    PHP:
    if($pk instanceof InventoryTransactionPacket and $pk->trData->getTypeId() === InventoryTransactionPacket::TYPE_USE_ITEM_ON_ENTITY) {
        
    $npc $this->core->getEntityManager()->getNPC($pk->trData->getEntityRuntimeId());
        if(
    $npc === null) {
            return;
        }
        
    $callable $npc->getCallable();
        
    $callable($player);
    }
    Reference:
    https://github.com/pmmp/PocketMine-.../mcpe/protocol/InventoryTransactionPacket.php
    https://github.com/pmmp/PocketMine-.../protocol/types/inventory/TransactionData.php
    https://github.com/pmmp/PocketMine-.../inventory/UseItemOnEntityTransactionData.php
     
    Last edited: Apr 14, 2021
  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.