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

InventoryTransactionPacket Problem

Discussion in 'Development' started by xinghao2003, Sep 22, 2017.

  1. xinghao2003

    xinghao2003 Creeper

    Messages:
    5
    GitHub:
    xinghao2003
    How can I get target in InventoryTransactionPacket like before in InteractPacket
     
  2. Aviv

    Aviv Baby Zombie

    Messages:
    156
    PHP:
    use pocketmine\network\mcpe\protocol\InventoryTransactionPacket;

    public function 
    DataPacketReceive(DataPacketReceiveEvent $event) {
      
    $pk $event->getPacket();
      if(
    $pk instanceof InventoryTransactionPacket){
        if(
    $pk->transactionType === InventoryTransactionPacket::TYPE_USE_ITEM_ON_ENTITY){
          if(
    $pk->trData->actionType === InventoryTransactionPacket::USE_ITEM_ON_ENTITY_ACTION_INTERACT){
            
    $data $pk->trData;
            
    $itemUsedOnEntity $data->itemInHand;
            
    $entityId $data->entityRuntimeId;
            
    $vector1 $data->vector1// what are those?!
            
    $vector2 $data->vector2// what are those?! are these meant to be player and entity positions?
            //code
          
    }
        }
      }
    }
     
  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.