mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 00:07:30 +00:00
Protocol changes for 1.17.40
This commit is contained in:
parent
ead9aae23c
commit
70636f6eb4
@ -116,6 +116,7 @@ use pocketmine\network\mcpe\protocol\NpcDialoguePacket;
|
||||
use pocketmine\network\mcpe\protocol\NpcRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\OnScreenTextureAnimationPacket;
|
||||
use pocketmine\network\mcpe\protocol\PacketViolationWarningPacket;
|
||||
use pocketmine\network\mcpe\protocol\PassengerJumpPacket;
|
||||
use pocketmine\network\mcpe\protocol\PhotoInfoRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\PhotoTransferPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayerActionPacket;
|
||||
@ -144,7 +145,6 @@ use pocketmine\network\mcpe\protocol\ResourcePackDataInfoPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePacksInfoPacket;
|
||||
use pocketmine\network\mcpe\protocol\ResourcePackStackPacket;
|
||||
use pocketmine\network\mcpe\protocol\RespawnPacket;
|
||||
use pocketmine\network\mcpe\protocol\RiderJumpPacket;
|
||||
use pocketmine\network\mcpe\protocol\ScriptCustomEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\ServerSettingsRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\ServerSettingsResponsePacket;
|
||||
@ -178,6 +178,8 @@ use pocketmine\network\mcpe\protocol\StopSoundPacket;
|
||||
use pocketmine\network\mcpe\protocol\StructureBlockUpdatePacket;
|
||||
use pocketmine\network\mcpe\protocol\StructureTemplateDataRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\StructureTemplateDataResponsePacket;
|
||||
use pocketmine\network\mcpe\protocol\SubChunkPacket;
|
||||
use pocketmine\network\mcpe\protocol\SubChunkRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\SubClientLoginPacket;
|
||||
use pocketmine\network\mcpe\protocol\SyncActorPropertyPacket;
|
||||
use pocketmine\network\mcpe\protocol\TakeItemActorPacket;
|
||||
@ -272,7 +274,7 @@ abstract class NetworkSession{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleRiderJump(RiderJumpPacket $packet) : bool{
|
||||
public function handlePassengerJump(PassengerJumpPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -871,4 +873,12 @@ abstract class NetworkSession{
|
||||
public function handlePhotoInfoRequest(PhotoInfoRequestPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSubChunk(SubChunkPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSubChunkRequest(SubChunkRequestPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ class PacketPool{
|
||||
static::registerPacket(new TakeItemActorPacket());
|
||||
static::registerPacket(new MoveActorAbsolutePacket());
|
||||
static::registerPacket(new MovePlayerPacket());
|
||||
static::registerPacket(new RiderJumpPacket());
|
||||
static::registerPacket(new PassengerJumpPacket());
|
||||
static::registerPacket(new UpdateBlockPacket());
|
||||
static::registerPacket(new AddPaintingPacket());
|
||||
static::registerPacket(new TickSyncPacket());
|
||||
@ -204,6 +204,8 @@ class PacketPool{
|
||||
static::registerPacket(new CreatePhotoPacket());
|
||||
static::registerPacket(new UpdateSubChunkBlocksPacket());
|
||||
static::registerPacket(new PhotoInfoRequestPacket());
|
||||
static::registerPacket(new SubChunkPacket());
|
||||
static::registerPacket(new SubChunkRequestPacket());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,8 +27,8 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class RiderJumpPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::RIDER_JUMP_PACKET;
|
||||
class PassengerJumpPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::PASSENGER_JUMP_PACKET;
|
||||
|
||||
/** @var int */
|
||||
public $jumpStrength; //percentage
|
||||
@ -41,7 +41,7 @@ class RiderJumpPacket extends DataPacket{
|
||||
$this->putVarInt($this->jumpStrength);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleRiderJump($this);
|
||||
public function handle(NetworkSession $handler) : bool{
|
||||
return $handler->handlePassengerJump($this);
|
||||
}
|
||||
}
|
@ -37,11 +37,11 @@ interface ProtocolInfo{
|
||||
*/
|
||||
|
||||
/** Actual Minecraft: PE protocol version */
|
||||
public const CURRENT_PROTOCOL = 465;
|
||||
public const CURRENT_PROTOCOL = 471;
|
||||
/** Current Minecraft PE version reported by the server. This is usually the earliest currently supported version. */
|
||||
public const MINECRAFT_VERSION = 'v1.17.30';
|
||||
public const MINECRAFT_VERSION = 'v1.17.40';
|
||||
/** Version number sent to clients in ping responses. */
|
||||
public const MINECRAFT_VERSION_NETWORK = '1.17.30';
|
||||
public const MINECRAFT_VERSION_NETWORK = '1.17.40';
|
||||
|
||||
public const LOGIN_PACKET = 0x01;
|
||||
public const PLAY_STATUS_PACKET = 0x02;
|
||||
@ -62,7 +62,7 @@ interface ProtocolInfo{
|
||||
public const TAKE_ITEM_ACTOR_PACKET = 0x11;
|
||||
public const MOVE_ACTOR_ABSOLUTE_PACKET = 0x12;
|
||||
public const MOVE_PLAYER_PACKET = 0x13;
|
||||
public const RIDER_JUMP_PACKET = 0x14;
|
||||
public const PASSENGER_JUMP_PACKET = 0x14;
|
||||
public const UPDATE_BLOCK_PACKET = 0x15;
|
||||
public const ADD_PAINTING_PACKET = 0x16;
|
||||
public const TICK_SYNC_PACKET = 0x17;
|
||||
@ -216,5 +216,7 @@ interface ProtocolInfo{
|
||||
public const CREATE_PHOTO_PACKET = 0xab;
|
||||
public const UPDATE_SUB_CHUNK_BLOCKS_PACKET = 0xac;
|
||||
public const PHOTO_INFO_REQUEST_PACKET = 0xad;
|
||||
public const SUB_CHUNK_PACKET = 0xae;
|
||||
public const SUB_CHUNK_REQUEST_PACKET = 0xaf;
|
||||
|
||||
}
|
||||
|
109
src/pocketmine/network/mcpe/protocol/SubChunkPacket.php
Normal file
109
src/pocketmine/network/mcpe/protocol/SubChunkPacket.php
Normal file
@ -0,0 +1,109 @@
|
||||
<?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\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\types\SubChunkPacketHeightMapInfo;
|
||||
use pocketmine\network\mcpe\protocol\types\SubChunkPacketHeightMapType;
|
||||
|
||||
class SubChunkPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::SUB_CHUNK_PACKET;
|
||||
|
||||
private int $dimension;
|
||||
private int $subChunkX;
|
||||
private int $subChunkY;
|
||||
private int $subChunkZ;
|
||||
private string $data;
|
||||
private int $requestResult;
|
||||
private ?SubChunkPacketHeightMapInfo $heightMapData = null;
|
||||
|
||||
public static function create(int $dimension, int $subChunkX, int $subChunkY, int $subChunkZ, string $data, int $requestResult, ?SubChunkPacketHeightMapInfo $heightMapData) : self{
|
||||
$result = new self;
|
||||
$result->dimension = $dimension;
|
||||
$result->subChunkX = $subChunkX;
|
||||
$result->subChunkY = $subChunkY;
|
||||
$result->subChunkZ = $subChunkZ;
|
||||
$result->data = $data;
|
||||
$result->requestResult = $requestResult;
|
||||
$result->heightMapData = $heightMapData;
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getDimension() : int{ return $this->dimension; }
|
||||
|
||||
public function getSubChunkX() : int{ return $this->subChunkX; }
|
||||
|
||||
public function getSubChunkY() : int{ return $this->subChunkY; }
|
||||
|
||||
public function getSubChunkZ() : int{ return $this->subChunkZ; }
|
||||
|
||||
public function getData() : string{ return $this->data; }
|
||||
|
||||
public function getRequestResult() : int{ return $this->requestResult; }
|
||||
|
||||
public function getHeightMapData() : ?SubChunkPacketHeightMapInfo{ return $this->heightMapData; }
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->dimension = $this->getVarInt();
|
||||
$this->subChunkX = $this->getVarInt();
|
||||
$this->subChunkY = $this->getVarInt();
|
||||
$this->subChunkZ = $this->getVarInt();
|
||||
$this->data = $this->getString();
|
||||
$this->requestResult = $this->getVarInt();
|
||||
$heightMapDataType = $this->getByte();
|
||||
$this->heightMapData = match($heightMapDataType){
|
||||
SubChunkPacketHeightMapType::NO_DATA => null,
|
||||
SubChunkPacketHeightMapType::DATA => SubChunkPacketHeightMapInfo::read($this),
|
||||
SubChunkPacketHeightMapType::ALL_TOO_HIGH => SubChunkPacketHeightMapInfo::allTooHigh(),
|
||||
SubChunkPacketHeightMapType::ALL_TOO_LOW => SubChunkPacketHeightMapInfo::allTooLow(),
|
||||
default => throw new \UnexpectedValueException("Unknown heightmap data type $heightMapDataType")
|
||||
};
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putVarInt($this->dimension);
|
||||
$this->putVarInt($this->subChunkX);
|
||||
$this->putVarInt($this->subChunkY);
|
||||
$this->putVarInt($this->subChunkZ);
|
||||
$this->putString($this->data);
|
||||
$this->putVarInt($this->requestResult);
|
||||
if($this->heightMapData === null){
|
||||
$this->putByte(SubChunkPacketHeightMapType::NO_DATA);
|
||||
}elseif($this->heightMapData->isAllTooLow()){
|
||||
$this->putByte(SubChunkPacketHeightMapType::ALL_TOO_LOW);
|
||||
}elseif($this->heightMapData->isAllTooHigh()){
|
||||
$this->putByte(SubChunkPacketHeightMapType::ALL_TOO_HIGH);
|
||||
}else{
|
||||
$heightMapData = $this->heightMapData; //avoid PHPStan purity issue
|
||||
$this->putByte(SubChunkPacketHeightMapType::DATA);
|
||||
$heightMapData->write($this);
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $handler) : bool{
|
||||
return $handler->handleSubChunk($this);
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
<?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\NetworkSession;
|
||||
|
||||
class SubChunkRequestPacket extends DataPacket/* implements ServerboundPacket*/{
|
||||
public const NETWORK_ID = ProtocolInfo::SUB_CHUNK_REQUEST_PACKET;
|
||||
|
||||
private int $dimension;
|
||||
private int $subChunkX;
|
||||
private int $subChunkY;
|
||||
private int $subChunkZ;
|
||||
|
||||
public static function create(int $dimension, int $subChunkX, int $subChunkY, int $subChunkZ) : self{
|
||||
$result = new self;
|
||||
$result->dimension = $dimension;
|
||||
$result->subChunkX = $subChunkX;
|
||||
$result->subChunkY = $subChunkY;
|
||||
$result->subChunkZ = $subChunkZ;
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getDimension() : int{ return $this->dimension; }
|
||||
|
||||
public function getSubChunkX() : int{ return $this->subChunkX; }
|
||||
|
||||
public function getSubChunkY() : int{ return $this->subChunkY; }
|
||||
|
||||
public function getSubChunkZ() : int{ return $this->subChunkZ; }
|
||||
|
||||
protected function decodePayload() : void{
|
||||
$this->dimension = $this->getVarInt();
|
||||
$this->subChunkX = $this->getVarInt();
|
||||
$this->subChunkY = $this->getVarInt();
|
||||
$this->subChunkZ = $this->getVarInt();
|
||||
}
|
||||
|
||||
protected function encodePayload() : void{
|
||||
$this->putVarInt($this->dimension);
|
||||
$this->putVarInt($this->subChunkX);
|
||||
$this->putVarInt($this->subChunkY);
|
||||
$this->putVarInt($this->subChunkZ);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $handler) : bool{
|
||||
return $handler->handleSubChunkRequest($this);
|
||||
}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
<?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\NetworkBinaryStream;
|
||||
use pocketmine\utils\Binary;
|
||||
use function array_fill;
|
||||
use function count;
|
||||
|
||||
class SubChunkPacketHeightMapInfo{
|
||||
|
||||
/**
|
||||
* @param int[] $heights ZZZZXXXX key bit order
|
||||
* @phpstan-param list<int> $heights
|
||||
*/
|
||||
public function __construct(private array $heights){
|
||||
if(count($heights) !== 256){
|
||||
throw new \InvalidArgumentException("Expected exactly 256 heightmap values");
|
||||
}
|
||||
}
|
||||
|
||||
/** @return int[] */
|
||||
public function getHeights() : array{ return $this->heights; }
|
||||
|
||||
public function getHeight(int $x, int $z) : int{
|
||||
return $this->heights[(($z & 0xf) << 4) | ($x & 0xf)];
|
||||
}
|
||||
|
||||
public static function read(NetworkBinaryStream $in) : self{
|
||||
$heights = [];
|
||||
for($i = 0; $i < 256; ++$i){
|
||||
$heights[] = Binary::signByte($in->getByte());
|
||||
}
|
||||
return new self($heights);
|
||||
}
|
||||
|
||||
public function write(NetworkBinaryStream $out) : void{
|
||||
for($i = 0; $i < 256; ++$i){
|
||||
$out->putByte(Binary::unsignByte($this->heights[$i]));
|
||||
}
|
||||
}
|
||||
|
||||
public static function allTooLow() : self{
|
||||
return new self(array_fill(0, 256, -1));
|
||||
}
|
||||
|
||||
public static function allTooHigh() : self{
|
||||
return new self(array_fill(0, 256, 16));
|
||||
}
|
||||
|
||||
public function isAllTooLow() : bool{
|
||||
foreach($this->heights as $height){
|
||||
if($height >= 0){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isAllTooHigh() : bool{
|
||||
foreach($this->heights as $height){
|
||||
if($height <= 15){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?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;
|
||||
|
||||
final class SubChunkPacketHeightMapType{
|
||||
|
||||
public const NO_DATA = 0;
|
||||
public const DATA = 1;
|
||||
public const ALL_TOO_HIGH = 2;
|
||||
public const ALL_TOO_LOW = 3;
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
<?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;
|
||||
|
||||
final class SubChunkRequestResult{
|
||||
|
||||
public const SUCCESS = 1;
|
||||
//why even respond at all in these cases? ...
|
||||
public const NO_SUCH_CHUNK = 2;
|
||||
public const WRONG_DIMENSION = 3;
|
||||
public const NULL_PLAYER = 4;
|
||||
public const Y_INDEX_OUT_OF_BOUNDS = 5;
|
||||
}
|
@ -1 +1 @@
|
||||
Subproject commit 19569dd729970e161a24b574b41c06a5e064ab81
|
||||
Subproject commit f29b7be8fa3046d2ee4c6421485b97b3f5b07774
|
Loading…
x
Reference in New Issue
Block a user