I tried this PHP: $item = Item::get(280, 0, $item->addEnchantment(Enchantment::getEnchantment(Enchantment::KNOCKBACK)->setLevel(1)); $item->setCustomName(TextFormat::GOLD.TextFormat::ITALIC.'KNOCKBACK'); $player->getInventory()->setItem(0, $item, TRUE); But it return: Code: [06:30:35] [Server thread/CRITICAL]: Could not execute task SkyZoneMC\OneLine\OLTask: Call to a member function setLevel() on null [06:30:35] [Server thread/CRITICAL]: Error: "Call to a member function setLevel() on null" (EXCEPTION) in "OneLine - SkyZoneMC/src/SkyZoneMC/OneLine/OneLine" at line 829 I dont know how to fix this ._.
Because it's PMMP. Check it https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/item/enchantment/Enchantment.php. You must correct it by yourself. Or wait updates
To make it clear: The knockback enchantment isn't registered yet as you can see here https://github.com/pmmp/PocketMine-...mine/item/enchantment/Enchantment.php#L89-L95
You can create new enchant and try add it to stick PHP: $item = Item::get(Item::STICK, 0, 1);$enchantment = new Enchantment(Enchantment::KNOCKBACK, "Knockback", 1, Enchantment::ACTIVATION_HELD, 0);$enchantment->setLevel(1);$item->addEnchantment($enchantment);$p->getInventory()->addItem($item);$p->getInventory()->addItem(Item::get(Item::ARROW, 0, 1));