mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-20 04:33:59 +00:00
this will allow for mutable packet handlers which can be used to cleanly implement multi-stage game sessions.
73 lines
1.9 KiB
PHP
73 lines
1.9 KiB
PHP
<?php
|
|
|
|
/*
|
|
*
|
|
* ____ _ _ __ __ _ __ __ ____
|
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* @author PocketMine Team
|
|
* @link http://www.pocketmine.net/
|
|
*
|
|
*
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace pocketmine\network\mcpe\protocol;
|
|
|
|
#include <rules/DataPacket.h>
|
|
|
|
|
|
use pocketmine\network\mcpe\handler\SessionHandler;
|
|
|
|
class MobEffectPacket extends DataPacket{
|
|
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;
|
|
|
|
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(SessionHandler $handler) : bool{
|
|
return $handler->handleMobEffect($this);
|
|
}
|
|
}
|