use pocketmine\network\mcpe\handler\PacketHandler; class MobEffectPacket extends DataPacket implements ClientboundPacket{ public const NETWORK_ID = ProtocolInfo::MOB_EFFECT_PACKET; public const EVENT_ADD = 1; public const EVENT_MODIFY = 2; public const EVENT_REMOVE = 3; /** @var int */ public $entityRuntimeId; /** @var int */ public $eventId; /** @var int */ public $effectId; /** @var int */ public $amplifier = 0; /** @var bool */ public $particles = true; /** @var int */ public $duration = 0; public static function add(int $entityRuntimeId, bool $replace, int $effectId, int $amplifier, bool $particles, int $duration) : self{ $result = new self; $result->eventId = $replace ? self::EVENT_MODIFY : self::EVENT_ADD; $result->entityRuntimeId = $entityRuntimeId; $result->effectId = $effectId; $result->amplifier = $amplifier; $result->particles = $particles; $result->duration = $duration; return $result; } public static function remove(int $entityRuntimeId, int $effectId) : self{ $pk = new self; $pk->eventId = self::EVENT_REMOVE; $pk->entityRuntimeId = $entityRuntimeId; $pk->effectId = $effectId; return $pk; } protected function decodePayload() : void{ $this->entityRuntimeId = $this->getEntityRuntimeId(); $this->eventId = $this->getByte(); $this->effectId = $this->getVarInt(); $this->amplifier = $this->getVarInt(); $this->particles = $this->getBool(); $this->duration = $this->getVarInt(); } protected function encodePayload() : void{ $this->putEntityRuntimeId($this->entityRuntimeId); $this->putByte($this->eventId); $this->putVarInt($this->effectId); $this->putVarInt($this->amplifier); $this->putBool($this->particles); $this->putVarInt($this->duration); } public function handle(PacketHandler $handler) : bool{ return $handler->handleMobEffect($this); } }