Im a new php dev... In training... I would like to know how to set it up to where when u are holding or wearing an item it gives u effects... Such as haste ect. I figured it out $player->addEffect(Effect::getEffect(Effect::REGENERATION)->setAmplifier(3)->setDuration(100 * 20));
It is better to use an event to hold an item in your hand, PHP: /** * @param PlayerItemHeldEvent $event */ public function onPlayerHeld(PlayerItemHeldEvent $event) { // 280 = stick if($event->getItem()->getId() == 280) { $event->getPlayer()->addEffect(Effect::getEffect(Effect::REGENERATION)); } } but if a player has to wear a item, is a better schedule repeating task. PHP: <?php/** * Class CheckPlayerTask */class CheckPlayerTask extends \pocketmine\scheduler\PluginTask { /** * @param int $currentTick */ public function onRun(int $currentTick) { foreach (\pocketmine\Server::getInstance()->getOnlinePlayers() as $player) { if($player->getInventory()->contains(\pocketmine\item\Item::get(\pocketmine\item\Item::CARROT))) { $player->addEffect(\pocketmine\entity\Effect::getEffect(\pocketmine\entity\Effect::JUMP)->setDuration(20)); } } }}