mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-08-30 15:01:19 +00:00
73 lines
2.1 KiB
PHP
73 lines
2.1 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\protocol\serializer\PacketSerializer;
|
|
|
|
class CameraShakePacket extends DataPacket implements ClientboundPacket{
|
|
public const NETWORK_ID = ProtocolInfo::CAMERA_SHAKE_PACKET;
|
|
|
|
public const TYPE_POSITIONAL = 0;
|
|
public const TYPE_ROTATIONAL = 1;
|
|
|
|
/** @var float */
|
|
private $intensity;
|
|
/** @var float */
|
|
private $duration;
|
|
/** @var int */
|
|
private $shakeType;
|
|
|
|
public static function create(float $intensity, float $duration, int $shakeType) : self{
|
|
$result = new self;
|
|
$result->intensity = $intensity;
|
|
$result->duration = $duration;
|
|
$result->shakeType = $shakeType;
|
|
return $result;
|
|
}
|
|
|
|
public function getIntensity() : float{ return $this->intensity; }
|
|
|
|
public function getDuration() : float{ return $this->duration; }
|
|
|
|
public function getShakeType() : int{ return $this->shakeType; }
|
|
|
|
protected function decodePayload(PacketSerializer $in) : void{
|
|
$this->intensity = $in->getLFloat();
|
|
$this->duration = $in->getLFloat();
|
|
$this->shakeType = $in->getByte();
|
|
}
|
|
|
|
protected function encodePayload(PacketSerializer $out) : void{
|
|
$out->putLFloat($this->intensity);
|
|
$out->putLFloat($this->duration);
|
|
$out->putByte($this->shakeType);
|
|
}
|
|
|
|
public function handle(PacketHandlerInterface $handler) : bool{
|
|
return $handler->handleCameraShake($this);
|
|
}
|
|
}
|