Im having trouble with inventory transactionevent, im trying to cancel it but its not working. Send Inventory code: PHP: $player = $p; $block = Block::get(54,27); $player->getLevel()->setBlock(new Vector3($player->x, $player->y - 4, $player->z), $block, true, true); $nbt = new CompoundTag("", [ new ListTag("Items", []), new StringTag("id", Tile::CHEST), new StringTag("CustomName", "My custom chest"), new IntTag("x", floor($player->x)), new IntTag("y", floor($player->y) - 4), new IntTag("z", floor($player->z)) ]); $nbt->Items->setTagType(NBT::TAG_Compound); $tile = Tile::createTile('Chest', $player->getLevel()->getChunk($player->getX() >> 4, $player->getZ() >> 4), $nbt); $tile->getInventory()->setItem(5, Item::get(384, 0, 1)); $tile->getInventory()->setItem(4, Item::get(384, 0, 1)); $tile->getInventory()->setSize(8); $player->addWindow($tile->getInventory()); TransactionCode: PHP: public function onTransaction(InventoryTransactionEvent $event){ $transactions = $event->getTransaction()->getTransactions(); $player = null; $chestinv = null; $action = null; foreach($transactions as $transaction){ if(($inv = $transaction->getInventory()) instanceof PlayerInventory){ foreach($inv->getViewers() as $assumed) if($assumed instanceof Player) { if($inv->getTargetItem()->getId() === 384) { $event->setCancelled(true); $player = $assumed; $chestinv = $inv; } }}}}
Help! I need somebody. Help!.. not just anybody.. Help!.. I need someone. Heeelllppp!! sorry I can't help you but maybe if you tagged a staff member....
I've had staff and verified people help me before on the forums and they are definitely more qualified to answer questions than a lot of people on the forum not that there gonna be excited to answer a question or even that they will but they might but hey idk if your desperate for help it might work
Can you at least tell us wat doesnt work? Does the inventory show up? Does the items get transferred? Can you use the transferred item? Try doing a var_dump where you cancel the event, if it shows up but item is transferred then there is something wrong with your server core
if(($inv = $transaction->getInventory()) instanceof PlayerInventory){, this is causing it, if u dont have this line, it cancels