<commit_before><?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\protocol;

#include <rules/DataPacket.h>


class MovePlayerPacket extends PEPacket{
	const NETWORK_ID = Info::MOVE_PLAYER_PACKET;
	const PACKET_NAME = "MOVE_PLAYER_PACKET";

	const MODE_NORMAL = 0;
	const MODE_RESET = 1;
	const MODE_TELEPORT = 2;
	const MODE_ROTATION = 3;

	const TELEPORTATION_CAUSE_UNKNOWN = 0;
	const TELEPORTATION_CAUSE_PROJECTILE = 1;
	const TELEPORTATION_CAUSE_CHORUS_FRUIT = 2;
	const TELEPORTATION_CAUSE_COMMAND = 3;
	const TELEPORTATION_CAUSE_BEHAVIOR = 4;
	const TELEPORTATION_CAUSE_COUNT = 5; // ???

	public $eid;
	public $x;
	public $y;
	public $z;
	public $yaw;
	public $bodyYaw;
	public $pitch;
	public $mode = self::MODE_NORMAL;
	public $onGround;

	public function decode($playerProtocol){
		$this->getHeader($playerProtocol);
		$this->eid = $this->getVarInt();

		$this->x = $this->getLFloat();
		$this->y = $this->getLFloat();
		$this->z = $this->getLFloat();

		$this->pitch = $this->getLFloat();
		$this->yaw = $this->getLFloat();

		$this->bodyYaw = $this->getLFloat();
		$this->mode = $this->getByte();
		$this->onGround = $this->getByte() > 0;
	}

	public function encode($playerProtocol){
		$this->reset($playerProtocol);
		$this->putVarInt($this->eid);

		$this->putLFloat($this->x);
		$this->putLFloat($this->y);
		$this->putLFloat($this->z);
	
		$this->putLFloat($this->pitch);
		$this->putLFloat($this->yaw == 0 ? 0.1 : $this->yaw); //hack for 1.13 if send 0 client rotate to -180

		$this->putLFloat($this->bodyYaw);
		$this->putByte($this->mode);
		$this->putByte($this->onGround > 0);
		/** @todo do it right */
		$this->putVarInt(0); // riding runtime ID<commit_msg>take out 1.13 yaw hack<commit_after><?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\protocol;

#include <rules/DataPacket.h>


class MovePlayerPacket extends PEPacket{
	const NETWORK_ID = Info::MOVE_PLAYER_PACKET;
	const PACKET_NAME = "MOVE_PLAYER_PACKET";

	const MODE_NORMAL = 0;
	const MODE_RESET = 1;
	const MODE_TELEPORT = 2;
	const MODE_ROTATION = 3;

	const TELEPORTATION_CAUSE_UNKNOWN = 0;
	const TELEPORTATION_CAUSE_PROJECTILE = 1;
	const TELEPORTATION_CAUSE_CHORUS_FRUIT = 2;
	const TELEPORTATION_CAUSE_COMMAND = 3;
	const TELEPORTATION_CAUSE_BEHAVIOR = 4;
	const TELEPORTATION_CAUSE_COUNT = 5; // ???

	public $eid;
	public $x;
	public $y;
	public $z;
	public $yaw;
	public $bodyYaw;
	public $pitch;
	public $mode = self::MODE_NORMAL;
	public $onGround;

	public function decode($playerProtocol){
		$this->getHeader($playerProtocol);
		$this->eid = $this->getVarInt();

		$this->x = $this->getLFloat();
		$this->y = $this->getLFloat();
		$this->z = $this->getLFloat();

		$this->pitch = $this->getLFloat();
		$this->yaw = $this->getLFloat();

		$this->bodyYaw = $this->getLFloat();
		$this->mode = $this->getByte();
		$this->onGround = $this->getByte() > 0;
	}

	public function encode($playerProtocol){
		$this->reset($playerProtocol);
		$this->putVarInt($this->eid);

		$this->putLFloat($this->x);
		$this->putLFloat($this->y);
		$this->putLFloat($this->z);
	
		$this->putLFloat($this->pitch);
		$this->putLFloat($this->yaw);

		$this->putLFloat($this->bodyYaw);
		$this->putByte($this->mode);
		$this->putByte($this->onGround > 0);
		/** @todo do it right */
		$this->putVarInt(0); // riding runtime ID
{'fraction_non_alphanumeric': 0.17780149413020277, 'fraction_numerical': 0.008751334044823906, 'mean_word_length': 3.1839285714285714, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 88, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1081639', 'n_tokens_mistral': 1937, 'n_tokens_neox': 1800, 'n_words': 328}