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

InventoryTransactionEvent

Comments in 'Plugin Development' started by Bluplayz, Feb 10, 2016.

  1. Bluplayz
    Offline

    Bluplayz Active Member

    Joined:
    Aug 20, 2015
    Posts:
    74
    Minecraft User:
    Bluplayz
    Did anyone knows how to get the slot (int) From the item in the chest that i want to transfer?
  2. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    yes...example:
    PHP:
            foreach ($ev->getTransaction()->getTransactions() as $baseTransaction) {
                if (
    $baseTransaction->getInventory() instanceof \pocketmine\inventory\PlayerInventory) {
                    
    $plInvSlot $baseTransaction->getSlot();
                    
    $plFromItem = clone $baseTransaction->getSourceItem();
                    
    $plToItem = clone $baseTransaction->getTargetItem();
                } elseif (
    $baseTransaction->getInventory() instanceof \pocketmine\inventory\ChestInventory) {
                    
    $chInvSlot $baseTransaction->getSlot();
                    
    $chFromItem = clone $baseTransaction->getSourceItem();
                    
    $chToItem = clone $baseTransaction->getTargetItem();
                } else {
                    break;
                }
            }
  3. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
  4. Bluplayz
    Offline

    Bluplayz Active Member

    Joined:
    Aug 20, 2015
    Posts:
    74
    Minecraft User:
    Bluplayz
    THX :D but i search already but nothing was found xD what is $event->getTransaction() ? In the event class there a very empty xD
  5. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    is a pocketmine/inventory/SimpleTransactionGroup

Share This Page

Advertisement