When I was working on my relic plugin, you were able to get a relic in every stone you mine but I'm trying to make it in every 50 blocks, is that possible? PHP: public function onBreak(BlockBreakEvent $event) { if($event->getBlock()->getId() == 1 && mt_rand(1, 50)) { $player = $event->getPlayer(); $name = $player->getName(); $tier1 = Item::get(Item::NETHER_STAR, 0, 1); $tier1->setCustomName(TF::RESET . TF::GOLD . TF::BOLD . "Ancient Relic" . TF::RESET . PHP_EOL . TF::GRAY . " * An ancient relic found by mining" . PHP_EOL . TF::GRAY . " * Tap anywhere to see what it holds"); $player->getInventory()->addItem($tier1);
You can change mt_rand(1, 50) to mt_rand(-49, 1) since negative numbers and zeroes are equivalent to false. Or a cleaner method... PHP: if(mt_rand(1, 50) === 1){ //mt_rand(1, 50) generates a rand number between 1 and 50. //There's 1 in a 50 chance (ignoring "psuedo" factors) that mt_rand(1, 50) //will return 1.}