mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
Protocol changes for 1.5.0 "release"
what a piece of shit this version is...
This commit is contained in:
parent
b3ffce9729
commit
b5dcdea6d8
@ -64,7 +64,7 @@ use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\network\mcpe\protocol\AddEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\EntityEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\MoveEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\MoveEntityAbsolutePacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetEntityDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetEntityMotionPacket;
|
||||
@ -1134,13 +1134,20 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
|
||||
protected function broadcastMovement(bool $teleport = false) : void{
|
||||
if($this->chunk !== null){
|
||||
$pk = new MoveEntityPacket();
|
||||
$pk = new MoveEntityAbsolutePacket();
|
||||
$pk->entityRuntimeId = $this->id;
|
||||
$pk->position = $this->getOffsetPosition($this);
|
||||
$pk->yaw = $this->yaw;
|
||||
$pk->pitch = $this->pitch;
|
||||
$pk->headYaw = $this->yaw; //TODO
|
||||
$pk->teleported = $teleport;
|
||||
|
||||
//this looks very odd but is correct as of 1.5.0.7
|
||||
//for arrows this is actually x/y/z rotation
|
||||
//for mobs x and z are used for pitch and yaw, and y is used for headyaw
|
||||
$pk->xRot = $this->pitch;
|
||||
$pk->yRot = $this->yaw; //TODO: head yaw
|
||||
$pk->zRot = $this->yaw;
|
||||
|
||||
if($teleport){
|
||||
$pk->flags |= MoveEntityAbsolutePacket::FLAG_TELEPORT;
|
||||
}
|
||||
|
||||
$this->level->addChunkPacket($this->chunk->getX(), $this->chunk->getZ(), $pk);
|
||||
}
|
||||
|
@ -76,7 +76,8 @@ use pocketmine\network\mcpe\protocol\MobEffectPacket;
|
||||
use pocketmine\network\mcpe\protocol\MobEquipmentPacket;
|
||||
use pocketmine\network\mcpe\protocol\ModalFormRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\ModalFormResponsePacket;
|
||||
use pocketmine\network\mcpe\protocol\MoveEntityPacket;
|
||||
use pocketmine\network\mcpe\protocol\MoveEntityAbsolutePacket;
|
||||
use pocketmine\network\mcpe\protocol\MoveEntityDeltaPacket;
|
||||
use pocketmine\network\mcpe\protocol\MovePlayerPacket;
|
||||
use pocketmine\network\mcpe\protocol\NpcRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\PhotoTransferPacket;
|
||||
@ -111,6 +112,7 @@ use pocketmine\network\mcpe\protocol\SetEntityLinkPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetEntityMotionPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetHealthPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetLastHurtByPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetLocalPlayerAsInitializedPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetPlayerGameTypePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetScorePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetSpawnPositionPacket;
|
||||
@ -207,7 +209,7 @@ abstract class NetworkSession{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMoveEntity(MoveEntityPacket $packet) : bool{
|
||||
public function handleMoveEntityAbsolute(MoveEntityAbsolutePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -578,4 +580,12 @@ abstract class NetworkSession{
|
||||
public function handleUpdateBlockSynced(UpdateBlockSyncedPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleMoveEntityDelta(MoveEntityDeltaPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleSetLocalPlayerAsInitialized(SetLocalPlayerAsInitializedPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -44,9 +44,11 @@ class AddEntityPacket extends DataPacket{
|
||||
/** @var Vector3|null */
|
||||
public $motion;
|
||||
/** @var float */
|
||||
public $pitch = 0.0;
|
||||
/** @var float */
|
||||
public $yaw = 0.0;
|
||||
/** @var float */
|
||||
public $pitch = 0.0;
|
||||
public $headYaw = 0.0;
|
||||
|
||||
/** @var Attribute[] */
|
||||
public $attributes = [];
|
||||
@ -63,6 +65,7 @@ class AddEntityPacket extends DataPacket{
|
||||
$this->motion = $this->getVector3();
|
||||
$this->pitch = $this->getLFloat();
|
||||
$this->yaw = $this->getLFloat();
|
||||
$this->headYaw = $this->getLFloat();
|
||||
|
||||
$attrCount = $this->getUnsignedVarInt();
|
||||
for($i = 0; $i < $attrCount; ++$i){
|
||||
@ -97,6 +100,7 @@ class AddEntityPacket extends DataPacket{
|
||||
$this->putVector3Nullable($this->motion);
|
||||
$this->putLFloat($this->pitch);
|
||||
$this->putLFloat($this->yaw);
|
||||
$this->putLFloat($this->headYaw);
|
||||
|
||||
$this->putUnsignedVarInt(count($this->attributes));
|
||||
foreach($this->attributes as $attribute){
|
||||
|
@ -29,6 +29,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\types\DimensionIds;
|
||||
use pocketmine\network\mcpe\protocol\types\MapTrackedObject;
|
||||
use pocketmine\utils\Color;
|
||||
|
||||
class ClientboundMapItemDataPacket extends DataPacket{
|
||||
@ -49,8 +50,8 @@ class ClientboundMapItemDataPacket extends DataPacket{
|
||||
/** @var int */
|
||||
public $scale;
|
||||
|
||||
/** @var int[] */
|
||||
public $decorationEntityUniqueIds = [];
|
||||
/** @var MapTrackedObject[] */
|
||||
public $trackedEntities = [];
|
||||
/** @var array */
|
||||
public $decorations = [];
|
||||
|
||||
@ -83,7 +84,16 @@ class ClientboundMapItemDataPacket extends DataPacket{
|
||||
|
||||
if(($this->type & self::BITFLAG_DECORATION_UPDATE) !== 0){
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
$this->decorationEntityUniqueIds[] = $this->getEntityUniqueId();
|
||||
$object = new MapTrackedObject();
|
||||
$object->type = $this->getLInt();
|
||||
if($object->type === MapTrackedObject::TYPE_BLOCK){
|
||||
$this->getBlockPosition($object->x, $object->y, $object->z);
|
||||
}elseif($object->type === MapTrackedObject::TYPE_ENTITY){
|
||||
$object->entityUniqueId = $this->getEntityUniqueId();
|
||||
}else{
|
||||
throw new \UnexpectedValueException("Unknown map object type");
|
||||
}
|
||||
$this->trackedEntities[] = $object;
|
||||
}
|
||||
|
||||
for($i = 0, $count = $this->getUnsignedVarInt(); $i < $count; ++$i){
|
||||
@ -143,9 +153,16 @@ class ClientboundMapItemDataPacket extends DataPacket{
|
||||
}
|
||||
|
||||
if(($type & self::BITFLAG_DECORATION_UPDATE) !== 0){
|
||||
$this->putUnsignedVarInt(count($this->decorationEntityUniqueIds));
|
||||
foreach($this->decorationEntityUniqueIds as $id){
|
||||
$this->putEntityUniqueId($id);
|
||||
$this->putUnsignedVarInt(count($this->trackedEntities));
|
||||
foreach($this->trackedEntities as $object){
|
||||
$this->putLInt($object->type);
|
||||
if($object->type === MapTrackedObject::TYPE_BLOCK){
|
||||
$this->putBlockPosition($object->x, $object->y, $object->z);
|
||||
}elseif($object->type === MapTrackedObject::TYPE_ENTITY){
|
||||
$this->putEntityUniqueId($object->entityUniqueId);
|
||||
}else{
|
||||
throw new \UnexpectedValueException("Unknown map object type");
|
||||
}
|
||||
}
|
||||
|
||||
$this->putUnsignedVarInt($decorationCount);
|
||||
|
@ -29,45 +29,44 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class MoveEntityPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::MOVE_ENTITY_PACKET;
|
||||
class MoveEntityAbsolutePacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::MOVE_ENTITY_ABSOLUTE_PACKET;
|
||||
|
||||
public const FLAG_GROUND = 0x01;
|
||||
public const FLAG_TELEPORT = 0x02;
|
||||
|
||||
/** @var int */
|
||||
public $entityRuntimeId;
|
||||
/** @var int */
|
||||
public $flags = 0;
|
||||
/** @var Vector3 */
|
||||
public $position;
|
||||
/** @var float */
|
||||
public $yaw;
|
||||
public $xRot;
|
||||
/** @var float */
|
||||
public $headYaw;
|
||||
public $yRot;
|
||||
/** @var float */
|
||||
public $pitch;
|
||||
/** @var bool */
|
||||
public $onGround = false;
|
||||
/** @var bool */
|
||||
public $teleported = false;
|
||||
public $zRot;
|
||||
|
||||
protected function decodePayload(){
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
$this->flags = $this->getByte();
|
||||
$this->position = $this->getVector3();
|
||||
$this->pitch = $this->getByteRotation();
|
||||
$this->headYaw = $this->getByteRotation();
|
||||
$this->yaw = $this->getByteRotation();
|
||||
$this->onGround = $this->getBool();
|
||||
$this->teleported = $this->getBool();
|
||||
$this->xRot = $this->getByteRotation();
|
||||
$this->yRot = $this->getByteRotation();
|
||||
$this->zRot = $this->getByteRotation();
|
||||
}
|
||||
|
||||
protected function encodePayload(){
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
$this->putByte($this->flags);
|
||||
$this->putVector3($this->position);
|
||||
$this->putByteRotation($this->pitch);
|
||||
$this->putByteRotation($this->headYaw);
|
||||
$this->putByteRotation($this->yaw);
|
||||
$this->putBool($this->onGround);
|
||||
$this->putBool($this->teleported);
|
||||
$this->putByteRotation($this->xRot);
|
||||
$this->putByteRotation($this->yRot);
|
||||
$this->putByteRotation($this->zRot);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleMoveEntity($this);
|
||||
return $session->handleMoveEntityAbsolute($this);
|
||||
}
|
||||
}
|
104
src/pocketmine/network/mcpe/protocol/MoveEntityDeltaPacket.php
Normal file
104
src/pocketmine/network/mcpe/protocol/MoveEntityDeltaPacket.php
Normal file
@ -0,0 +1,104 @@
|
||||
<?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 MoveEntityDeltaPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::MOVE_ENTITY_DELTA_PACKET;
|
||||
|
||||
public const FLAG_HAS_X = 0x01;
|
||||
public const FLAG_HAS_Y = 0x02;
|
||||
public const FLAG_HAS_Z = 0x04;
|
||||
public const FLAG_HAS_ROT_X = 0x08;
|
||||
public const FLAG_HAS_ROT_Y = 0x10;
|
||||
public const FLAG_HAS_ROT_Z = 0x20;
|
||||
|
||||
/** @var int */
|
||||
public $flags;
|
||||
/** @var int */
|
||||
public $xDiff = 0;
|
||||
/** @var int */
|
||||
public $yDiff = 0;
|
||||
/** @var int */
|
||||
public $zDiff = 0;
|
||||
/** @var float */
|
||||
public $xRot = 0.0;
|
||||
/** @var float */
|
||||
public $yRot = 0.0;
|
||||
/** @var float */
|
||||
public $zRot = 0.0;
|
||||
|
||||
private function maybeReadCoord(int $flag) : int{
|
||||
if($this->flags & $flag){
|
||||
return $this->getVarInt();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function maybeReadRotation(int $flag) : float{
|
||||
if($this->flags & $flag){
|
||||
return $this->getByteRotation();
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
protected function decodePayload(){
|
||||
$this->flags = $this->getByte();
|
||||
$this->xDiff = $this->maybeReadCoord(self::FLAG_HAS_X);
|
||||
$this->yDiff = $this->maybeReadCoord(self::FLAG_HAS_Y);
|
||||
$this->zDiff = $this->maybeReadCoord(self::FLAG_HAS_Z);
|
||||
$this->xRot = $this->maybeReadRotation(self::FLAG_HAS_ROT_X);
|
||||
$this->yRot = $this->maybeReadRotation(self::FLAG_HAS_ROT_Y);
|
||||
$this->zRot = $this->maybeReadRotation(self::FLAG_HAS_ROT_Z);
|
||||
}
|
||||
|
||||
private function maybeWriteCoord(int $flag, int $val) : void{
|
||||
if($this->flags & $flag){
|
||||
$this->putVarInt($val);
|
||||
}
|
||||
}
|
||||
|
||||
private function maybeWriteRotation(int $flag, float $val) : void{
|
||||
if($this->flags & $flag){
|
||||
$this->putByteRotation($val);
|
||||
}
|
||||
}
|
||||
|
||||
protected function encodePayload(){
|
||||
$this->putByte($this->flags);
|
||||
$this->maybeWriteCoord(self::FLAG_HAS_X, $this->xDiff);
|
||||
$this->maybeWriteCoord(self::FLAG_HAS_Y, $this->yDiff);
|
||||
$this->maybeWriteCoord(self::FLAG_HAS_Z, $this->zDiff);
|
||||
$this->maybeWriteRotation(self::FLAG_HAS_ROT_X, $this->xRot);
|
||||
$this->maybeWriteRotation(self::FLAG_HAS_ROT_Y, $this->yRot);
|
||||
$this->maybeWriteRotation(self::FLAG_HAS_ROT_Z, $this->zRot);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleMoveEntityDelta($this);
|
||||
}
|
||||
}
|
@ -48,7 +48,7 @@ class PacketPool{
|
||||
static::registerPacket(new AddItemEntityPacket());
|
||||
static::registerPacket(new AddHangingEntityPacket());
|
||||
static::registerPacket(new TakeItemEntityPacket());
|
||||
static::registerPacket(new MoveEntityPacket());
|
||||
static::registerPacket(new MoveEntityAbsolutePacket());
|
||||
static::registerPacket(new MovePlayerPacket());
|
||||
static::registerPacket(new RiderJumpPacket());
|
||||
static::registerPacket(new UpdateBlockPacket());
|
||||
@ -141,6 +141,8 @@ class PacketPool{
|
||||
static::registerPacket(new SetScorePacket());
|
||||
static::registerPacket(new LabTablePacket());
|
||||
static::registerPacket(new UpdateBlockSyncedPacket());
|
||||
static::registerPacket(new MoveEntityDeltaPacket());
|
||||
static::registerPacket(new SetLocalPlayerAsInitializedPacket());
|
||||
|
||||
static::registerPacket(new BatchPacket());
|
||||
}
|
||||
|
@ -39,15 +39,15 @@ interface ProtocolInfo{
|
||||
/**
|
||||
* Actual Minecraft: PE protocol version
|
||||
*/
|
||||
public const CURRENT_PROTOCOL = 261;
|
||||
public const CURRENT_PROTOCOL = 274;
|
||||
/**
|
||||
* Current Minecraft PE version reported by the server. This is usually the earliest currently supported version.
|
||||
*/
|
||||
public const MINECRAFT_VERSION = 'v1.4.0';
|
||||
public const MINECRAFT_VERSION = 'v1.5.0';
|
||||
/**
|
||||
* Version number sent to clients in ping responses.
|
||||
*/
|
||||
public const MINECRAFT_VERSION_NETWORK = '1.4.0';
|
||||
public const MINECRAFT_VERSION_NETWORK = '1.5.0';
|
||||
|
||||
public const LOGIN_PACKET = 0x01;
|
||||
public const PLAY_STATUS_PACKET = 0x02;
|
||||
@ -66,7 +66,7 @@ interface ProtocolInfo{
|
||||
public const ADD_ITEM_ENTITY_PACKET = 0x0f;
|
||||
public const ADD_HANGING_ENTITY_PACKET = 0x10;
|
||||
public const TAKE_ITEM_ENTITY_PACKET = 0x11;
|
||||
public const MOVE_ENTITY_PACKET = 0x12;
|
||||
public const MOVE_ENTITY_ABSOLUTE_PACKET = 0x12;
|
||||
public const MOVE_PLAYER_PACKET = 0x13;
|
||||
public const RIDER_JUMP_PACKET = 0x14;
|
||||
public const UPDATE_BLOCK_PACKET = 0x15;
|
||||
@ -159,5 +159,7 @@ interface ProtocolInfo{
|
||||
public const SET_SCORE_PACKET = 0x6c;
|
||||
public const LAB_TABLE_PACKET = 0x6d;
|
||||
public const UPDATE_BLOCK_SYNCED_PACKET = 0x6e;
|
||||
public const MOVE_ENTITY_DELTA_PACKET = 0x6f;
|
||||
public const SET_LOCAL_PLAYER_AS_INITIALIZED_PACKET = 0x70;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
<?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 SetLocalPlayerAsInitializedPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::SET_LOCAL_PLAYER_AS_INITIALIZED_PACKET;
|
||||
|
||||
/** @var int */
|
||||
public $entityRuntimeId;
|
||||
|
||||
protected function decodePayload(){
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
}
|
||||
|
||||
protected function encodePayload(){
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleSetLocalPlayerAsInitialized($this);
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
<?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;
|
||||
|
||||
class MapTrackedObject{
|
||||
public const TYPE_ENTITY = 0;
|
||||
public const TYPE_BLOCK = 1;
|
||||
|
||||
/** @var int */
|
||||
public $type;
|
||||
|
||||
/** @var int Only set if is TYPE_ENTITY */
|
||||
public $entityUniqueId;
|
||||
|
||||
/** @var int */
|
||||
public $x;
|
||||
/** @var int */
|
||||
public $y;
|
||||
/** @var int */
|
||||
public $z;
|
||||
|
||||
}
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user