Dylan K. Taylor 3463bea932 add defaults to MobEffectPacket
these fields may be unspecified if we are only removing effects
2017-06-03 15:21:24 +01:00

67 lines
1.7 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/
*
*
*/
namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\NetworkSession;
class MobEffectPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::MOB_EFFECT_PACKET;
const EVENT_ADD = 1;
const EVENT_MODIFY = 2;
const EVENT_REMOVE = 3;
public $eid;
public $eventId;
public $effectId;
public $amplifier = 0;
public $particles = true;
public $duration = 0;
public function decode(){
$this->eid = $this->getEntityRuntimeId();
$this->eventId = $this->getByte();
$this->effectId = $this->getVarInt();
$this->amplifier = $this->getVarInt();
$this->particles = $this->getBool();
$this->duration = $this->getVarInt();
}
public function encode(){
$this->reset();
$this->putEntityRuntimeId($this->eid);
$this->putByte($this->eventId);
$this->putVarInt($this->effectId);
$this->putVarInt($this->amplifier);
$this->putBool($this->particles);
$this->putVarInt($this->duration);
}
public function handle(NetworkSession $session) : bool{
return $session->handleMobEffect($this);
}
}