if i cancelled the event when a actions' inventory is instance of PlayerInventory, the event will stop being called , it's random, after you make the problem happened, the event sometimes get called, sometimes not Here is the code to make the issue happens: PHP: use pocketmine\event\inventory\InventoryTransactionEvent;use pocketmine\inventory\transaction\action\SlotChangeAction;use pocketmine\inventory\PlayerInventory;public function onTransaction(InventoryTransactionEvent $ev) : void{ var_dump("Event called"); $acts = array_values($ev->getTransaction()->getActions()); if($acts[0] instanceof SlotChangeAction && $acts[1] instanceof SlotChangeAction){ if($acts[0]->getInventory() instanceof PlayerInventory || $acts[1]->getInventory() instanceof PlayerInventory){ $ev->setCancelled(); }} This issue only happens in the mc win10; You can place a chest with items inside on the server before running that code, then when you runs the server and the code So when you click the item, your cursor has the item,the console print "Event Called",when you put the item in your cursor into player inventory , the console still print "Event Called", but the item disppear both in your cursor and the inventory, for now it just the lag (if you close the inven then open again the item still there), after that, when you do again with other items, the console sometimes print, sometimes not, try to do it mutiple item , not only one im not sure it's just me or everyone get that or this problem is just like the item still in the cursor even the event is cancelled so can i fix this
$event->getTransaction()->getActions() does not maintain an order. You have to foreach over all actions.
$acts can have more then 2 values but in this case that's not the point causing the bug.if u stimulate the issue $acts only returns 2 values
Like I said, $event->getTransaction()->getActions() does not maintain an order. You are only fetching one action from the array of actions. You might as well be fetching a random action from the two (or more) actions in the array and checking if it satisfies your condition. That's how unreliable it is going to be if you aren't checking all actions. A foreach is unavoidable. https://github.com/Muqsit/InvMenu/blob/master/src/muqsit/invmenu/InvMenuEventHandler.php#L80 Try before criticizing ¯\_(ツ)_/¯