Hey there. I'm trying to create an auto pickup plugin. That means if you break a block it doesn't drop but get's into your inventory. I'm working with the BlockBreakEvent.
i think something like this onBreak, get the item in the event, and add to inventory, if inv is full, do nothing, and send player Make some more space!
PHP: public function onBreak(BlockBreakEvent $event) { $event->setDrops(); $event->getPlayer()->getInventory->addItem(Item::get($event->getBlock()->getId()));} Tell me if it worked
even better, PHP: public function onBreak(BlockBreakEvent $event) { foreach($event->getDrops() as $drops) { $event->getPlayer()->getInventory()->addItem($drops); } $event->setDrops();}
But what if the player's inventory is full? Maybe this: PHP: //Make sure the priority is set to high and ignoreCancelled=truepublic function onBlockBreak(BlockBreakEvent $event) : void{ $event->setDrops($event->getPlayer()->getInventory()->addItem(...$event->getDrops()));}