PHP: $item = Item::get(313,0,1); //diamond boots$item->addEnchantment(Enchantment::getEnchantment(2)->setLevel(1); //this adds FeatherFalling to the boot and sets the enchantment level to 1
This is wrong! The new addEnchantment() param is the class EnchantmentInstance! Heres what it should look like PHP: $enchantment = Enchantment::getEnchantment(0);$ench = new EnchantmentInstance($enchantment, $lvl);/** @var Item */$item;$item->addEnchantment($ench); getEnchantment() function: https://github.com/pmmp/PocketMine-...ketmine/item/enchantment/Enchantment.php#L109 EnchantmentInstance class: https://github.com/pmmp/PocketMine-...mine/item/enchantment/EnchantmentInstance.php addEnchantment() function: https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/item/Item.php#L363 Btw there are only 3 enchants currently registered in PMMP! ;P
I use it that way and It works perfectly fine xD and also you're my teacher bish -.- XD you so evil -.- lml
PHP: use pocketmine\Server;use pocketmine\Player;use pocketmine\item\Item;use pocketmine\inventory\Inventory;use pocketmine\item\enchantment\Enchantment;use pocketmine\item\enchantment\EnchantmentInstance;$e = Enchantment::getEnchantment((int) 0); //0 is Enchant$item = Item::get(1,0,1) //stone$item->addEnchantment(new EnchantmentInstance($e, (int) 2)); //2 is level$sender->getInventory()->addItem($item); //I use $sender it just for Player, CommandSender , etc...