I have a problem, when I try to enchant a thing, it kicks me. Screen from the logs attached. The code is below. $rinstruments = array(15, 16, 18, 17); $instruments = array(256, 257, 258, 269, 270, 271, 273, 274, 275, 277, 278, 279, 284, 285, 286); if(in_array($item->getId(), $instruments)){ for($i = 0; $i != mt_rand(2, 3); $i++){ $item->addEnchantment(new EnchantmentInstance(Enchantment::getEnchantment($rinstruments[array_rand($rinstruments)]), mt_rand(1, 2))); $player->getInventory()->setItemInHand($item); }}
If you are trying to take a random element of $rinstruments, try this : §rinstruments[random_int(0,3)] Or replace the 3 by : count($rinstruments) If you don't want to take a random element of that, then I don't understand the code. Ima beginner in php
This occurs because the enchantment with the ID 18 (fortune) isn't implemented in PocketMine yet. See here: https://github.com/pmmp/PocketMine-...c/pocketmine/item/enchantment/Enchantment.php