Protocol changes for 1.9.0

This commit is contained in:
Dylan K. Taylor
2019-02-07 21:56:42 +00:00
parent 37c2d78731
commit b8703d5dff
19 changed files with 390 additions and 96 deletions

View File

@ -28,19 +28,37 @@ namespace pocketmine\network\mcpe\protocol;
use pocketmine\network\mcpe\NetworkSession;
class AddPaintingPacket extends AddHangingEntityPacket{
class AddPaintingPacket extends DataPacket{
public const NETWORK_ID = ProtocolInfo::ADD_PAINTING_PACKET;
/** @var string */
public $title;
/** @var int */
public $entityRuntimeId;
/** @var int */
public $x;
/** @var int|null */
public $entityUniqueId = null;
/** @var int */
public $y;
/** @var int */
public $z;
/** @var int */
public $direction;
protected function decodePayload(){
parent::decodePayload();
$this->entityUniqueId = $this->getEntityUniqueId();
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->getBlockPosition($this->x, $this->y, $this->z);
$this->direction = $this->getVarInt();
$this->title = $this->getString();
}
protected function encodePayload(){
parent::encodePayload();
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putBlockPosition($this->x, $this->y, $this->z);
$this->putVarInt($this->direction);
$this->putString($this->title);
}

File diff suppressed because one or more lines are too long

View File

@ -299,7 +299,7 @@ class LevelSoundEventPacket extends DataPacket{
public $disableRelativeVolume = false;
protected function decodePayload(){
$this->sound = $this->getByte();
$this->sound = $this->getUnsignedVarInt();
$this->position = $this->getVector3();
$this->extraData = $this->getVarInt();
$this->entityType = $this->getString();
@ -308,7 +308,7 @@ class LevelSoundEventPacket extends DataPacket{
}
protected function encodePayload(){
$this->putByte($this->sound);
$this->putUnsignedVarInt($this->sound);
$this->putVector3($this->position);
$this->putVarInt($this->extraData);
$this->putString($this->entityType);

View File

@ -25,39 +25,47 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\NetworkSession;
class AddHangingEntityPacket extends DataPacket{
public const NETWORK_ID = ProtocolInfo::ADD_HANGING_ENTITY_PACKET;
/**
* Useless leftover from a 1.9 refactor, does nothing
*/
class LevelSoundEventPacketV2 extends DataPacket{
public const NETWORK_ID = ProtocolInfo::LEVEL_SOUND_EVENT_PACKET_V2;
/** @var int|null */
public $entityUniqueId = null;
/** @var int */
public $entityRuntimeId;
public $sound;
/** @var Vector3 */
public $position;
/** @var int */
public $x;
/** @var int */
public $y;
/** @var int */
public $z;
/** @var int */
public $direction;
public $extraData = -1;
/** @var string */
public $entityType = ":"; //???
/** @var bool */
public $isBabyMob = false; //...
/** @var bool */
public $disableRelativeVolume = false;
protected function decodePayload(){
$this->entityUniqueId = $this->getEntityUniqueId();
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->getBlockPosition($this->x, $this->y, $this->z);
$this->direction = $this->getVarInt();
$this->sound = $this->getByte();
$this->position = $this->getVector3();
$this->extraData = $this->getVarInt();
$this->entityType = $this->getString();
$this->isBabyMob = $this->getBool();
$this->disableRelativeVolume = $this->getBool();
}
protected function encodePayload(){
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putBlockPosition($this->x, $this->y, $this->z);
$this->putVarInt($this->direction);
$this->putByte($this->sound);
$this->putVector3($this->position);
$this->putVarInt($this->extraData);
$this->putString($this->entityType);
$this->putBool($this->isBabyMob);
$this->putBool($this->disableRelativeVolume);
}
public function handle(NetworkSession $session) : bool{
return $session->handleAddHangingEntity($this);
return $session->handleLevelSoundEventPacketV2($this);
}
}

View File

@ -32,13 +32,17 @@ class NetworkStackLatencyPacket extends DataPacket{
/** @var int */
public $timestamp;
/** @var bool */
public $needResponse;
protected function decodePayload(){
$this->timestamp = $this->getLLong();
$this->needResponse = $this->getBool();
}
protected function encodePayload(){
$this->putLLong($this->timestamp);
$this->putBool($this->needResponse);
}
public function handle(NetworkSession $session) : bool{

View File

@ -48,7 +48,6 @@ class PacketPool{
static::registerPacket(new AddEntityPacket());
static::registerPacket(new RemoveEntityPacket());
static::registerPacket(new AddItemEntityPacket());
static::registerPacket(new AddHangingEntityPacket());
static::registerPacket(new TakeItemEntityPacket());
static::registerPacket(new MoveEntityAbsolutePacket());
static::registerPacket(new MovePlayerPacket());
@ -151,9 +150,10 @@ class PacketPool{
static::registerPacket(new ScriptCustomEventPacket());
static::registerPacket(new SpawnParticleEffectPacket());
static::registerPacket(new AvailableEntityIdentifiersPacket());
static::registerPacket(new LevelSoundEventPacket());
static::registerPacket(new LevelSoundEventPacketV2());
static::registerPacket(new NetworkChunkPublisherUpdatePacket());
static::registerPacket(new BiomeDefinitionListPacket());
static::registerPacket(new LevelSoundEventPacket());
static::registerPacket(new BatchPacket());
}

View File

@ -39,15 +39,15 @@ interface ProtocolInfo{
/**
* Actual Minecraft: PE protocol version
*/
public const CURRENT_PROTOCOL = 313;
public const CURRENT_PROTOCOL = 332;
/**
* Current Minecraft PE version reported by the server. This is usually the earliest currently supported version.
*/
public const MINECRAFT_VERSION = 'v1.8.0';
public const MINECRAFT_VERSION = 'v1.9.0';
/**
* Version number sent to clients in ping responses.
*/
public const MINECRAFT_VERSION_NETWORK = '1.8.0';
public const MINECRAFT_VERSION_NETWORK = '1.9.0';
public const LOGIN_PACKET = 0x01;
public const PLAY_STATUS_PACKET = 0x02;
@ -64,7 +64,7 @@ interface ProtocolInfo{
public const ADD_ENTITY_PACKET = 0x0d;
public const REMOVE_ENTITY_PACKET = 0x0e;
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_ABSOLUTE_PACKET = 0x12;
public const MOVE_PLAYER_PACKET = 0x13;
@ -168,8 +168,9 @@ interface ProtocolInfo{
public const SCRIPT_CUSTOM_EVENT_PACKET = 0x75;
public const SPAWN_PARTICLE_EFFECT_PACKET = 0x76;
public const AVAILABLE_ENTITY_IDENTIFIERS_PACKET = 0x77;
public const LEVEL_SOUND_EVENT_PACKET = 0x78;
public const LEVEL_SOUND_EVENT_PACKET_V2 = 0x78;
public const NETWORK_CHUNK_PUBLISHER_UPDATE_PACKET = 0x79;
public const BIOME_DEFINITION_LIST_PACKET = 0x7a;
public const LEVEL_SOUND_EVENT_PACKET = 0x7b;
}

View File

@ -35,6 +35,8 @@ class ResourcePacksInfoPacket extends DataPacket{
/** @var bool */
public $mustAccept = false; //if true, forces client to use selected resource packs
/** @var bool */
public $hasScripts = false; //if true, causes disconnect for any platform that doesn't support scripts yet
/** @var ResourcePack[] */
public $behaviorPackEntries = [];
/** @var ResourcePack[] */
@ -42,6 +44,7 @@ class ResourcePacksInfoPacket extends DataPacket{
protected function decodePayload(){
$this->mustAccept = $this->getBool();
$this->hasScripts = $this->getBool();
$behaviorPackCount = $this->getLShort();
while($behaviorPackCount-- > 0){
$this->getString();
@ -50,6 +53,7 @@ class ResourcePacksInfoPacket extends DataPacket{
$this->getString();
$this->getString();
$this->getString();
$this->getBool();
}
$resourcePackCount = $this->getLShort();
@ -60,12 +64,13 @@ class ResourcePacksInfoPacket extends DataPacket{
$this->getString();
$this->getString();
$this->getString();
$this->getBool();
}
}
protected function encodePayload(){
$this->putBool($this->mustAccept);
$this->putBool($this->hasScripts);
$this->putLShort(count($this->behaviorPackEntries));
foreach($this->behaviorPackEntries as $entry){
$this->putString($entry->getPackId());
@ -74,6 +79,7 @@ class ResourcePacksInfoPacket extends DataPacket{
$this->putString(""); //TODO: encryption key
$this->putString(""); //TODO: subpack name
$this->putString(""); //TODO: content identity
$this->putBool(false); //TODO: has scripts (?)
}
$this->putLShort(count($this->resourcePackEntries));
foreach($this->resourcePackEntries as $entry){
@ -83,6 +89,7 @@ class ResourcePacksInfoPacket extends DataPacket{
$this->putString(""); //TODO: encryption key
$this->putString(""); //TODO: subpack name
$this->putString(""); //TODO: content identity
$this->putBool(false); //TODO: seems useless for resource packs
}
}

View File

@ -34,6 +34,8 @@ class SpawnParticleEffectPacket extends DataPacket{
/** @var int */
public $dimensionId = DimensionIds::OVERWORLD; //wtf mojang
/** @var int */
public $entityUniqueId = -1; //default none
/** @var Vector3 */
public $position;
/** @var string */
@ -41,12 +43,14 @@ class SpawnParticleEffectPacket extends DataPacket{
protected function decodePayload(){
$this->dimensionId = $this->getByte();
$this->entityUniqueId = $this->getEntityUniqueId();
$this->position = $this->getVector3();
$this->particleName = $this->getString();
}
protected function encodePayload(){
$this->putByte($this->dimensionId);
$this->putEntityUniqueId($this->entityUniqueId);
$this->putVector3($this->position);
$this->putString($this->particleName);
}

View File

@ -84,11 +84,15 @@ class StartGamePacket extends DataPacket{
/** @var float */
public $lightningLevel;
/** @var bool */
public $hasConfirmedPlatformLockedContent = false;
/** @var bool */
public $isMultiplayerGame = true;
/** @var bool */
public $hasLANBroadcast = true;
/** @var bool */
public $hasXboxLiveBroadcast = false;
/** @var int */
public $xboxLiveBroadcastMode = 0; //TODO: find values
/** @var int */
public $platformBroadcastMode = 0;
/** @var bool */
public $commandsEnabled;
/** @var bool */
@ -101,20 +105,12 @@ class StartGamePacket extends DataPacket{
public $hasBonusChestEnabled = false;
/** @var bool */
public $hasStartWithMapEnabled = false;
/** @var bool */
public $hasTrustPlayersEnabled = false;
/** @var int */
public $defaultPlayerPermission = PlayerPermissions::MEMBER; //TODO
/** @var int */
public $xboxLiveBroadcastMode = 0; //TODO: find values
/** @var int */
public $serverChunkTickRadius = 4; //TODO (leave as default for now)
/** @var bool */
public $hasPlatformBroadcast = false;
/** @var int */
public $platformBroadcastMode = 0;
/** @var bool */
public $xboxLiveBroadcastIntent = false;
/** @var bool */
public $hasLockedBehaviorPack = false;
/** @var bool */
@ -166,21 +162,18 @@ class StartGamePacket extends DataPacket{
$this->hasEduFeaturesEnabled = $this->getBool();
$this->rainLevel = $this->getLFloat();
$this->lightningLevel = $this->getLFloat();
$this->hasConfirmedPlatformLockedContent = $this->getBool();
$this->isMultiplayerGame = $this->getBool();
$this->hasLANBroadcast = $this->getBool();
$this->hasXboxLiveBroadcast = $this->getBool();
$this->xboxLiveBroadcastMode = $this->getVarInt();
$this->platformBroadcastMode = $this->getVarInt();
$this->commandsEnabled = $this->getBool();
$this->isTexturePacksRequired = $this->getBool();
$this->gameRules = $this->getGameRules();
$this->hasBonusChestEnabled = $this->getBool();
$this->hasStartWithMapEnabled = $this->getBool();
$this->hasTrustPlayersEnabled = $this->getBool();
$this->defaultPlayerPermission = $this->getVarInt();
$this->xboxLiveBroadcastMode = $this->getVarInt();
$this->serverChunkTickRadius = $this->getLInt();
$this->hasPlatformBroadcast = $this->getBool();
$this->platformBroadcastMode = $this->getVarInt();
$this->xboxLiveBroadcastIntent = $this->getBool();
$this->hasLockedBehaviorPack = $this->getBool();
$this->hasLockedResourcePack = $this->getBool();
$this->isFromLockedWorldTemplate = $this->getBool();
@ -228,21 +221,18 @@ class StartGamePacket extends DataPacket{
$this->putBool($this->hasEduFeaturesEnabled);
$this->putLFloat($this->rainLevel);
$this->putLFloat($this->lightningLevel);
$this->putBool($this->hasConfirmedPlatformLockedContent);
$this->putBool($this->isMultiplayerGame);
$this->putBool($this->hasLANBroadcast);
$this->putBool($this->hasXboxLiveBroadcast);
$this->putVarInt($this->xboxLiveBroadcastMode);
$this->putVarInt($this->platformBroadcastMode);
$this->putBool($this->commandsEnabled);
$this->putBool($this->isTexturePacksRequired);
$this->putGameRules($this->gameRules);
$this->putBool($this->hasBonusChestEnabled);
$this->putBool($this->hasStartWithMapEnabled);
$this->putBool($this->hasTrustPlayersEnabled);
$this->putVarInt($this->defaultPlayerPermission);
$this->putVarInt($this->xboxLiveBroadcastMode);
$this->putLInt($this->serverChunkTickRadius);
$this->putBool($this->hasPlatformBroadcast);
$this->putVarInt($this->platformBroadcastMode);
$this->putBool($this->xboxLiveBroadcastIntent);
$this->putBool($this->hasLockedBehaviorPack);
$this->putBool($this->hasLockedResourcePack);
$this->putBool($this->isFromLockedWorldTemplate);

View File

@ -41,6 +41,7 @@ class TextPacket extends DataPacket{
public const TYPE_SYSTEM = 6;
public const TYPE_WHISPER = 7;
public const TYPE_ANNOUNCEMENT = 8;
public const TYPE_JSON = 9;
/** @var int */
public $type;
@ -69,6 +70,7 @@ class TextPacket extends DataPacket{
case self::TYPE_RAW:
case self::TYPE_TIP:
case self::TYPE_SYSTEM:
case self::TYPE_JSON:
$this->message = $this->getString();
break;
@ -99,6 +101,7 @@ class TextPacket extends DataPacket{
case self::TYPE_RAW:
case self::TYPE_TIP:
case self::TYPE_SYSTEM:
case self::TYPE_JSON:
$this->putString($this->message);
break;