Hello, i want to make a consume event with give effect but it's don't work ans i get a "class EffectInstance not found". You can view my code : PHP: <?phpnamespace Fritures\ItemCore\Ajouts;use Fritures\ItemCore\Main;use pocketmine\event\Listener;use pocketmine\Player;use pocketmine\item\Item;use pocketmine\entity\Effect;use pocketmine\entity\EffectInstance;use pocketmine\level\sound\AnvilFallSound;use pocketmine\event\player\PlayerItemConsumeEvent;class GoldFish implements Listener { private $plugin = null; public function __construct(Main $plugin){ $this->plugin = $plugin; } public function getPlugin() : ?Main { return $this->plugin; } public function onConsume(PlayerItemConsumeEvent $event){ $item = $event->getItem(); if($item->getId() == 412){ $player = $event->getPlayer(); $player->sendPopup("§l[§r§9!!!§f§l]§r§eMiam que c'est bon !"); $player->getLevel()->addSound(new AnvilFallSound($player)); $speed = new EffectInstance(Effect::getEffect(1),1,2000,true); $player->addEffect($speed); } }}?>
Salut! Je suppose que tu est francais! Pour donner un effet speed à un joueur tu as juste à utilisé: PHP: $speed = Effect::getEffect(1); //l'Id de l'effet$speed->setDuration(6273); //La durée de l'effet$speed->setAmplifier(2); //Amplifier l'effet$speed->setVisible(true);$player->addEffect($speed);
Un ami dev m'a dit pour le construct de mettre ça et sa me permet aussi de pas avoir des erreurs de merde