Added PhpDoc for packet field types and changed float x,y,z to Vector3

This commit is contained in:
Dylan K. Taylor 2017-08-13 20:02:07 +01:00
parent 6480f7a989
commit 9be1b929a5
99 changed files with 424 additions and 207 deletions

View File

@ -920,9 +920,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
protected function sendRespawnPacket(Vector3 $pos){ protected function sendRespawnPacket(Vector3 $pos){
$pk = new RespawnPacket(); $pk = new RespawnPacket();
$pk->x = $pos->x; $pk->position = $pos->add(0, $this->baseOffset, 0);
$pk->y = $pos->y + $this->baseOffset;
$pk->z = $pos->z;
$this->dataPacket($pk); $this->dataPacket($pk);
} }
@ -1581,7 +1580,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
if($to->distanceSquared($ev->getTo()) > 0.01){ //If plugins modify the destination if($to->distanceSquared($ev->getTo()) > 0.01){ //If plugins modify the destination
$this->teleport($ev->getTo()); $this->teleport($ev->getTo());
}else{ }else{
$this->level->addEntityMovement($this->x >> 4, $this->z >> 4, $this->getId(), $this->x, $this->y + $this->baseOffset, $this->z, $this->yaw, $this->pitch, $this->yaw); $this->broadcastMovement();
$distance = $from->distance($to); $distance = $from->distance($to);
//TODO: check swimming (adds 0.015 exhaustion in MCPE) //TODO: check swimming (adds 0.015 exhaustion in MCPE)
@ -1621,7 +1620,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
public function setMotion(Vector3 $mot){ public function setMotion(Vector3 $mot){
if(parent::setMotion($mot)){ if(parent::setMotion($mot)){
if($this->chunk !== null){ if($this->chunk !== null){
$this->level->addEntityMotion($this->chunk->getX(), $this->chunk->getZ(), $this->getId(), $this->motionX, $this->motionY, $this->motionZ); $this->broadcastMotion();
} }
if($this->motionY > 0){ if($this->motionY > 0){
@ -1865,9 +1864,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$pk->entityUniqueId = $this->id; $pk->entityUniqueId = $this->id;
$pk->entityRuntimeId = $this->id; $pk->entityRuntimeId = $this->id;
$pk->playerGamemode = Player::getClientFriendlyGamemode($this->gamemode); $pk->playerGamemode = Player::getClientFriendlyGamemode($this->gamemode);
$pk->x = $this->x;
$pk->y = $this->y + $this->baseOffset; $pk->playerPosition = $this->getOffsetPosition();
$pk->z = $this->z;
$pk->pitch = $this->pitch; $pk->pitch = $this->pitch;
$pk->yaw = $this->yaw; $pk->yaw = $this->yaw;
$pk->seed = -1; $pk->seed = -1;
@ -2086,7 +2085,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
} }
public function handleMovePlayer(MovePlayerPacket $packet) : bool{ public function handleMovePlayer(MovePlayerPacket $packet) : bool{
$newPos = new Vector3($packet->x, $packet->y - $this->baseOffset, $packet->z); $newPos = $packet->position->subtract(0, $this->baseOffset, 0);
if($this->isTeleporting and $newPos->distanceSquared($this) > 1){ //Tolerate up to 1 block to avoid problems with client-sided physics when spawning in blocks if($this->isTeleporting and $newPos->distanceSquared($this) > 1){ //Tolerate up to 1 block to avoid problems with client-sided physics when spawning in blocks
$this->server->getLogger()->debug("Ignoring outdated pre-teleport movement from " . $this->getName() . ", received " . $newPos . ", expected " . $this->asVector3()); $this->server->getLogger()->debug("Ignoring outdated pre-teleport movement from " . $this->getName() . ", received " . $newPos . ", expected " . $this->asVector3());
@ -3746,9 +3745,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$pk = new MovePlayerPacket(); $pk = new MovePlayerPacket();
$pk->entityRuntimeId = $this->getId(); $pk->entityRuntimeId = $this->getId();
$pk->x = $pos->x; $pk->position = $this->getOffsetPosition();
$pk->y = $pos->y + ($baseOffsetOverride ?? $this->baseOffset);
$pk->z = $pos->z;
$pk->bodyYaw = $yaw; $pk->bodyYaw = $yaw;
$pk->pitch = $pitch; $pk->pitch = $pitch;
$pk->yaw = $yaw; $pk->yaw = $yaw;

View File

@ -89,12 +89,9 @@ class Arrow extends Projectile{
$pk = new AddEntityPacket(); $pk = new AddEntityPacket();
$pk->type = Arrow::NETWORK_ID; $pk->type = Arrow::NETWORK_ID;
$pk->entityRuntimeId = $this->getId(); $pk->entityRuntimeId = $this->getId();
$pk->x = $this->x; $pk->position = $this->asVector3();
$pk->y = $this->y; $pk->motion = $this->getMotion();
$pk->z = $this->z;
$pk->speedX = $this->motionX;
$pk->speedY = $this->motionY;
$pk->speedZ = $this->motionZ;
$pk->yaw = $this->yaw; $pk->yaw = $this->yaw;
$pk->pitch = $this->pitch; $pk->pitch = $this->pitch;
$pk->metadata = $this->dataProperties; $pk->metadata = $this->dataProperties;

View File

@ -54,8 +54,10 @@ use pocketmine\nbt\tag\FloatTag;
use pocketmine\nbt\tag\ListTag; use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\ShortTag; use pocketmine\nbt\tag\ShortTag;
use pocketmine\nbt\tag\StringTag; use pocketmine\nbt\tag\StringTag;
use pocketmine\network\mcpe\protocol\MoveEntityPacket;
use pocketmine\network\mcpe\protocol\RemoveEntityPacket; use pocketmine\network\mcpe\protocol\RemoveEntityPacket;
use pocketmine\network\mcpe\protocol\SetEntityDataPacket; use pocketmine\network\mcpe\protocol\SetEntityDataPacket;
use pocketmine\network\mcpe\protocol\SetEntityMotionPacket;
use pocketmine\Player; use pocketmine\Player;
use pocketmine\plugin\Plugin; use pocketmine\plugin\Plugin;
use pocketmine\Server; use pocketmine\Server;
@ -1146,7 +1148,7 @@ abstract class Entity extends Location implements Metadatable{
$this->lastYaw = $this->yaw; $this->lastYaw = $this->yaw;
$this->lastPitch = $this->pitch; $this->lastPitch = $this->pitch;
$this->level->addEntityMovement($this->chunk->getX(), $this->chunk->getZ(), $this->id, $this->x, $this->y + $this->baseOffset, $this->z, $this->yaw, $this->pitch, $this->yaw); $this->broadcastMovement();
} }
if($diffMotion > 0.0025 or ($diffMotion > 0.0001 and $this->getMotion()->lengthSquared() <= 0.0001)){ //0.05 ** 2 if($diffMotion > 0.0025 or ($diffMotion > 0.0001 and $this->getMotion()->lengthSquared() <= 0.0001)){ //0.05 ** 2
@ -1154,10 +1156,33 @@ abstract class Entity extends Location implements Metadatable{
$this->lastMotionY = $this->motionY; $this->lastMotionY = $this->motionY;
$this->lastMotionZ = $this->motionZ; $this->lastMotionZ = $this->motionZ;
$this->level->addEntityMotion($this->chunk->getX(), $this->chunk->getZ(), $this->id, $this->motionX, $this->motionY, $this->motionZ); $this->broadcastMotion();
} }
} }
public function getOffsetPosition() : Vector3{
return new Vector3($this->x, $this->y + $this->baseOffset, $this->z);
}
protected function broadcastMovement(){
$pk = new MoveEntityPacket();
$pk->entityRuntimeId = $this->id;
$pk->position = $this->getOffsetPosition();
$pk->yaw = $this->yaw;
$pk->pitch = $this->pitch;
$pk->headYaw = $this->yaw; //TODO
$this->level->addChunkPacket($this->chunk->getX(), $this->chunk->getZ(), $pk);
}
protected function broadcastMotion(){
$pk = new SetEntityMotionPacket();
$pk->entityRuntimeId = $this->id;
$pk->motion = $this->getMotion();
$this->level->addChunkPacket($this->chunk->getX(), $this->chunk->getZ(), $pk);
}
/** /**
* @return Vector3 * @return Vector3
*/ */

View File

@ -148,12 +148,8 @@ class FallingSand extends Entity{
$pk = new AddEntityPacket(); $pk = new AddEntityPacket();
$pk->type = FallingSand::NETWORK_ID; $pk->type = FallingSand::NETWORK_ID;
$pk->entityRuntimeId = $this->getId(); $pk->entityRuntimeId = $this->getId();
$pk->x = $this->x; $pk->position = $this->asVector3();
$pk->y = $this->y; $pk->motion = $this->getMotion();
$pk->z = $this->z;
$pk->speedX = $this->motionX;
$pk->speedY = $this->motionY;
$pk->speedZ = $this->motionZ;
$pk->yaw = $this->yaw; $pk->yaw = $this->yaw;
$pk->pitch = $this->pitch; $pk->pitch = $this->pitch;
$pk->metadata = $this->dataProperties; $pk->metadata = $this->dataProperties;

View File

@ -515,12 +515,8 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
$pk->uuid = $this->getUniqueId(); $pk->uuid = $this->getUniqueId();
$pk->username = $this->getName(); $pk->username = $this->getName();
$pk->entityRuntimeId = $this->getId(); $pk->entityRuntimeId = $this->getId();
$pk->x = $this->x; $pk->position = $this->asVector3();
$pk->y = $this->y; $pk->motion = $this->getMotion();
$pk->z = $this->z;
$pk->speedX = $this->motionX;
$pk->speedY = $this->motionY;
$pk->speedZ = $this->motionZ;
$pk->yaw = $this->yaw; $pk->yaw = $this->yaw;
$pk->pitch = $this->pitch; $pk->pitch = $this->pitch;
$pk->item = $this->getInventory()->getItemInHand(); $pk->item = $this->getInventory()->getItemInHand();

View File

@ -234,12 +234,8 @@ class Item extends Entity{
public function spawnTo(Player $player){ public function spawnTo(Player $player){
$pk = new AddItemEntityPacket(); $pk = new AddItemEntityPacket();
$pk->entityRuntimeId = $this->getId(); $pk->entityRuntimeId = $this->getId();
$pk->x = $this->x; $pk->position = $this->asVector3();
$pk->y = $this->y; $pk->motion = $this->getMotion();
$pk->z = $this->z;
$pk->speedX = $this->motionX;
$pk->speedY = $this->motionY;
$pk->speedZ = $this->motionZ;
$pk->item = $this->getItem(); $pk->item = $this->getItem();
$pk->metadata = $this->dataProperties; $pk->metadata = $this->dataProperties;
$player->dataPacket($pk); $player->dataPacket($pk);

View File

@ -149,12 +149,8 @@ class PrimedTNT extends Entity implements Explosive{
$pk = new AddEntityPacket(); $pk = new AddEntityPacket();
$pk->type = PrimedTNT::NETWORK_ID; $pk->type = PrimedTNT::NETWORK_ID;
$pk->entityRuntimeId = $this->getId(); $pk->entityRuntimeId = $this->getId();
$pk->x = $this->x; $pk->position = $this->asVector3();
$pk->y = $this->y; $pk->motion = $this->getMotion();
$pk->z = $this->z;
$pk->speedX = $this->motionX;
$pk->speedY = $this->motionY;
$pk->speedZ = $this->motionZ;
$pk->metadata = $this->dataProperties; $pk->metadata = $this->dataProperties;
$player->dataPacket($pk); $player->dataPacket($pk);

View File

@ -65,12 +65,8 @@ class Snowball extends Projectile{
$pk = new AddEntityPacket(); $pk = new AddEntityPacket();
$pk->type = Snowball::NETWORK_ID; $pk->type = Snowball::NETWORK_ID;
$pk->entityRuntimeId = $this->getId(); $pk->entityRuntimeId = $this->getId();
$pk->x = $this->x; $pk->position = $this->asVector3();
$pk->y = $this->y; $pk->motion = $this->getMotion();
$pk->z = $this->z;
$pk->speedX = $this->motionX;
$pk->speedY = $this->motionY;
$pk->speedZ = $this->motionZ;
$pk->metadata = $this->dataProperties; $pk->metadata = $this->dataProperties;
$player->dataPacket($pk); $player->dataPacket($pk);

View File

@ -150,12 +150,8 @@ class Squid extends WaterAnimal{
$pk = new AddEntityPacket(); $pk = new AddEntityPacket();
$pk->entityRuntimeId = $this->getId(); $pk->entityRuntimeId = $this->getId();
$pk->type = Squid::NETWORK_ID; $pk->type = Squid::NETWORK_ID;
$pk->x = $this->x; $pk->position = $this->asVector3();
$pk->y = $this->y; $pk->motion = $this->getMotion();
$pk->z = $this->z;
$pk->speedX = $this->motionX;
$pk->speedY = $this->motionY;
$pk->speedZ = $this->motionZ;
$pk->yaw = $this->yaw; $pk->yaw = $this->yaw;
$pk->pitch = $this->pitch; $pk->pitch = $this->pitch;
$pk->metadata = $this->dataProperties; $pk->metadata = $this->dataProperties;

View File

@ -56,12 +56,8 @@ class Villager extends Creature implements NPC, Ageable{
$pk = new AddEntityPacket(); $pk = new AddEntityPacket();
$pk->entityRuntimeId = $this->getId(); $pk->entityRuntimeId = $this->getId();
$pk->type = Villager::NETWORK_ID; $pk->type = Villager::NETWORK_ID;
$pk->x = $this->x; $pk->position = $this->asVector3();
$pk->y = $this->y; $pk->motion = $this->getMotion();
$pk->z = $this->z;
$pk->speedX = $this->motionX;
$pk->speedY = $this->motionY;
$pk->speedZ = $this->motionZ;
$pk->yaw = $this->yaw; $pk->yaw = $this->yaw;
$pk->pitch = $this->pitch; $pk->pitch = $this->pitch;
$pk->metadata = $this->dataProperties; $pk->metadata = $this->dataProperties;

View File

@ -43,12 +43,8 @@ class Zombie extends Monster{
$pk = new AddEntityPacket(); $pk = new AddEntityPacket();
$pk->entityRuntimeId = $this->getId(); $pk->entityRuntimeId = $this->getId();
$pk->type = Zombie::NETWORK_ID; $pk->type = Zombie::NETWORK_ID;
$pk->x = $this->x; $pk->position = $this->asVector3();
$pk->y = $this->y; $pk->motion = $this->getMotion();
$pk->z = $this->z;
$pk->speedX = $this->motionX;
$pk->speedY = $this->motionY;
$pk->speedZ = $this->motionZ;
$pk->yaw = $this->yaw; $pk->yaw = $this->yaw;
$pk->pitch = $this->pitch; $pk->pitch = $this->pitch;
$pk->metadata = $this->dataProperties; $pk->metadata = $this->dataProperties;

View File

@ -195,9 +195,7 @@ class Explosion{
} }
$pk = new ExplodePacket(); $pk = new ExplodePacket();
$pk->x = $this->source->x; $pk->position = $this->source->asVector3();
$pk->y = $this->source->y;
$pk->z = $this->source->z;
$pk->radius = $this->size; $pk->radius = $this->size;
$pk->records = $send; $pk->records = $send;
$this->level->addChunkPacket($source->x >> 4, $source->z >> 4, $pk); $this->level->addChunkPacket($source->x >> 4, $source->z >> 4, $pk);

View File

@ -97,8 +97,6 @@ use pocketmine\network\mcpe\protocol\BatchPacket;
use pocketmine\network\mcpe\protocol\DataPacket; use pocketmine\network\mcpe\protocol\DataPacket;
use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket; use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
use pocketmine\network\mcpe\protocol\MoveEntityPacket;
use pocketmine\network\mcpe\protocol\SetEntityMotionPacket;
use pocketmine\network\mcpe\protocol\SetTimePacket; use pocketmine\network\mcpe\protocol\SetTimePacket;
use pocketmine\network\mcpe\protocol\UpdateBlockPacket; use pocketmine\network\mcpe\protocol\UpdateBlockPacket;
use pocketmine\Player; use pocketmine\Player;
@ -518,7 +516,7 @@ class Level implements ChunkManager, Metadatable{
$pk->extraData = $extraData; $pk->extraData = $extraData;
$pk->unknownBool = $unknown; $pk->unknownBool = $unknown;
$pk->disableRelativeVolume = $disableRelativeVolume; $pk->disableRelativeVolume = $disableRelativeVolume;
list($pk->x, $pk->y, $pk->z) = [$pos->x, $pos->y, $pos->z]; $pk->position = $pos->asVector3();
$this->addChunkPacket($pos->x >> 4, $pos->z >> 4, $pk); $this->addChunkPacket($pos->x >> 4, $pos->z >> 4, $pk);
} }
@ -2922,25 +2920,4 @@ class Level implements ChunkManager, Metadatable{
public function removeMetadata($metadataKey, Plugin $plugin){ public function removeMetadata($metadataKey, Plugin $plugin){
$this->server->getLevelMetadata()->removeMetadata($this, $metadataKey, $plugin); $this->server->getLevelMetadata()->removeMetadata($this, $metadataKey, $plugin);
} }
public function addEntityMotion(int $chunkX, int $chunkZ, int $entityId, float $x, float $y, float $z){
$pk = new SetEntityMotionPacket();
$pk->entityRuntimeId = $entityId;
$pk->motionX = $x;
$pk->motionY = $y;
$pk->motionZ = $z;
$this->addChunkPacket($chunkX, $chunkZ, $pk);
}
public function addEntityMovement(int $chunkX, int $chunkZ, int $entityId, float $x, float $y, float $z, float $yaw, float $pitch, $headYaw = null){
$pk = new MoveEntityPacket();
$pk->entityRuntimeId = $entityId;
$pk->x = $x;
$pk->y = $y;
$pk->z = $z;
$pk->yaw = $yaw;
$pk->pitch = $pitch;
$pk->headYaw = $headYaw ?? $yaw;
$this->addChunkPacket($chunkX, $chunkZ, $pk);
}
} }

View File

@ -39,9 +39,7 @@ class DestroyBlockParticle extends Particle{
public function encode(){ public function encode(){
$pk = new LevelEventPacket; $pk = new LevelEventPacket;
$pk->evid = LevelEventPacket::EVENT_PARTICLE_DESTROY; $pk->evid = LevelEventPacket::EVENT_PARTICLE_DESTROY;
$pk->x = $this->x; $pk->position = $this->asVector3();
$pk->y = $this->y;
$pk->z = $this->z;
$pk->data = $this->data; $pk->data = $this->data;
return $pk; return $pk;

View File

@ -81,12 +81,7 @@ class FloatingTextParticle extends Particle{
$pk = new AddEntityPacket(); $pk = new AddEntityPacket();
$pk->entityRuntimeId = $this->entityId; $pk->entityRuntimeId = $this->entityId;
$pk->type = ItemEntity::NETWORK_ID; $pk->type = ItemEntity::NETWORK_ID;
$pk->x = $this->x; $pk->position = $this->asVector3()->subtract(0, 0.75, 0);
$pk->y = $this->y - 0.75;
$pk->z = $this->z;
$pk->speedX = 0;
$pk->speedY = 0;
$pk->speedZ = 0;
$pk->yaw = 0; $pk->yaw = 0;
$pk->pitch = 0; $pk->pitch = 0;
$flags = ( $flags = (

View File

@ -40,9 +40,7 @@ class GenericParticle extends Particle{
public function encode(){ public function encode(){
$pk = new LevelEventPacket; $pk = new LevelEventPacket;
$pk->evid = LevelEventPacket::EVENT_ADD_PARTICLE_MASK | $this->id; $pk->evid = LevelEventPacket::EVENT_ADD_PARTICLE_MASK | $this->id;
$pk->x = $this->x; $pk->position = $this->asVector3();
$pk->y = $this->y;
$pk->z = $this->z;
$pk->data = $this->data; $pk->data = $this->data;
return $pk; return $pk;

View File

@ -40,9 +40,7 @@ class MobSpawnParticle extends Particle{
public function encode(){ public function encode(){
$pk = new LevelEventPacket; $pk = new LevelEventPacket;
$pk->evid = LevelEventPacket::EVENT_PARTICLE_SPAWN; $pk->evid = LevelEventPacket::EVENT_PARTICLE_SPAWN;
$pk->x = $this->x; $pk->position = $this->asVector3();
$pk->y = $this->y;
$pk->z = $this->z;
$pk->data = ($this->width & 0xff) + (($this->height & 0xff) << 8); $pk->data = ($this->width & 0xff) + (($this->height & 0xff) << 8);
return $pk; return $pk;

View File

@ -49,9 +49,7 @@ class GenericSound extends Sound{
public function encode(){ public function encode(){
$pk = new LevelEventPacket; $pk = new LevelEventPacket;
$pk->evid = $this->id; $pk->evid = $this->id;
$pk->x = $this->x; $pk->position = $this->asVector3();
$pk->y = $this->y;
$pk->z = $this->z;
$pk->data = (int) $this->pitch; $pk->data = (int) $this->pitch;
return $pk; return $pk;

View File

@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h> #include <rules/DataPacket.h>
use pocketmine\entity\Attribute; use pocketmine\entity\Attribute;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
class AddEntityPacket extends DataPacket{ class AddEntityPacket extends DataPacket{
@ -35,26 +36,30 @@ class AddEntityPacket extends DataPacket{
public $entityUniqueId = null; //TODO public $entityUniqueId = null; //TODO
/** @var int */ /** @var int */
public $entityRuntimeId; public $entityRuntimeId;
/** @var int */
public $type; public $type;
public $x; /** @var Vector3 */
public $y; public $position;
public $z; /** @var Vector3|null */
public $speedX = 0.0; public $motion;
public $speedY = 0.0; /** @var float */
public $speedZ = 0.0;
public $yaw = 0.0; public $yaw = 0.0;
/** @var float */
public $pitch = 0.0; public $pitch = 0.0;
/** @var Attribute[] */ /** @var Attribute[] */
public $attributes = []; public $attributes = [];
/** @var array */
public $metadata = []; public $metadata = [];
/** @var array */
public $links = []; public $links = [];
protected function decodePayload(){ protected function decodePayload(){
$this->entityUniqueId = $this->getEntityUniqueId(); $this->entityUniqueId = $this->getEntityUniqueId();
$this->entityRuntimeId = $this->getEntityRuntimeId(); $this->entityRuntimeId = $this->getEntityRuntimeId();
$this->type = $this->getUnsignedVarInt(); $this->type = $this->getUnsignedVarInt();
$this->getVector3f($this->x, $this->y, $this->z); $this->position = $this->getVector3Obj();
$this->getVector3f($this->speedX, $this->speedY, $this->speedZ); $this->motion = $this->getVector3Obj();
$this->pitch = $this->getLFloat(); $this->pitch = $this->getLFloat();
$this->yaw = $this->getLFloat(); $this->yaw = $this->getLFloat();
@ -87,8 +92,8 @@ class AddEntityPacket extends DataPacket{
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId); $this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
$this->putEntityRuntimeId($this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId);
$this->putUnsignedVarInt($this->type); $this->putUnsignedVarInt($this->type);
$this->putVector3f($this->x, $this->y, $this->z); $this->putVector3Obj($this->position);
$this->putVector3f($this->speedX, $this->speedY, $this->speedZ); $this->putVector3ObjNullable($this->motion);
$this->putLFloat($this->pitch); $this->putLFloat($this->pitch);
$this->putLFloat($this->yaw); $this->putLFloat($this->yaw);

View File

@ -30,11 +30,17 @@ use pocketmine\network\mcpe\NetworkSession;
class AddHangingEntityPacket extends DataPacket{ class AddHangingEntityPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::ADD_HANGING_ENTITY_PACKET; const NETWORK_ID = ProtocolInfo::ADD_HANGING_ENTITY_PACKET;
/** @var int */
public $entityUniqueId; public $entityUniqueId;
/** @var int */
public $entityRuntimeId; public $entityRuntimeId;
/** @var int */
public $x; public $x;
/** @var int */
public $y; public $y;
/** @var int */
public $z; public $z;
/** @var int */
public $unknown; //TODO (rotation?) public $unknown; //TODO (rotation?)
protected function decodePayload(){ protected function decodePayload(){

View File

@ -25,7 +25,8 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h> #include <rules/DataPacket.h>
use pocketmine\item\Item;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
class AddItemEntityPacket extends DataPacket{ class AddItemEntityPacket extends DataPacket{
@ -35,21 +36,21 @@ class AddItemEntityPacket extends DataPacket{
public $entityUniqueId = null; //TODO public $entityUniqueId = null; //TODO
/** @var int */ /** @var int */
public $entityRuntimeId; public $entityRuntimeId;
/** @var Item */
public $item; public $item;
public $x; /** @var Vector3 */
public $y; public $position;
public $z; /** @var Vector3|null */
public $speedX = 0.0; public $motion;
public $speedY = 0.0; /** @var array */
public $speedZ = 0.0;
public $metadata = []; public $metadata = [];
protected function decodePayload(){ protected function decodePayload(){
$this->entityUniqueId = $this->getEntityUniqueId(); $this->entityUniqueId = $this->getEntityUniqueId();
$this->entityRuntimeId = $this->getEntityRuntimeId(); $this->entityRuntimeId = $this->getEntityRuntimeId();
$this->item = $this->getSlot(); $this->item = $this->getSlot();
$this->getVector3f($this->x, $this->y, $this->z); $this->position = $this->getVector3Obj();
$this->getVector3f($this->speedX, $this->speedY, $this->speedZ); $this->motion = $this->getVector3Obj();
$this->metadata = $this->getEntityMetadata(); $this->metadata = $this->getEntityMetadata();
} }
@ -57,8 +58,8 @@ class AddItemEntityPacket extends DataPacket{
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId); $this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
$this->putEntityRuntimeId($this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId);
$this->putSlot($this->item); $this->putSlot($this->item);
$this->putVector3f($this->x, $this->y, $this->z); $this->putVector3Obj($this->position);
$this->putVector3f($this->speedX, $this->speedY, $this->speedZ); $this->putVector3ObjNullable($this->motion);
$this->putEntityMetadata($this->metadata); $this->putEntityMetadata($this->metadata);
} }

View File

@ -35,10 +35,15 @@ class AddPaintingPacket extends DataPacket{
public $entityUniqueId = null; //TODO public $entityUniqueId = null; //TODO
/** @var int */ /** @var int */
public $entityRuntimeId; public $entityRuntimeId;
/** @var int */
public $x; public $x;
/** @var int */
public $y; public $y;
/** @var int */
public $z; public $z;
/** @var int */
public $direction; public $direction;
/** @var string */
public $title; public $title;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h> #include <rules/DataPacket.h>
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
use pocketmine\utils\UUID; use pocketmine\utils\UUID;
@ -40,17 +41,19 @@ class AddPlayerPacket extends DataPacket{
public $entityUniqueId = null; //TODO public $entityUniqueId = null; //TODO
/** @var int */ /** @var int */
public $entityRuntimeId; public $entityRuntimeId;
public $x; /** @var Vector3 */
public $y; public $position;
public $z; /** @var Vector3|null */
public $speedX = 0.0; public $motion;
public $speedY = 0.0; /** @var float */
public $speedZ = 0.0;
public $pitch = 0.0; public $pitch = 0.0;
/** @var float|null */
public $headYaw = null; //TODO public $headYaw = null; //TODO
/** @var float */
public $yaw = 0.0; public $yaw = 0.0;
/** @var Item */ /** @var Item */
public $item; public $item;
/** @var array */
public $metadata = []; public $metadata = [];
//TODO: adventure settings stuff //TODO: adventure settings stuff
@ -68,8 +71,8 @@ class AddPlayerPacket extends DataPacket{
$this->username = $this->getString(); $this->username = $this->getString();
$this->entityUniqueId = $this->getEntityUniqueId(); $this->entityUniqueId = $this->getEntityUniqueId();
$this->entityRuntimeId = $this->getEntityRuntimeId(); $this->entityRuntimeId = $this->getEntityRuntimeId();
$this->getVector3f($this->x, $this->y, $this->z); $this->position = $this->getVector3Obj();
$this->getVector3f($this->speedX, $this->speedY, $this->speedZ); $this->motion = $this->getVector3Obj();
$this->pitch = $this->getLFloat(); $this->pitch = $this->getLFloat();
$this->headYaw = $this->getLFloat(); $this->headYaw = $this->getLFloat();
$this->yaw = $this->getLFloat(); $this->yaw = $this->getLFloat();
@ -94,8 +97,8 @@ class AddPlayerPacket extends DataPacket{
$this->putString($this->username); $this->putString($this->username);
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId); $this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
$this->putEntityRuntimeId($this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId);
$this->putVector3f($this->x, $this->y, $this->z); $this->putVector3Obj($this->position);
$this->putVector3f($this->speedX, $this->speedY, $this->speedZ); $this->putVector3ObjNullable($this->motion);
$this->putLFloat($this->pitch); $this->putLFloat($this->pitch);
$this->putLFloat($this->headYaw ?? $this->yaw); $this->putLFloat($this->headYaw ?? $this->yaw);
$this->putLFloat($this->yaw); $this->putLFloat($this->yaw);

View File

@ -65,10 +65,15 @@ class AdventureSettingsPacket extends DataPacket{
const OPERATOR = 0x20 | self::BITFLAG_SECOND_SET; const OPERATOR = 0x20 | self::BITFLAG_SECOND_SET;
const TELEPORT = 0x80 | self::BITFLAG_SECOND_SET; const TELEPORT = 0x80 | self::BITFLAG_SECOND_SET;
/** @var int */
public $flags = 0; public $flags = 0;
/** @var int */
public $commandPermission = self::PERMISSION_NORMAL; public $commandPermission = self::PERMISSION_NORMAL;
/** @var int */
public $flags2 = -1; public $flags2 = -1;
/** @var int */
public $playerPermission = PlayerPermissions::MEMBER; public $playerPermission = PlayerPermissions::MEMBER;
/** @var int */
public $entityUniqueId; //This is a little-endian long, NOT a var-long. (WTF Mojang) public $entityUniqueId; //This is a little-endian long, NOT a var-long. (WTF Mojang)
protected function decodePayload(){ protected function decodePayload(){

View File

@ -36,8 +36,11 @@ class AnimatePacket extends DataPacket{
const ACTION_STOP_SLEEP = 3; const ACTION_STOP_SLEEP = 3;
const ACTION_CRITICAL_HIT = 4; const ACTION_CRITICAL_HIT = 4;
/** @var int */
public $action; public $action;
/** @var int */
public $entityRuntimeId; public $entityRuntimeId;
/** @var float */
public $float = 0.0; //TODO (Boat rowing time?) public $float = 0.0; //TODO (Boat rowing time?)
protected function decodePayload(){ protected function decodePayload(){

View File

@ -31,9 +31,13 @@ use pocketmine\network\mcpe\NetworkSession;
class BlockEntityDataPacket extends DataPacket{ class BlockEntityDataPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::BLOCK_ENTITY_DATA_PACKET; const NETWORK_ID = ProtocolInfo::BLOCK_ENTITY_DATA_PACKET;
/** @var int */
public $x; public $x;
/** @var int */
public $y; public $y;
/** @var int */
public $z; public $z;
/** @var string */
public $namedtag; public $namedtag;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -31,10 +31,15 @@ use pocketmine\network\mcpe\NetworkSession;
class BlockEventPacket extends DataPacket{ class BlockEventPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::BLOCK_EVENT_PACKET; const NETWORK_ID = ProtocolInfo::BLOCK_EVENT_PACKET;
/** @var int */
public $x; public $x;
/** @var int */
public $y; public $y;
/** @var int */
public $z; public $z;
/** @var int */
public $case1; public $case1;
/** @var int */
public $case2; public $case2;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -32,10 +32,15 @@ use pocketmine\network\mcpe\NetworkSession;
class BlockPickRequestPacket extends DataPacket{ class BlockPickRequestPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::BLOCK_PICK_REQUEST_PACKET; const NETWORK_ID = ProtocolInfo::BLOCK_PICK_REQUEST_PACKET;
/** @var int */
public $tileX; public $tileX;
/** @var int */
public $tileY; public $tileY;
/** @var int */
public $tileZ; public $tileZ;
/** @var bool */
public $addUserData = false; public $addUserData = false;
/** @var int */
public $hotbarSlot; public $hotbarSlot;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -48,7 +48,9 @@ class BossEventPacket extends DataPacket{
/* S2C: Not implemented :( Intended to alter bar appearance, but these currently produce no effect on client-side whatsoever. */ /* S2C: Not implemented :( Intended to alter bar appearance, but these currently produce no effect on client-side whatsoever. */
const TYPE_TEXTURE = 7; const TYPE_TEXTURE = 7;
/** @var int */
public $bossEid; public $bossEid;
/** @var int */
public $eventType; public $eventType;
/** @var int (long) */ /** @var int (long) */

View File

@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h> #include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
class ChangeDimensionPacket extends DataPacket{ class ChangeDimensionPacket extends DataPacket{
@ -33,24 +34,20 @@ class ChangeDimensionPacket extends DataPacket{
/** @var int */ /** @var int */
public $dimension; public $dimension;
/** @var float */ /** @var Vector3 */
public $x; public $position;
/** @var float */
public $y;
/** @var float */
public $z;
/** @var bool */ /** @var bool */
public $respawn = false; public $respawn = false;
protected function decodePayload(){ protected function decodePayload(){
$this->dimension = $this->getVarInt(); $this->dimension = $this->getVarInt();
$this->getVector3f($this->x, $this->y, $this->z); $this->position = $this->getVector3Obj();
$this->respawn = $this->getBool(); $this->respawn = $this->getBool();
} }
protected function encodePayload(){ protected function encodePayload(){
$this->putVarInt($this->dimension); $this->putVarInt($this->dimension);
$this->putVector3f($this->x, $this->y, $this->z); $this->putVector3Obj($this->position);
$this->putBool($this->respawn); $this->putBool($this->respawn);
} }

View File

@ -31,6 +31,7 @@ use pocketmine\network\mcpe\NetworkSession;
class ChunkRadiusUpdatedPacket extends DataPacket{ class ChunkRadiusUpdatedPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::CHUNK_RADIUS_UPDATED_PACKET; const NETWORK_ID = ProtocolInfo::CHUNK_RADIUS_UPDATED_PACKET;
/** @var int */
public $radius; public $radius;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -36,16 +36,25 @@ class ClientboundMapItemDataPacket extends DataPacket{
const BITFLAG_TEXTURE_UPDATE = 0x02; const BITFLAG_TEXTURE_UPDATE = 0x02;
const BITFLAG_DECORATION_UPDATE = 0x04; const BITFLAG_DECORATION_UPDATE = 0x04;
/** @var int */
public $mapId; public $mapId;
/** @var int */
public $type; public $type;
/** @var int[] */
public $eids = []; public $eids = [];
/** @var int */
public $scale; public $scale;
/** @var array */
public $decorations = []; public $decorations = [];
/** @var int */
public $width; public $width;
/** @var int */
public $height; public $height;
/** @var int */
public $xOffset = 0; public $xOffset = 0;
/** @var int */
public $yOffset = 0; public $yOffset = 0;
/** @var Color[][] */ /** @var Color[][] */
public $colors = []; public $colors = [];

View File

@ -32,21 +32,32 @@ use pocketmine\network\mcpe\NetworkSession;
class CommandBlockUpdatePacket extends DataPacket{ class CommandBlockUpdatePacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::COMMAND_BLOCK_UPDATE_PACKET; const NETWORK_ID = ProtocolInfo::COMMAND_BLOCK_UPDATE_PACKET;
/** @var bool */
public $isBlock; public $isBlock;
/** @var int */
public $x; public $x;
/** @var int */
public $y; public $y;
/** @var int */
public $z; public $z;
/** @var int */
public $commandBlockMode; public $commandBlockMode;
/** @var bool */
public $isRedstoneMode; public $isRedstoneMode;
/** @var bool */
public $isConditional; public $isConditional;
/** @var int */
public $minecartEid; public $minecartEid;
/** @var string */
public $command; public $command;
/** @var string */
public $lastOutput; public $lastOutput;
/** @var string */
public $name; public $name;
/** @var bool */
public $shouldTrackOutput; public $shouldTrackOutput;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -30,6 +30,7 @@ use pocketmine\network\mcpe\NetworkSession;
class CommandRequestPacket extends DataPacket{ class CommandRequestPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::COMMAND_REQUEST_PACKET; const NETWORK_ID = ProtocolInfo::COMMAND_REQUEST_PACKET;
/** @var string */
public $command; public $command;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -31,6 +31,7 @@ use pocketmine\network\mcpe\NetworkSession;
class ContainerClosePacket extends DataPacket{ class ContainerClosePacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::CONTAINER_CLOSE_PACKET; const NETWORK_ID = ProtocolInfo::CONTAINER_CLOSE_PACKET;
/** @var int */
public $windowId; public $windowId;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -31,11 +31,17 @@ use pocketmine\network\mcpe\NetworkSession;
class ContainerOpenPacket extends DataPacket{ class ContainerOpenPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::CONTAINER_OPEN_PACKET; const NETWORK_ID = ProtocolInfo::CONTAINER_OPEN_PACKET;
/** @var int */
public $windowId; public $windowId;
/** @var int */
public $type; public $type;
/** @var int */
public $x; public $x;
/** @var int */
public $y; public $y;
/** @var int */
public $z; public $z;
/** @var int */
public $entityUniqueId = -1; public $entityUniqueId = -1;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -41,8 +41,11 @@ class ContainerSetDataPacket extends DataPacket{
const PROPERTY_BREWING_STAND_FUEL_AMOUNT = 1; const PROPERTY_BREWING_STAND_FUEL_AMOUNT = 1;
const PROPERTY_BREWING_STAND_FUEL_TOTAL = 2; const PROPERTY_BREWING_STAND_FUEL_TOTAL = 2;
/** @var int */
public $windowId; public $windowId;
/** @var int */
public $property; public $property;
/** @var int */
public $value; public $value;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -45,6 +45,7 @@ class CraftingDataPacket extends DataPacket{
/** @var object[] */ /** @var object[] */
public $entries = []; public $entries = [];
/** @var bool */
public $cleanRecipes = false; public $cleanRecipes = false;
public function clean(){ public function clean(){

View File

@ -32,7 +32,9 @@ use pocketmine\utils\UUID;
class CraftingEventPacket extends DataPacket{ class CraftingEventPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::CRAFTING_EVENT_PACKET; const NETWORK_ID = ProtocolInfo::CRAFTING_EVENT_PACKET;
/** @var int */
public $windowId; public $windowId;
/** @var int */
public $type; public $type;
/** @var UUID */ /** @var UUID */
public $id; public $id;

View File

@ -38,9 +38,12 @@ abstract class DataPacket extends BinaryStream{
const NETWORK_ID = 0; const NETWORK_ID = 0;
/** @var bool */
public $isEncoded = false; public $isEncoded = false;
/** @var int */
public $extraByte1 = 0; public $extraByte1 = 0;
/** @var int */
public $extraByte2 = 0; public $extraByte2 = 0;
public function pid(){ public function pid(){

View File

@ -31,7 +31,9 @@ use pocketmine\network\mcpe\NetworkSession;
class DisconnectPacket extends DataPacket{ class DisconnectPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::DISCONNECT_PACKET; const NETWORK_ID = ProtocolInfo::DISCONNECT_PACKET;
/** @var bool */
public $hideDisconnectionScreen = false; public $hideDisconnectionScreen = false;
/** @var string */
public $message; public $message;
public function canBeSentBeforeLogin() : bool{ public function canBeSentBeforeLogin() : bool{

View File

@ -50,8 +50,11 @@ class EntityEventPacket extends DataPacket{
//TODO: add more events //TODO: add more events
/** @var int */
public $entityRuntimeId; public $entityRuntimeId;
/** @var int */
public $event; public $event;
/** @var int */
public $data = 0; public $data = 0;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -31,8 +31,11 @@ use pocketmine\network\mcpe\NetworkSession;
class EntityFallPacket extends DataPacket{ class EntityFallPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::ENTITY_FALL_PACKET; const NETWORK_ID = ProtocolInfo::ENTITY_FALL_PACKET;
/** @var int */
public $entityRuntimeId; public $entityRuntimeId;
/** @var float */
public $fallDistance; public $fallDistance;
/** @var bool */
public $bool1; public $bool1;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -30,7 +30,9 @@ use pocketmine\network\mcpe\NetworkSession;
class EntityPickRequestPacket extends DataPacket{ class EntityPickRequestPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::ENTITY_PICK_REQUEST_PACKET; const NETWORK_ID = ProtocolInfo::ENTITY_PICK_REQUEST_PACKET;
/** @var int */
public $entityTypeId; public $entityTypeId;
/** @var int */
public $hotbarSlot; public $hotbarSlot;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -41,8 +41,11 @@ class EventPacket extends DataPacket{
const TYPE_AGENT_COMMAND = 8; const TYPE_AGENT_COMMAND = 8;
const TYPE_AGENT_CREATED = 9; const TYPE_AGENT_CREATED = 9;
/** @var int */
public $playerRuntimeId; public $playerRuntimeId;
/** @var int */
public $eventData; public $eventData;
/** @var int */
public $type; public $type;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -32,9 +32,8 @@ use pocketmine\network\mcpe\NetworkSession;
class ExplodePacket extends DataPacket{ class ExplodePacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::EXPLODE_PACKET; const NETWORK_ID = ProtocolInfo::EXPLODE_PACKET;
public $x; /** @var Vector3 */
public $y; public $position;
public $z;
/** @var float */ /** @var float */
public $radius; public $radius;
/** @var Vector3[] */ /** @var Vector3[] */
@ -46,7 +45,7 @@ class ExplodePacket extends DataPacket{
} }
protected function decodePayload(){ protected function decodePayload(){
$this->getVector3f($this->x, $this->y, $this->z); $this->position = $this->getVector3Obj();
$this->radius = (float) ($this->getVarInt() / 32); $this->radius = (float) ($this->getVarInt() / 32);
$count = $this->getUnsignedVarInt(); $count = $this->getUnsignedVarInt();
for($i = 0; $i < $count; ++$i){ for($i = 0; $i < $count; ++$i){
@ -57,7 +56,7 @@ class ExplodePacket extends DataPacket{
} }
protected function encodePayload(){ protected function encodePayload(){
$this->putVector3f($this->x, $this->y, $this->z); $this->putVector3Obj($this->position);
$this->putVarInt((int) ($this->radius * 32)); $this->putVarInt((int) ($this->radius * 32));
$this->putUnsignedVarInt(count($this->records)); $this->putUnsignedVarInt(count($this->records));
if(count($this->records) > 0){ if(count($this->records) > 0){

View File

@ -31,8 +31,11 @@ use pocketmine\network\mcpe\NetworkSession;
class FullChunkDataPacket extends DataPacket{ class FullChunkDataPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::FULL_CHUNK_DATA_PACKET; const NETWORK_ID = ProtocolInfo::FULL_CHUNK_DATA_PACKET;
/** @var int */
public $chunkX; public $chunkX;
/** @var int */
public $chunkZ; public $chunkZ;
/** @var string */
public $data; public $data;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -30,6 +30,7 @@ use pocketmine\network\mcpe\NetworkSession;
class GameRulesChangedPacket extends DataPacket{ class GameRulesChangedPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::GAME_RULES_CHANGED_PACKET; const NETWORK_ID = ProtocolInfo::GAME_RULES_CHANGED_PACKET;
/** @var array */
public $gameRules = []; public $gameRules = [];
protected function decodePayload(){ protected function decodePayload(){

View File

@ -31,6 +31,7 @@ use pocketmine\network\mcpe\NetworkSession;
class HurtArmorPacket extends DataPacket{ class HurtArmorPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::HURT_ARMOR_PACKET; const NETWORK_ID = ProtocolInfo::HURT_ARMOR_PACKET;
/** @var int */
public $health; public $health;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -53,6 +53,7 @@ class InteractPacket extends DataPacket{
$this->target = $this->getEntityRuntimeId(); $this->target = $this->getEntityRuntimeId();
if($this->action === self::ACTION_MOUSEOVER){ if($this->action === self::ACTION_MOUSEOVER){
//TODO: should this be a vector3?
$this->x = $this->getLFloat(); $this->x = $this->getLFloat();
$this->y = $this->getLFloat(); $this->y = $this->getLFloat();
$this->z = $this->getLFloat(); $this->z = $this->getLFloat();

View File

@ -95,6 +95,7 @@ class InventoryTransactionPacket extends DataPacket{
/** @var InventoryAction[] */ /** @var InventoryAction[] */
public $actions = []; public $actions = [];
/** @var \stdClass */
public $transactionData; public $transactionData;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -31,8 +31,11 @@ class ItemFrameDropItemPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::ITEM_FRAME_DROP_ITEM_PACKET; const NETWORK_ID = ProtocolInfo::ITEM_FRAME_DROP_ITEM_PACKET;
/** @var int */
public $x; public $x;
/** @var int */
public $y; public $y;
/** @var int */
public $z; public $z;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -25,6 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h> #include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
class LevelEventPacket extends DataPacket{ class LevelEventPacket extends DataPacket{
@ -100,21 +101,22 @@ class LevelEventPacket extends DataPacket{
const EVENT_ADD_PARTICLE_MASK = 0x4000; const EVENT_ADD_PARTICLE_MASK = 0x4000;
/** @var int */
public $evid; public $evid;
public $x = 0; //Weather effects don't have coordinates /** @var Vector3|null */
public $y = 0; public $position;
public $z = 0; /** @var int */
public $data; public $data;
protected function decodePayload(){ protected function decodePayload(){
$this->evid = $this->getVarInt(); $this->evid = $this->getVarInt();
$this->getVector3f($this->x, $this->y, $this->z); $this->position = $this->getVector3Obj();
$this->data = $this->getVarInt(); $this->data = $this->getVarInt();
} }
protected function encodePayload(){ protected function encodePayload(){
$this->putVarInt($this->evid); $this->putVarInt($this->evid);
$this->putVector3f($this->x, $this->y, $this->z); $this->putVector3ObjNullable($this->position);
$this->putVarInt($this->data); $this->putVarInt($this->data);
} }

View File

@ -25,6 +25,7 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h> #include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
class LevelSoundEventPacket extends DataPacket{ class LevelSoundEventPacket extends DataPacket{
@ -192,18 +193,22 @@ class LevelSoundEventPacket extends DataPacket{
const SOUND_DEFAULT = 161; const SOUND_DEFAULT = 161;
const SOUND_UNDEFINED = 162; const SOUND_UNDEFINED = 162;
/** @var int */
public $sound; public $sound;
public $x; /** @var Vector3 */
public $y; public $position;
public $z; /** @var int */
public $extraData = -1; public $extraData = -1;
/** @var int */
public $pitch = 1; public $pitch = 1;
/** @var bool */
public $unknownBool = false; public $unknownBool = false;
/** @var bool */
public $disableRelativeVolume = false; public $disableRelativeVolume = false;
protected function decodePayload(){ protected function decodePayload(){
$this->sound = $this->getByte(); $this->sound = $this->getByte();
$this->getVector3f($this->x, $this->y, $this->z); $this->position = $this->getVector3Obj();
$this->extraData = $this->getVarInt(); $this->extraData = $this->getVarInt();
$this->pitch = $this->getVarInt(); $this->pitch = $this->getVarInt();
$this->unknownBool = $this->getBool(); $this->unknownBool = $this->getBool();
@ -212,7 +217,7 @@ class LevelSoundEventPacket extends DataPacket{
protected function encodePayload(){ protected function encodePayload(){
$this->putByte($this->sound); $this->putByte($this->sound);
$this->putVector3f($this->x, $this->y, $this->z); $this->putVector3Obj($this->position);
$this->putVarInt($this->extraData); $this->putVarInt($this->extraData);
$this->putVarInt($this->pitch); $this->putVarInt($this->pitch);
$this->putBool($this->unknownBool); $this->putBool($this->unknownBool);

View File

@ -34,14 +34,22 @@ class LoginPacket extends DataPacket{
const EDITION_POCKET = 0; const EDITION_POCKET = 0;
/** @var string */
public $username; public $username;
/** @var int */
public $protocol; public $protocol;
/** @var string */
public $clientUUID; public $clientUUID;
/** @var int */
public $clientId; public $clientId;
/** @var string */
public $identityPublicKey; public $identityPublicKey;
/** @var string */
public $serverAddress; public $serverAddress;
/** @var string */
public $skinId; public $skinId;
/** @var string */
public $skin = ""; public $skin = "";
/** @var array (the "chain" index contains one or more JWTs) */ /** @var array (the "chain" index contains one or more JWTs) */

View File

@ -32,6 +32,7 @@ use pocketmine\network\mcpe\NetworkSession;
class MapInfoRequestPacket extends DataPacket{ class MapInfoRequestPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::MAP_INFO_REQUEST_PACKET; const NETWORK_ID = ProtocolInfo::MAP_INFO_REQUEST_PACKET;
/** @var int */
public $mapId; public $mapId;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -32,24 +32,23 @@ use pocketmine\network\mcpe\NetworkSession;
class MobArmorEquipmentPacket extends DataPacket{ class MobArmorEquipmentPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::MOB_ARMOR_EQUIPMENT_PACKET; const NETWORK_ID = ProtocolInfo::MOB_ARMOR_EQUIPMENT_PACKET;
/** @var int */
public $entityRuntimeId; public $entityRuntimeId;
/** @var Item[] */ /** @var Item[] */
public $slots = []; public $slots = [];
protected function decodePayload(){ protected function decodePayload(){
$this->entityRuntimeId = $this->getEntityRuntimeId(); $this->entityRuntimeId = $this->getEntityRuntimeId();
$this->slots[0] = $this->getSlot(); for($i = 0; $i < 4; ++$i){
$this->slots[1] = $this->getSlot(); $this->slots[$i] = $this->getSlot();
$this->slots[2] = $this->getSlot(); }
$this->slots[3] = $this->getSlot();
} }
protected function encodePayload(){ protected function encodePayload(){
$this->putEntityRuntimeId($this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId);
$this->putSlot($this->slots[0]); for($i = 0; $i < 4; ++$i){
$this->putSlot($this->slots[1]); $this->putSlot($this->slots[$i]);
$this->putSlot($this->slots[2]); }
$this->putSlot($this->slots[3]);
} }
public function handle(NetworkSession $session) : bool{ public function handle(NetworkSession $session) : bool{

View File

@ -35,11 +35,17 @@ class MobEffectPacket extends DataPacket{
const EVENT_MODIFY = 2; const EVENT_MODIFY = 2;
const EVENT_REMOVE = 3; const EVENT_REMOVE = 3;
/** @var int */
public $entityRuntimeId; public $entityRuntimeId;
/** @var int */
public $eventId; public $eventId;
/** @var int */
public $effectId; public $effectId;
/** @var int */
public $amplifier = 0; public $amplifier = 0;
/** @var bool */
public $particles = true; public $particles = true;
/** @var int */
public $duration = 0; public $duration = 0;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -26,15 +26,21 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h> #include <rules/DataPacket.h>
use pocketmine\item\Item;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
class MobEquipmentPacket extends DataPacket{ class MobEquipmentPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::MOB_EQUIPMENT_PACKET; const NETWORK_ID = ProtocolInfo::MOB_EQUIPMENT_PACKET;
/** @var int */
public $entityRuntimeId; public $entityRuntimeId;
/** @var Item */
public $item; public $item;
/** @var int */
public $inventorySlot; public $inventorySlot;
/** @var int */
public $hotbarSlot; public $hotbarSlot;
/** @var int */
public $windowId = 0; public $windowId = 0;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -26,24 +26,30 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h> #include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
class MoveEntityPacket extends DataPacket{ class MoveEntityPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::MOVE_ENTITY_PACKET; const NETWORK_ID = ProtocolInfo::MOVE_ENTITY_PACKET;
/** @var int */
public $entityRuntimeId; public $entityRuntimeId;
public $x; /** @var Vector3 */
public $y; public $position;
public $z; /** @var float */
public $yaw; public $yaw;
/** @var float */
public $headYaw; public $headYaw;
/** @var float */
public $pitch; public $pitch;
/** @var bool */
public $onGround = false; public $onGround = false;
/** @var bool */
public $teleported = false; public $teleported = false;
protected function decodePayload(){ protected function decodePayload(){
$this->entityRuntimeId = $this->getEntityRuntimeId(); $this->entityRuntimeId = $this->getEntityRuntimeId();
$this->getVector3f($this->x, $this->y, $this->z); $this->position = $this->getVector3Obj();
$this->pitch = $this->getByteRotation(); $this->pitch = $this->getByteRotation();
$this->headYaw = $this->getByteRotation(); $this->headYaw = $this->getByteRotation();
$this->yaw = $this->getByteRotation(); $this->yaw = $this->getByteRotation();
@ -53,7 +59,7 @@ class MoveEntityPacket extends DataPacket{
protected function encodePayload(){ protected function encodePayload(){
$this->putEntityRuntimeId($this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId);
$this->putVector3f($this->x, $this->y, $this->z); $this->putVector3Obj($this->position);
$this->putByteRotation($this->pitch); $this->putByteRotation($this->pitch);
$this->putByteRotation($this->headYaw); $this->putByteRotation($this->headYaw);
$this->putByteRotation($this->yaw); $this->putByteRotation($this->yaw);

View File

@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h> #include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
class MovePlayerPacket extends DataPacket{ class MovePlayerPacket extends DataPacket{
@ -36,22 +37,30 @@ class MovePlayerPacket extends DataPacket{
const MODE_TELEPORT = 2; const MODE_TELEPORT = 2;
const MODE_PITCH = 3; //facepalm Mojang const MODE_PITCH = 3; //facepalm Mojang
/** @var int */
public $entityRuntimeId; public $entityRuntimeId;
public $x; /** @var Vector3 */
public $y; public $position;
public $z; /** @var float */
public $yaw; public $yaw;
/** @var float */
public $bodyYaw; public $bodyYaw;
/** @var float */
public $pitch; public $pitch;
/** @var int */
public $mode = self::MODE_NORMAL; public $mode = self::MODE_NORMAL;
/** @var bool */
public $onGround = false; //TODO public $onGround = false; //TODO
/** @var int */
public $ridingEid = 0; public $ridingEid = 0;
/** @var int */
public $int1 = 0; public $int1 = 0;
/** @var int */
public $int2 = 0; public $int2 = 0;
protected function decodePayload(){ protected function decodePayload(){
$this->entityRuntimeId = $this->getEntityRuntimeId(); $this->entityRuntimeId = $this->getEntityRuntimeId();
$this->getVector3f($this->x, $this->y, $this->z); $this->position = $this->getVector3Obj();
$this->pitch = $this->getLFloat(); $this->pitch = $this->getLFloat();
$this->yaw = $this->getLFloat(); $this->yaw = $this->getLFloat();
$this->bodyYaw = $this->getLFloat(); $this->bodyYaw = $this->getLFloat();
@ -66,7 +75,7 @@ class MovePlayerPacket extends DataPacket{
protected function encodePayload(){ protected function encodePayload(){
$this->putEntityRuntimeId($this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId);
$this->putVector3f($this->x, $this->y, $this->z); $this->putVector3Obj($this->position);
$this->putLFloat($this->pitch); $this->putLFloat($this->pitch);
$this->putLFloat($this->yaw); $this->putLFloat($this->yaw);
$this->putLFloat($this->bodyYaw); //TODO $this->putLFloat($this->bodyYaw); //TODO

View File

@ -32,11 +32,17 @@ use pocketmine\network\mcpe\NetworkSession;
class PlaySoundPacket extends DataPacket{ class PlaySoundPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::PLAY_SOUND_PACKET; const NETWORK_ID = ProtocolInfo::PLAY_SOUND_PACKET;
/** @var string */
public $soundName; public $soundName;
/** @var int */
public $x; public $x;
/** @var int */
public $y; public $y;
/** @var int */
public $z; public $z;
/** @var float */
public $volume; public $volume;
/** @var float */
public $pitch; public $pitch;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -39,6 +39,7 @@ class PlayStatusPacket extends DataPacket{
const LOGIN_FAILED_VANILLA_EDU = 5; const LOGIN_FAILED_VANILLA_EDU = 5;
const LOGIN_FAILED_EDU_VANILLA = 6; const LOGIN_FAILED_EDU_VANILLA = 6;
/** @var int */
public $status; public $status;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -54,11 +54,17 @@ class PlayerActionPacket extends DataPacket{
const ACTION_RELEASE_ITEM = 99999; //TODO REMOVE const ACTION_RELEASE_ITEM = 99999; //TODO REMOVE
/** @var int */
public $entityRuntimeId; public $entityRuntimeId;
/** @var int */
public $action; public $action;
/** @var int */
public $x; public $x;
/** @var int */
public $y; public $y;
/** @var int */
public $z; public $z;
/** @var int */
public $face; public $face;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -31,9 +31,13 @@ use pocketmine\network\mcpe\NetworkSession;
class PlayerInputPacket extends DataPacket{ class PlayerInputPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::PLAYER_INPUT_PACKET; const NETWORK_ID = ProtocolInfo::PLAYER_INPUT_PACKET;
/** @var float */
public $motionX; public $motionX;
/** @var float */
public $motionY; public $motionY;
/** @var bool */
public $unknownBool1; public $unknownBool1;
/** @var bool */
public $unknownBool2; public $unknownBool2;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -37,6 +37,7 @@ class PlayerListPacket extends DataPacket{
//REMOVE: UUID, ADD: UUID, entity id, name, skinId, skin, geometric model, geometry data //REMOVE: UUID, ADD: UUID, entity id, name, skinId, skin, geometric model, geometry data
/** @var array[] */ /** @var array[] */
public $entries = []; public $entries = [];
/** @var int */
public $type; public $type;
public function clean(){ public function clean(){

View File

@ -31,6 +31,7 @@ use pocketmine\network\mcpe\NetworkSession;
class RemoveEntityPacket extends DataPacket{ class RemoveEntityPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::REMOVE_ENTITY_PACKET; const NETWORK_ID = ProtocolInfo::REMOVE_ENTITY_PACKET;
/** @var int */
public $entityUniqueId; public $entityUniqueId;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -31,6 +31,7 @@ use pocketmine\network\mcpe\NetworkSession;
class RequestChunkRadiusPacket extends DataPacket{ class RequestChunkRadiusPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::REQUEST_CHUNK_RADIUS_PACKET; const NETWORK_ID = ProtocolInfo::REQUEST_CHUNK_RADIUS_PACKET;
/** @var int */
public $radius; public $radius;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -32,9 +32,13 @@ use pocketmine\network\mcpe\NetworkSession;
class ResourcePackChunkDataPacket extends DataPacket{ class ResourcePackChunkDataPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_CHUNK_DATA_PACKET; const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_CHUNK_DATA_PACKET;
/** @var string */
public $packId; public $packId;
/** @var int */
public $chunkIndex; public $chunkIndex;
/** @var int */
public $progress; public $progress;
/** @var string */
public $data; public $data;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -32,7 +32,9 @@ use pocketmine\network\mcpe\NetworkSession;
class ResourcePackChunkRequestPacket extends DataPacket{ class ResourcePackChunkRequestPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_CHUNK_REQUEST_PACKET; const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_CHUNK_REQUEST_PACKET;
/** @var string */
public $packId; public $packId;
/** @var int */
public $chunkIndex; public $chunkIndex;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -36,7 +36,9 @@ class ResourcePackClientResponsePacket extends DataPacket{
const STATUS_HAVE_ALL_PACKS = 3; const STATUS_HAVE_ALL_PACKS = 3;
const STATUS_COMPLETED = 4; const STATUS_COMPLETED = 4;
/** @var int */
public $status; public $status;
/** @var string[] */
public $packIds = []; public $packIds = [];
protected function decodePayload(){ protected function decodePayload(){

View File

@ -32,10 +32,15 @@ use pocketmine\network\mcpe\NetworkSession;
class ResourcePackDataInfoPacket extends DataPacket{ class ResourcePackDataInfoPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_DATA_INFO_PACKET; const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_DATA_INFO_PACKET;
/** @var string */
public $packId; public $packId;
/** @var int */
public $maxChunkSize; public $maxChunkSize;
/** @var int */
public $chunkCount; public $chunkCount;
/** @var int */
public $compressedPackSize; public $compressedPackSize;
/** @var string */
public $sha256; public $sha256;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -34,6 +34,7 @@ use pocketmine\resourcepacks\ResourcePackInfoEntry;
class ResourcePackStackPacket extends DataPacket{ class ResourcePackStackPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_STACK_PACKET; const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_STACK_PACKET;
/** @var bool */
public $mustAccept = false; public $mustAccept = false;
/** @var ResourcePack[] */ /** @var ResourcePack[] */

View File

@ -33,6 +33,7 @@ use pocketmine\resourcepacks\ResourcePackInfoEntry;
class ResourcePacksInfoPacket extends DataPacket{ class ResourcePacksInfoPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::RESOURCE_PACKS_INFO_PACKET; const NETWORK_ID = ProtocolInfo::RESOURCE_PACKS_INFO_PACKET;
/** @var bool */
public $mustAccept = false; //if true, forces client to use selected resource packs public $mustAccept = false; //if true, forces client to use selected resource packs
/** @var ResourcePack[] */ /** @var ResourcePack[] */
public $behaviorPackEntries = []; public $behaviorPackEntries = [];

View File

@ -26,21 +26,21 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h> #include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
class RespawnPacket extends DataPacket{ class RespawnPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::RESPAWN_PACKET; const NETWORK_ID = ProtocolInfo::RESPAWN_PACKET;
public $x; /** @var Vector3 */
public $y; public $position;
public $z;
protected function decodePayload(){ protected function decodePayload(){
$this->getVector3f($this->x, $this->y, $this->z); $this->position = $this->getVector3Obj();
} }
protected function encodePayload(){ protected function encodePayload(){
$this->putVector3f($this->x, $this->y, $this->z); $this->putVector3Obj($this->position);
} }
public function handle(NetworkSession $session) : bool{ public function handle(NetworkSession $session) : bool{

View File

@ -32,6 +32,7 @@ use pocketmine\network\mcpe\NetworkSession;
class RiderJumpPacket extends DataPacket{ class RiderJumpPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::RIDER_JUMP_PACKET; const NETWORK_ID = ProtocolInfo::RIDER_JUMP_PACKET;
/** @var int */
public $unknown; public $unknown;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -31,6 +31,7 @@ use pocketmine\network\mcpe\NetworkSession;
class SetCommandsEnabledPacket extends DataPacket{ class SetCommandsEnabledPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::SET_COMMANDS_ENABLED_PACKET; const NETWORK_ID = ProtocolInfo::SET_COMMANDS_ENABLED_PACKET;
/** @var bool */
public $enabled; public $enabled;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -31,6 +31,7 @@ use pocketmine\network\mcpe\NetworkSession;
class SetDifficultyPacket extends DataPacket{ class SetDifficultyPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::SET_DIFFICULTY_PACKET; const NETWORK_ID = ProtocolInfo::SET_DIFFICULTY_PACKET;
/** @var int */
public $difficulty; public $difficulty;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -31,7 +31,9 @@ use pocketmine\network\mcpe\NetworkSession;
class SetEntityDataPacket extends DataPacket{ class SetEntityDataPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::SET_ENTITY_DATA_PACKET; const NETWORK_ID = ProtocolInfo::SET_ENTITY_DATA_PACKET;
/** @var int */
public $entityRuntimeId; public $entityRuntimeId;
/** @var array */
public $metadata; public $metadata;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -26,24 +26,25 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h> #include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
class SetEntityMotionPacket extends DataPacket{ class SetEntityMotionPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::SET_ENTITY_MOTION_PACKET; const NETWORK_ID = ProtocolInfo::SET_ENTITY_MOTION_PACKET;
/** @var int */
public $entityRuntimeId; public $entityRuntimeId;
public $motionX; /** @var Vector3 */
public $motionY; public $motion;
public $motionZ;
protected function decodePayload(){ protected function decodePayload(){
$this->entityRuntimeId = $this->getEntityRuntimeId(); $this->entityRuntimeId = $this->getEntityRuntimeId();
$this->getVector3f($this->motionX, $this->motionY, $this->motionZ); $this->motion = $this->getVector3Obj();
} }
protected function encodePayload(){ protected function encodePayload(){
$this->putEntityRuntimeId($this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId);
$this->putVector3f($this->motionX, $this->motionY, $this->motionZ); $this->putVector3Obj($this->motion);
} }
public function handle(NetworkSession $session) : bool{ public function handle(NetworkSession $session) : bool{

View File

@ -31,6 +31,7 @@ use pocketmine\network\mcpe\NetworkSession;
class SetHealthPacket extends DataPacket{ class SetHealthPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::SET_HEALTH_PACKET; const NETWORK_ID = ProtocolInfo::SET_HEALTH_PACKET;
/** @var int */
public $health; public $health;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -30,6 +30,7 @@ use pocketmine\network\mcpe\NetworkSession;
class SetLastHurtByPacket extends DataPacket{ class SetLastHurtByPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::SET_LAST_HURT_BY_PACKET; const NETWORK_ID = ProtocolInfo::SET_LAST_HURT_BY_PACKET;
/** @var int */
public $entityTypeId; public $entityTypeId;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -31,6 +31,7 @@ use pocketmine\network\mcpe\NetworkSession;
class SetPlayerGameTypePacket extends DataPacket{ class SetPlayerGameTypePacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::SET_PLAYER_GAME_TYPE_PACKET; const NETWORK_ID = ProtocolInfo::SET_PLAYER_GAME_TYPE_PACKET;
/** @var int */
public $gamemode; public $gamemode;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -34,10 +34,15 @@ class SetSpawnPositionPacket extends DataPacket{
const TYPE_PLAYER_SPAWN = 0; const TYPE_PLAYER_SPAWN = 0;
const TYPE_WORLD_SPAWN = 1; const TYPE_WORLD_SPAWN = 1;
/** @var int */
public $spawnType; public $spawnType;
/** @var int */
public $x; public $x;
/** @var int */
public $y; public $y;
/** @var int */
public $z; public $z;
/** @var bool */
public $spawnForced; public $spawnForced;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -30,6 +30,7 @@ use pocketmine\network\mcpe\NetworkSession;
class SetTimePacket extends DataPacket{ class SetTimePacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::SET_TIME_PACKET; const NETWORK_ID = ProtocolInfo::SET_TIME_PACKET;
/** @var int */
public $time; public $time;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -39,10 +39,15 @@ class SetTitlePacket extends DataPacket{
const TYPE_SET_ACTIONBAR_MESSAGE = 4; const TYPE_SET_ACTIONBAR_MESSAGE = 4;
const TYPE_SET_ANIMATION_TIMES = 5; const TYPE_SET_ANIMATION_TIMES = 5;
/** @var int */
public $type; public $type;
/** @var string */
public $text = ""; public $text = "";
/** @var int */
public $fadeInTime = 0; public $fadeInTime = 0;
/** @var int */
public $stayTime = 0; public $stayTime = 0;
/** @var int */
public $fadeOutTime = 0; public $fadeOutTime = 0;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -35,7 +35,9 @@ class ShowCreditsPacket extends DataPacket{
const STATUS_START_CREDITS = 0; const STATUS_START_CREDITS = 0;
const STATUS_END_CREDITS = 1; const STATUS_END_CREDITS = 1;
/** @var int */
public $playerEid; public $playerEid;
/** @var int */
public $status; public $status;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -30,8 +30,11 @@ use pocketmine\network\mcpe\NetworkSession;
class ShowStoreOfferPacket extends DataPacket{ class ShowStoreOfferPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::SHOW_STORE_OFFER_PACKET; const NETWORK_ID = ProtocolInfo::SHOW_STORE_OFFER_PACKET;
/** @var string */
public $offerId; public $offerId;
/** @var bool */
public $unknownBool; public $unknownBool;
/** @var string */
public $unknownString; public $unknownString;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -30,6 +30,7 @@ use pocketmine\network\mcpe\NetworkSession;
class SimpleEventPacket extends DataPacket{ class SimpleEventPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::SIMPLE_EVENT_PACKET; const NETWORK_ID = ProtocolInfo::SIMPLE_EVENT_PACKET;
/** @var int */
public $unknownShort1; public $unknownShort1;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -26,23 +26,24 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h> #include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
class SpawnExperienceOrbPacket extends DataPacket{ class SpawnExperienceOrbPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::SPAWN_EXPERIENCE_ORB_PACKET; const NETWORK_ID = ProtocolInfo::SPAWN_EXPERIENCE_ORB_PACKET;
public $x; /** @var Vector3 */
public $y; public $position;
public $z; /** @var int */
public $amount; public $amount;
protected function decodePayload(){ protected function decodePayload(){
$this->getVector3f($this->x, $this->y, $this->z); $this->position = $this->getVector3Obj();
$this->amount = $this->getVarInt(); $this->amount = $this->getVarInt();
} }
protected function encodePayload(){ protected function encodePayload(){
$this->putVector3f($this->x, $this->y, $this->z); $this->putVector3Obj($this->position);
$this->putVarInt($this->amount); $this->putVarInt($this->amount);
} }

View File

@ -26,54 +26,88 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h> #include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
use pocketmine\network\mcpe\protocol\types\PlayerPermissions; use pocketmine\network\mcpe\protocol\types\PlayerPermissions;
class StartGamePacket extends DataPacket{ class StartGamePacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::START_GAME_PACKET; const NETWORK_ID = ProtocolInfo::START_GAME_PACKET;
/** @var int */
public $entityUniqueId; public $entityUniqueId;
/** @var int */
public $entityRuntimeId; public $entityRuntimeId;
/** @var int */
public $playerGamemode; public $playerGamemode;
public $x; /** @var Vector3 */
public $y; public $playerPosition;
public $z;
/** @var float */
public $pitch; public $pitch;
/** @var float */
public $yaw; public $yaw;
/** @var int */
public $seed; public $seed;
/** @var int */
public $dimension; public $dimension;
/** @var int */
public $generator = 1; //default infinite - 0 old, 1 infinite, 2 flat public $generator = 1; //default infinite - 0 old, 1 infinite, 2 flat
/** @var int */
public $worldGamemode; public $worldGamemode;
/** @var int */
public $difficulty; public $difficulty;
/** @var int */
public $spawnX; public $spawnX;
/** @var int*/
public $spawnY; public $spawnY;
/** @var int */
public $spawnZ; public $spawnZ;
/** @var bool */
public $hasAchievementsDisabled = true; public $hasAchievementsDisabled = true;
/** @var int */
public $time = -1; public $time = -1;
/** @var bool */
public $eduMode = false; public $eduMode = false;
/** @var float */
public $rainLevel; public $rainLevel;
/** @var float */
public $lightningLevel; public $lightningLevel;
/** @var bool */
public $isMultiplayerGame = true; public $isMultiplayerGame = true;
/** @var bool */
public $hasLANBroadcast = true; public $hasLANBroadcast = true;
/** @var bool */
public $hasXboxLiveBroadcast = false; public $hasXboxLiveBroadcast = false;
/** @var bool */
public $commandsEnabled; public $commandsEnabled;
/** @var bool */
public $isTexturePacksRequired = true; public $isTexturePacksRequired = true;
/** @var array */
public $gameRules = []; //TODO: implement this public $gameRules = []; //TODO: implement this
/** @var bool */
public $hasBonusChestEnabled = false; public $hasBonusChestEnabled = false;
/** @var bool */
public $hasStartWithMapEnabled = false; public $hasStartWithMapEnabled = false;
/** @var bool */
public $hasTrustPlayersEnabled = false; public $hasTrustPlayersEnabled = false;
/** @var int */
public $defaultPlayerPermission = PlayerPermissions::MEMBER; //TODO public $defaultPlayerPermission = PlayerPermissions::MEMBER; //TODO
/** @var int */
public $xboxLiveBroadcastMode = 0; //TODO: find values public $xboxLiveBroadcastMode = 0; //TODO: find values
/** @var string */
public $levelId = ""; //base64 string, usually the same as world folder name in vanilla public $levelId = ""; //base64 string, usually the same as world folder name in vanilla
/** @var string */
public $worldName; public $worldName;
/** @var string */
public $premiumWorldTemplateId = ""; public $premiumWorldTemplateId = "";
/** @var bool */
public $unknownBool = false; public $unknownBool = false;
/** @var int */
public $currentTick = 0; public $currentTick = 0;
/** @var int */
public $unknownVarInt = 0; public $unknownVarInt = 0;
protected function decodePayload(){ protected function decodePayload(){
@ -81,7 +115,7 @@ class StartGamePacket extends DataPacket{
$this->entityRuntimeId = $this->getEntityRuntimeId(); $this->entityRuntimeId = $this->getEntityRuntimeId();
$this->playerGamemode = $this->getVarInt(); $this->playerGamemode = $this->getVarInt();
$this->getVector3f($this->x, $this->y, $this->z); $this->playerPosition = $this->getVector3Obj();
$this->pitch = $this->getLFloat(); $this->pitch = $this->getLFloat();
$this->yaw = $this->getLFloat(); $this->yaw = $this->getLFloat();
@ -124,7 +158,7 @@ class StartGamePacket extends DataPacket{
$this->putEntityRuntimeId($this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId);
$this->putVarInt($this->playerGamemode); $this->putVarInt($this->playerGamemode);
$this->putVector3f($this->x, $this->y, $this->z); $this->putVector3Obj($this->playerPosition);
$this->putLFloat($this->pitch); $this->putLFloat($this->pitch);
$this->putLFloat($this->yaw); $this->putLFloat($this->yaw);

View File

@ -32,7 +32,9 @@ use pocketmine\network\mcpe\NetworkSession;
class StopSoundPacket extends DataPacket{ class StopSoundPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::STOP_SOUND_PACKET; const NETWORK_ID = ProtocolInfo::STOP_SOUND_PACKET;
/** @var string */
public $soundName; public $soundName;
/** @var bool */
public $stopAll; public $stopAll;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -31,7 +31,9 @@ use pocketmine\network\mcpe\NetworkSession;
class TakeItemEntityPacket extends DataPacket{ class TakeItemEntityPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::TAKE_ITEM_ENTITY_PACKET; const NETWORK_ID = ProtocolInfo::TAKE_ITEM_ENTITY_PACKET;
/** @var int */
public $target; public $target;
/** @var int */
public $eid; public $eid;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -30,7 +30,9 @@ use pocketmine\network\mcpe\NetworkSession;
class TransferPacket extends DataPacket{ class TransferPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::TRANSFER_PACKET; const NETWORK_ID = ProtocolInfo::TRANSFER_PACKET;
/** @var string */
public $address; public $address;
/** @var int */
public $port = 19132; public $port = 19132;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -30,6 +30,7 @@ use pocketmine\network\mcpe\NetworkSession;
class UnknownPacket extends DataPacket{ class UnknownPacket extends DataPacket{
const NETWORK_ID = -1; //Invalid, do not try to write this const NETWORK_ID = -1; //Invalid, do not try to write this
/** @var string */
public $payload; public $payload;
public function pid(){ public function pid(){

View File

@ -32,6 +32,7 @@ use pocketmine\network\mcpe\NetworkSession;
class UpdateAttributesPacket extends DataPacket{ class UpdateAttributesPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::UPDATE_ATTRIBUTES_PACKET; const NETWORK_ID = ProtocolInfo::UPDATE_ATTRIBUTES_PACKET;
/** @var int */
public $entityRuntimeId; public $entityRuntimeId;
/** @var Attribute[] */ /** @var Attribute[] */
public $entries = []; public $entries = [];

View File

@ -40,11 +40,17 @@ class UpdateBlockPacket extends DataPacket{
const FLAG_ALL = self::FLAG_NEIGHBORS | self::FLAG_NETWORK; const FLAG_ALL = self::FLAG_NEIGHBORS | self::FLAG_NETWORK;
const FLAG_ALL_PRIORITY = self::FLAG_ALL | self::FLAG_PRIORITY; const FLAG_ALL_PRIORITY = self::FLAG_ALL | self::FLAG_PRIORITY;
/** @var int */
public $x; public $x;
/** @var int */
public $z; public $z;
/** @var int */
public $y; public $y;
/** @var int */
public $blockId; public $blockId;
/** @var int */
public $blockData; public $blockData;
/** @var int */
public $flags; public $flags;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -30,10 +30,15 @@ use pocketmine\network\mcpe\NetworkSession;
class UpdateEquipPacket extends DataPacket{ class UpdateEquipPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::UPDATE_EQUIP_PACKET; const NETWORK_ID = ProtocolInfo::UPDATE_EQUIP_PACKET;
/** @var int */
public $windowId; public $windowId;
/** @var int */
public $windowType; public $windowType;
/** @var int */
public $unknownVarint; //TODO: find out what this is (vanilla always sends 0) public $unknownVarint; //TODO: find out what this is (vanilla always sends 0)
/** @var int */
public $entityUniqueId; public $entityUniqueId;
/** @var string */
public $namedtag; public $namedtag;
protected function decodePayload(){ protected function decodePayload(){

View File

@ -34,14 +34,24 @@ class UpdateTradePacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::UPDATE_TRADE_PACKET; const NETWORK_ID = ProtocolInfo::UPDATE_TRADE_PACKET;
//TODO: find fields //TODO: find fields
/** @var int */
public $windowId; public $windowId;
/** @var int */
public $windowType = WindowTypes::TRADING; //Mojang hardcoded this -_- public $windowType = WindowTypes::TRADING; //Mojang hardcoded this -_-
/** @var int */
public $varint1; public $varint1;
/** @var int */
public $varint2; public $varint2;
/** @var bool */
public $isWilling; public $isWilling;
/** @var int */
public $traderEid; public $traderEid;
/** @var int */
public $playerEid; public $playerEid;
/** @var string */
public $displayName; public $displayName;
/** @var string */
public $offers; public $offers;
protected function decodePayload(){ protected function decodePayload(){