I'm making a lucky blocks plugin and I'm trying to use the setDrops function to change the drops of the block to be the reward they get. So I need to know the proper way to use the setDrops function. This includes how to add multiple item drops and the amount of each drop. I'm guessing this would be the best way to do what I'm trying to achieve but if there is a better why i'm willing to give it a try. One more thing, I don't want to have the items go straight into the players inventory if possible. I want them to fall as an entity have make the player pick them up. Thanks for any help!
on BlockBreakEvent Code: if($event->getBlock()->getId ==/*block id*/){ $event->setDrops(/*items(s)*/); }
I have tried the time id's as well as item::stone for example like you showed and neither of these worked...
ok he's my basic code I used to test setDrops() PHP: public function onBlockBreak(BlockBreakEvent $event){ $player = $event->getPlayer(); $block = $event->getBlock(); $blockID = $block->getId(); if($blockID === 1){ $drops = array(1); $event->setDrops($drops); } } I tryed putting 1 where the variable $drops is but it said needs to be an array so i did this. When I do it this way it doesn't have any drops so i'm guessing it isn't item ID
PHP: public function drops(BlockBreakEvent $event){if($event->getBlock()->getID() === 56){$drops = array(Item::get(Item::DIAMOND_CHESTPLATE,0,1));$event->getDrops($event->setDrops($drops));} taken from my servercore