Dylan K. Taylor 64ecc373be Split up session base logic and packet handling
this will allow for mutable packet handlers which can be used to cleanly implement multi-stage game sessions.
2018-07-20 12:36:44 +01:00

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);
}
}