mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
Merge remote-tracking branch 'origin/stable'
This commit is contained in:
@ -98,6 +98,8 @@ use function base64_encode;
|
||||
use function count;
|
||||
use function fmod;
|
||||
use function implode;
|
||||
use function is_infinite;
|
||||
use function is_nan;
|
||||
use function json_decode;
|
||||
use function json_encode;
|
||||
use function json_last_error_msg;
|
||||
@ -153,6 +155,14 @@ class InGamePacketHandler extends PacketHandler{
|
||||
}
|
||||
|
||||
public function handleMovePlayer(MovePlayerPacket $packet) : bool{
|
||||
$rawPos = $packet->position;
|
||||
foreach([$rawPos->x, $rawPos->y, $rawPos->z, $packet->yaw, $packet->headYaw, $packet->pitch] as $float){
|
||||
if(is_infinite($float) || is_nan($float)){
|
||||
$this->session->getLogger()->debug("Invalid movement received, contains NAN/INF components");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$yaw = fmod($packet->yaw, 360);
|
||||
$pitch = fmod($packet->pitch, 360);
|
||||
if($yaw < 0){
|
||||
|
@ -49,25 +49,26 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
* ARG_FLAG_VALID | (type const)
|
||||
*/
|
||||
public const ARG_TYPE_INT = 0x01;
|
||||
public const ARG_TYPE_FLOAT = 0x02;
|
||||
public const ARG_TYPE_VALUE = 0x03;
|
||||
public const ARG_TYPE_WILDCARD_INT = 0x04;
|
||||
public const ARG_TYPE_OPERATOR = 0x05;
|
||||
public const ARG_TYPE_TARGET = 0x06;
|
||||
public const ARG_TYPE_FLOAT = 0x03;
|
||||
public const ARG_TYPE_VALUE = 0x04;
|
||||
public const ARG_TYPE_WILDCARD_INT = 0x05;
|
||||
public const ARG_TYPE_OPERATOR = 0x06;
|
||||
public const ARG_TYPE_TARGET = 0x07;
|
||||
public const ARG_TYPE_WILDCARD_TARGET = 0x08;
|
||||
|
||||
public const ARG_TYPE_FILEPATH = 0x0e;
|
||||
public const ARG_TYPE_FILEPATH = 0x10;
|
||||
|
||||
public const ARG_TYPE_STRING = 0x1d;
|
||||
public const ARG_TYPE_STRING = 0x20;
|
||||
|
||||
public const ARG_TYPE_POSITION = 0x25;
|
||||
public const ARG_TYPE_POSITION = 0x28;
|
||||
|
||||
public const ARG_TYPE_MESSAGE = 0x29;
|
||||
public const ARG_TYPE_MESSAGE = 0x2c;
|
||||
|
||||
public const ARG_TYPE_RAWTEXT = 0x2b;
|
||||
public const ARG_TYPE_RAWTEXT = 0x2e;
|
||||
|
||||
public const ARG_TYPE_JSON = 0x2f;
|
||||
public const ARG_TYPE_JSON = 0x32;
|
||||
|
||||
public const ARG_TYPE_COMMAND = 0x36;
|
||||
public const ARG_TYPE_COMMAND = 0x3f;
|
||||
|
||||
/**
|
||||
* Enums are a little different: they are composed as follows:
|
||||
|
@ -34,6 +34,11 @@ use function count;
|
||||
class CommandOutputPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::COMMAND_OUTPUT_PACKET;
|
||||
|
||||
public const TYPE_LAST = 1;
|
||||
public const TYPE_SILENT = 2;
|
||||
public const TYPE_ALL = 3;
|
||||
public const TYPE_DATA_SET = 4;
|
||||
|
||||
/** @var CommandOriginData */
|
||||
public $originData;
|
||||
/** @var int */
|
||||
@ -54,7 +59,7 @@ class CommandOutputPacket extends DataPacket implements ClientboundPacket{
|
||||
$this->messages[] = $this->getCommandMessage($in);
|
||||
}
|
||||
|
||||
if($this->outputType === 4){
|
||||
if($this->outputType === self::TYPE_DATA_SET){
|
||||
$this->unknownString = $in->getString();
|
||||
}
|
||||
}
|
||||
@ -85,7 +90,7 @@ class CommandOutputPacket extends DataPacket implements ClientboundPacket{
|
||||
$this->putCommandMessage($message, $out);
|
||||
}
|
||||
|
||||
if($this->outputType === 4){
|
||||
if($this->outputType === self::TYPE_DATA_SET){
|
||||
$out->putString($this->unknownString);
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +48,13 @@ class EventPacket extends DataPacket implements ClientboundPacket{
|
||||
public const TYPE_CAULDRON_BLOCK_USED = 15;
|
||||
public const TYPE_COMPOSTER_BLOCK_USED = 16;
|
||||
public const TYPE_BELL_BLOCK_USED = 17;
|
||||
public const TYPE_ACTOR_DEFINITION = 18;
|
||||
public const TYPE_RAID_UPDATE = 19;
|
||||
public const TYPE_PLAYER_MOVEMENT_ANOMALY = 20; //anti cheat
|
||||
public const TYPE_PLAYER_MOVEMENT_CORRECTED = 21;
|
||||
public const TYPE_HONEY_HARVESTED = 22;
|
||||
public const TYPE_TARGET_BLOCK_HIT = 23;
|
||||
public const TYPE_PIGLIN_BARTER = 24;
|
||||
|
||||
/** @var int */
|
||||
public $playerRuntimeId;
|
||||
|
@ -28,6 +28,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
|
||||
use pocketmine\network\mcpe\protocol\types\InputMode;
|
||||
use pocketmine\network\mcpe\protocol\types\PlayerAuthInputFlags;
|
||||
use pocketmine\network\mcpe\protocol\types\PlayMode;
|
||||
use function assert;
|
||||
|
||||
@ -60,6 +61,7 @@ class PlayerAuthInputPacket extends DataPacket implements ServerboundPacket{
|
||||
private $delta;
|
||||
|
||||
/**
|
||||
* @param int $inputFlags @see InputFlags
|
||||
* @param int $inputMode @see InputMode
|
||||
* @param int $playMode @see PlayMode
|
||||
* @param Vector3|null $vrGazeDirection only used when PlayMode::VR
|
||||
@ -111,6 +113,9 @@ class PlayerAuthInputPacket extends DataPacket implements ServerboundPacket{
|
||||
return $this->moveVecZ;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PlayerAuthInputFlags
|
||||
*/
|
||||
public function getInputFlags() : int{
|
||||
return $this->inputFlags;
|
||||
}
|
||||
|
@ -36,6 +36,9 @@ class SetTitlePacket extends DataPacket implements ClientboundPacket{
|
||||
public const TYPE_SET_SUBTITLE = 3;
|
||||
public const TYPE_SET_ACTIONBAR_MESSAGE = 4;
|
||||
public const TYPE_SET_ANIMATION_TIMES = 5;
|
||||
public const TYPE_SET_TITLE_JSON = 6;
|
||||
public const TYPE_SET_SUBTITLE_JSON = 7;
|
||||
public const TYPE_SET_ACTIONBAR_MESSAGE_JSON = 8;
|
||||
|
||||
/** @var int */
|
||||
public $type;
|
||||
|
75
src/network/mcpe/protocol/types/PlayerAuthInputFlags.php
Normal file
75
src/network/mcpe/protocol/types/PlayerAuthInputFlags.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?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\types;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\PlayerAuthInputPacket;
|
||||
|
||||
/**
|
||||
* These flags are used in PlayerAuthInputPacket's inputFlags field.
|
||||
* The flags should be written as
|
||||
* `flags |= (1 << flag)`
|
||||
* and read as
|
||||
* `(flags & (1 & flag)) !== 0`
|
||||
*
|
||||
* @see PlayerAuthInputPacket
|
||||
*/
|
||||
final class PlayerAuthInputFlags{
|
||||
public const ASCEND = 0;
|
||||
public const DESCEND = 1;
|
||||
public const NORTH_JUMP = 2;
|
||||
public const JUMP_DOWN = 3;
|
||||
public const SPRINT_DOWN = 4;
|
||||
public const CHANGE_HEIGHT = 5;
|
||||
public const JUMPING = 6;
|
||||
public const AUTO_JUMPING_IN_WATER = 7;
|
||||
public const SNEAKING = 8;
|
||||
public const SNEAK_DOWN = 9;
|
||||
public const UP = 10;
|
||||
public const DOWN = 11;
|
||||
public const LEFT = 12;
|
||||
public const RIGHT = 13;
|
||||
public const UP_LEFT = 14;
|
||||
public const UP_RIGHT = 15;
|
||||
public const WANT_UP = 16;
|
||||
public const WANT_DOWN = 17;
|
||||
public const WANT_DOWN_SLOW = 18;
|
||||
public const WANT_UP_SLOW = 19;
|
||||
public const SPRINTING = 20;
|
||||
public const ASCEND_SCAFFOLDING = 21;
|
||||
public const DESCEND_SCAFFOLDING = 22;
|
||||
public const SNEAK_TOGGLE_DOWN = 23;
|
||||
public const PERSIST_SNEAK = 24;
|
||||
public const START_SPRINTING = 25;
|
||||
public const STOP_SPRINTING = 26;
|
||||
public const START_SNEAKING = 27;
|
||||
public const STOP_SNEAKING = 28;
|
||||
public const START_SWIMMING = 29;
|
||||
public const STOP_SWIMMING = 30;
|
||||
public const START_JUMPING = 31;
|
||||
public const START_GLIDING = 32;
|
||||
public const STOP_GLIDING = 33;
|
||||
public const PERFORM_ITEM_INTERACTION = 34;
|
||||
public const PERFORM_BLOCK_ACTIONS = 35;
|
||||
public const PERFORM_ITEM_STACK_REQUEST = 36;
|
||||
}
|
Reference in New Issue
Block a user