Added new 1.0.5 packets

This commit is contained in:
Dylan K. Taylor
2017-03-11 19:54:03 +00:00
parent 004880548c
commit 6f1b12b021
9 changed files with 399 additions and 11 deletions

View File

@ -35,10 +35,12 @@ use pocketmine\network\mcpe\protocol\AvailableCommandsPacket;
use pocketmine\network\mcpe\protocol\BatchPacket;
use pocketmine\network\mcpe\protocol\BlockEntityDataPacket;
use pocketmine\network\mcpe\protocol\BlockEventPacket;
use pocketmine\network\mcpe\protocol\BlockPickRequestPacket;
use pocketmine\network\mcpe\protocol\ChangeDimensionPacket;
use pocketmine\network\mcpe\protocol\ChunkRadiusUpdatedPacket;
use pocketmine\network\mcpe\protocol\ClientboundMapItemDataPacket;
use pocketmine\network\mcpe\protocol\ClientToServerHandshakePacket;
use pocketmine\network\mcpe\protocol\CommandBlockUpdatePacket;
use pocketmine\network\mcpe\protocol\CommandStepPacket;
use pocketmine\network\mcpe\protocol\ContainerClosePacket;
use pocketmine\network\mcpe\protocol\ContainerOpenPacket;
@ -69,6 +71,7 @@ use pocketmine\network\mcpe\protocol\PlayerActionPacket;
use pocketmine\network\mcpe\protocol\PlayerFallPacket;
use pocketmine\network\mcpe\protocol\PlayerInputPacket;
use pocketmine\network\mcpe\protocol\PlayerListPacket;
use pocketmine\network\mcpe\protocol\PlaySoundPacket;
use pocketmine\network\mcpe\protocol\PlayStatusPacket;
use pocketmine\network\mcpe\protocol\RemoveBlockPacket;
use pocketmine\network\mcpe\protocol\RemoveEntityPacket;
@ -92,9 +95,11 @@ use pocketmine\network\mcpe\protocol\SetHealthPacket;
use pocketmine\network\mcpe\protocol\SetPlayerGameTypePacket;
use pocketmine\network\mcpe\protocol\SetSpawnPositionPacket;
use pocketmine\network\mcpe\protocol\SetTimePacket;
use pocketmine\network\mcpe\protocol\SetTitlePacket;
use pocketmine\network\mcpe\protocol\ShowCreditsPacket;
use pocketmine\network\mcpe\protocol\SpawnExperienceOrbPacket;
use pocketmine\network\mcpe\protocol\StartGamePacket;
use pocketmine\network\mcpe\protocol\StopSoundPacket;
use pocketmine\network\mcpe\protocol\TakeItemEntityPacket;
use pocketmine\network\mcpe\protocol\TextPacket;
use pocketmine\network\mcpe\protocol\TransferPacket;
@ -174,6 +179,8 @@ interface NetworkSession{
public function handleInteract(InteractPacket $packet) : bool;
public function handleBlockPickRequest(BlockPickRequestPacket $packet) : bool;
public function handleUseItem(UseItemPacket $packet) : bool;
public function handlePlayerAction(PlayerActionPacket $packet) : bool;
@ -262,6 +269,8 @@ interface NetworkSession{
public function handleCommandStep(CommandStepPacket $packet) : bool;
public function handleCommandBlockUpdate(CommandBlockUpdatePacket $packet) : bool;
public function handleUpdateTrade(UpdateTradePacket $packet) : bool;
public function handleResourcePackDataInfo(ResourcePackDataInfoPacket $packet) : bool;
@ -272,5 +281,11 @@ interface NetworkSession{
public function handleTransfer(TransferPacket $packet) : bool;
public function handlePlaySound(PlaySoundPacket $packet) : bool;
public function handleStopSound(StopSoundPacket $packet) : bool;
public function handleSetTitle(SetTitlePacket $packet) : bool;
public function handleUnknown(UnknownPacket $packet) : bool;
}

View File

@ -0,0 +1,52 @@
<?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\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\NetworkSession;
class BlockPickRequestPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::BLOCK_PICK_REQUEST_PACKET;
public $tileX;
public $tileY;
public $tileZ;
public $hotbarSlot;
public function decode(){
$this->getSignedBlockPosition($this->tileX, $this->tileY, $this->tileZ);
$this->hotbarSlot = $this->getByte();
}
public function encode(){
$this->reset();
$this->putSignedBlockPosition($this->tileX, $this->tileY, $this->tileZ);
$this->putByte($this->hotbarSlot);
}
public function handle(NetworkSession $session) : bool{
return $session->handleBlockPickRequest($this);
}
}

View File

@ -0,0 +1,92 @@
<?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\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\NetworkSession;
class CommandBlockUpdatePacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::COMMAND_BLOCK_UPDATE_PACKET;
public $isCommandBlockUpdate;
public $x;
public $y;
public $z;
public $commandBlockMode;
public $isRedstoneMode;
public $isConditional;
public $eid;
public $command;
public $lastOutput;
public $name;
public $shouldTrackOutput;
public function decode(){
$this->isCommandBlockUpdate = $this->getBool();
if($this->isCommandBlockUpdate){
$this->getBlockPosition($this->x, $this->y, $this->z);
$this->commandBlockMode = $this->getUnsignedVarInt();
$this->isRedstoneMode = $this->getBool();
$this->isConditional = $this->getBool();
}else{
$this->eid = $this->getEntityRuntimeId();
}
$this->command = $this->getString();
$this->lastOutput = $this->getString();
$this->name = $this->getString();
$this->shouldTrackOutput = $this->getBool();
}
public function encode(){
$this->reset();
$this->putBool($this->isCommandBlockUpdate);
if($this->isCommandBlockUpdate){
$this->putBlockPosition($this->x, $this->y, $this->z);
$this->putUnsignedVarInt($this->commandBlockMode);
$this->putBool($this->isRedstoneMode);
$this->putBool($this->isConditional);
}else{
$this->putEntityRuntimeId($this->eid);
}
$this->putString($this->command);
$this->putString($this->lastOutput);
$this->putString($this->name);
$this->putBool($this->shouldTrackOutput);
}
public function handle(NetworkSession $session) : bool{
return $session->handleCommandBlockUpdate($this);
}
}

View File

@ -116,17 +116,15 @@ abstract class DataPacket extends BinaryStream{
$value[2] = $item->getDamage();
break;
case Entity::DATA_TYPE_POS:
$value = [];
$value[0] = $this->getVarInt(); //x
$value[1] = $this->getVarInt(); //y (SIGNED)
$value[2] = $this->getVarInt(); //z
$value = [0, 0, 0];
$this->getSignedBlockPosition(...$value);
break;
case Entity::DATA_TYPE_LONG:
$value = $this->getVarLong();
break;
case Entity::DATA_TYPE_VECTOR3F:
$value = [0.0, 0.0, 0.0];
$this->getVector3f($value[0], $value[1], $value[2]);
$this->getVector3f(...$value);
break;
default:
$value = [];
@ -173,16 +171,14 @@ abstract class DataPacket extends BinaryStream{
break;
case Entity::DATA_TYPE_POS:
//TODO: change this implementation (use objects)
$this->putVarInt($d[1][0]); //x
$this->putVarInt($d[1][1]); //y (SIGNED)
$this->putVarInt($d[1][2]); //z
$this->putSignedBlockPosition(...$d[1]);
break;
case Entity::DATA_TYPE_LONG:
$this->putVarLong($d[1]);
break;
case Entity::DATA_TYPE_VECTOR3F:
//TODO: change this implementation (use objects)
$this->putVector3f($d[1][0], $d[1][1], $d[1][2]); //x, y, z
$this->putVector3f(...$d[1]); //x, y, z
}
}
}
@ -220,7 +216,7 @@ abstract class DataPacket extends BinaryStream{
}
/**
* Writes an block position with unsigned Y coordinate.
* Reads an block position with unsigned Y coordinate.
* @param int $x
* @param int $y 0-255
* @param int $z
@ -232,7 +228,7 @@ abstract class DataPacket extends BinaryStream{
}
/**
* Reads a block position with unsigned Y coordinate.
* Writes a block position with unsigned Y coordinate.
* @param int &$x
* @param int &$y
* @param int &$z
@ -243,6 +239,30 @@ abstract class DataPacket extends BinaryStream{
$this->putVarInt($z);
}
/**
* Reads a block position with a signed Y coordinate.
* @param int &$x
* @param int &$y
* @param int &$z
*/
public function getSignedBlockPosition(&$x, &$y, &$z){
$x = $this->getVarInt();
$y = $this->getVarInt();
$z = $this->getVarInt();
}
/**
* Writes a block position with a signed Y coordinate.
* @param int $x
* @param int $y
* @param int $z
*/
public function putSignedBlockPosition($x, $y, $z){
$this->putVarInt($x);
$this->putVarInt($y);
$this->putVarInt($z);
}
/**
* Reads a floating-point vector3 rounded to 4dp.
* @param float $x

View File

@ -0,0 +1,58 @@
<?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\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\NetworkSession;
class PlaySoundPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::PLAY_SOUND_PACKET;
public $string1;
public $x;
public $y;
public $z;
public $float1;
public $float2;
public function decode(){
$this->string1 = $this->getString();
$this->getBlockPosition($this->x, $this->y, $this->z);
$this->float1 = $this->getLFloat();
$this->float2 = $this->getLFloat();
}
public function encode(){
$this->reset();
$this->putString($this->string1);
$this->putBlockPosition($this->x, $this->y, $this->z);
$this->putLFloat($this->float1);
$this->putLFloat($this->float2);
}
public function handle(NetworkSession $session) : bool{
return $session->handlePlaySound($this);
}
}

View File

@ -0,0 +1,66 @@
<?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\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\NetworkSession;
class SetTitlePacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::SET_TITLE_PACKET;
const TYPE_CLEAR_TITLE = 0;
const TYPE_RESET_TITLE = 1;
const TYPE_SET_TITLE = 2;
const TYPE_SET_SUBTITLE = 3;
const TYPE_SET_ACTIONBAR_MESSAGE = 4;
const TYPE_SET_ANIMATION_TIMES = 5;
public $type;
public $text;
public $fadeInTime;
public $stayTime;
public $fadeOutTime;
public function decode(){
$this->type = $this->getVarInt();
$this->text = $this->getString();
$this->fadeInTime = $this->getVarInt();
$this->stayTime = $this->getVarInt();
$this->fadeOutTime = $this->getVarInt();
}
public function encode(){
$this->reset();
$this->putVarInt($this->type);
$this->putString($this->text);
$this->putVarInt($this->fadeInTime);
$this->putVarInt($this->stayTime);
$this->putVarInt($this->fadeOutTime);
}
public function handle(NetworkSession $session) : bool{
return $session->handleSetTitle($this);
}
}

View File

@ -0,0 +1,50 @@
<?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\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\NetworkSession;
class StopSoundPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::STOP_SOUND_PACKET;
public $string1;
public $stopAll;
public function decode(){
$this->string1 = $this->getString();
$this->stopAll = $this->getBool();
}
public function encode(){
$this->reset();
$this->putString($this->string1);
$this->putBool($this->stopAll);
}
public function handle(NetworkSession $session) : bool{
return $session->handleStopSound($this);
}
}