diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index f7032a1b3e..b2a0d52b3f 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -920,9 +920,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ protected function sendRespawnPacket(Vector3 $pos){ $pk = new RespawnPacket(); - $pk->x = $pos->x; - $pk->y = $pos->y + $this->baseOffset; - $pk->z = $pos->z; + $pk->position = $pos->add(0, $this->baseOffset, 0); + $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 $this->teleport($ev->getTo()); }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); //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){ if(parent::setMotion($mot)){ 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){ @@ -1865,9 +1864,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $pk->entityUniqueId = $this->id; $pk->entityRuntimeId = $this->id; $pk->playerGamemode = Player::getClientFriendlyGamemode($this->gamemode); - $pk->x = $this->x; - $pk->y = $this->y + $this->baseOffset; - $pk->z = $this->z; + + $pk->playerPosition = $this->getOffsetPosition(); + $pk->pitch = $this->pitch; $pk->yaw = $this->yaw; $pk->seed = -1; @@ -2086,7 +2085,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ } 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 $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->entityRuntimeId = $this->getId(); - $pk->x = $pos->x; - $pk->y = $pos->y + ($baseOffsetOverride ?? $this->baseOffset); - $pk->z = $pos->z; + $pk->position = $this->getOffsetPosition(); $pk->bodyYaw = $yaw; $pk->pitch = $pitch; $pk->yaw = $yaw; diff --git a/src/pocketmine/entity/Arrow.php b/src/pocketmine/entity/Arrow.php index eebbe5131c..4a062a7f7c 100644 --- a/src/pocketmine/entity/Arrow.php +++ b/src/pocketmine/entity/Arrow.php @@ -89,12 +89,9 @@ class Arrow extends Projectile{ $pk = new AddEntityPacket(); $pk->type = Arrow::NETWORK_ID; $pk->entityRuntimeId = $this->getId(); - $pk->x = $this->x; - $pk->y = $this->y; - $pk->z = $this->z; - $pk->speedX = $this->motionX; - $pk->speedY = $this->motionY; - $pk->speedZ = $this->motionZ; + $pk->position = $this->asVector3(); + $pk->motion = $this->getMotion(); + $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->metadata = $this->dataProperties; diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 962e8f1070..56140222fd 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -54,8 +54,10 @@ use pocketmine\nbt\tag\FloatTag; use pocketmine\nbt\tag\ListTag; use pocketmine\nbt\tag\ShortTag; use pocketmine\nbt\tag\StringTag; +use pocketmine\network\mcpe\protocol\MoveEntityPacket; use pocketmine\network\mcpe\protocol\RemoveEntityPacket; use pocketmine\network\mcpe\protocol\SetEntityDataPacket; +use pocketmine\network\mcpe\protocol\SetEntityMotionPacket; use pocketmine\Player; use pocketmine\plugin\Plugin; use pocketmine\Server; @@ -1146,7 +1148,7 @@ abstract class Entity extends Location implements Metadatable{ $this->lastYaw = $this->yaw; $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 @@ -1154,10 +1156,33 @@ abstract class Entity extends Location implements Metadatable{ $this->lastMotionY = $this->motionY; $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 */ diff --git a/src/pocketmine/entity/FallingSand.php b/src/pocketmine/entity/FallingSand.php index 87f6be8a7a..e314d1f938 100644 --- a/src/pocketmine/entity/FallingSand.php +++ b/src/pocketmine/entity/FallingSand.php @@ -148,12 +148,8 @@ class FallingSand extends Entity{ $pk = new AddEntityPacket(); $pk->type = FallingSand::NETWORK_ID; $pk->entityRuntimeId = $this->getId(); - $pk->x = $this->x; - $pk->y = $this->y; - $pk->z = $this->z; - $pk->speedX = $this->motionX; - $pk->speedY = $this->motionY; - $pk->speedZ = $this->motionZ; + $pk->position = $this->asVector3(); + $pk->motion = $this->getMotion(); $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->metadata = $this->dataProperties; diff --git a/src/pocketmine/entity/Human.php b/src/pocketmine/entity/Human.php index 68db995337..e8ca7bab93 100644 --- a/src/pocketmine/entity/Human.php +++ b/src/pocketmine/entity/Human.php @@ -515,12 +515,8 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ $pk->uuid = $this->getUniqueId(); $pk->username = $this->getName(); $pk->entityRuntimeId = $this->getId(); - $pk->x = $this->x; - $pk->y = $this->y; - $pk->z = $this->z; - $pk->speedX = $this->motionX; - $pk->speedY = $this->motionY; - $pk->speedZ = $this->motionZ; + $pk->position = $this->asVector3(); + $pk->motion = $this->getMotion(); $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->item = $this->getInventory()->getItemInHand(); diff --git a/src/pocketmine/entity/Item.php b/src/pocketmine/entity/Item.php index 335d43feba..22d5f3475a 100644 --- a/src/pocketmine/entity/Item.php +++ b/src/pocketmine/entity/Item.php @@ -234,12 +234,8 @@ class Item extends Entity{ public function spawnTo(Player $player){ $pk = new AddItemEntityPacket(); $pk->entityRuntimeId = $this->getId(); - $pk->x = $this->x; - $pk->y = $this->y; - $pk->z = $this->z; - $pk->speedX = $this->motionX; - $pk->speedY = $this->motionY; - $pk->speedZ = $this->motionZ; + $pk->position = $this->asVector3(); + $pk->motion = $this->getMotion(); $pk->item = $this->getItem(); $pk->metadata = $this->dataProperties; $player->dataPacket($pk); diff --git a/src/pocketmine/entity/PrimedTNT.php b/src/pocketmine/entity/PrimedTNT.php index c9d96b3e86..dcdd706b7b 100644 --- a/src/pocketmine/entity/PrimedTNT.php +++ b/src/pocketmine/entity/PrimedTNT.php @@ -149,12 +149,8 @@ class PrimedTNT extends Entity implements Explosive{ $pk = new AddEntityPacket(); $pk->type = PrimedTNT::NETWORK_ID; $pk->entityRuntimeId = $this->getId(); - $pk->x = $this->x; - $pk->y = $this->y; - $pk->z = $this->z; - $pk->speedX = $this->motionX; - $pk->speedY = $this->motionY; - $pk->speedZ = $this->motionZ; + $pk->position = $this->asVector3(); + $pk->motion = $this->getMotion(); $pk->metadata = $this->dataProperties; $player->dataPacket($pk); diff --git a/src/pocketmine/entity/Snowball.php b/src/pocketmine/entity/Snowball.php index 52a439d66f..532d4e3da5 100644 --- a/src/pocketmine/entity/Snowball.php +++ b/src/pocketmine/entity/Snowball.php @@ -65,12 +65,8 @@ class Snowball extends Projectile{ $pk = new AddEntityPacket(); $pk->type = Snowball::NETWORK_ID; $pk->entityRuntimeId = $this->getId(); - $pk->x = $this->x; - $pk->y = $this->y; - $pk->z = $this->z; - $pk->speedX = $this->motionX; - $pk->speedY = $this->motionY; - $pk->speedZ = $this->motionZ; + $pk->position = $this->asVector3(); + $pk->motion = $this->getMotion(); $pk->metadata = $this->dataProperties; $player->dataPacket($pk); diff --git a/src/pocketmine/entity/Squid.php b/src/pocketmine/entity/Squid.php index fbb7c41abb..a2ea247a2f 100644 --- a/src/pocketmine/entity/Squid.php +++ b/src/pocketmine/entity/Squid.php @@ -150,12 +150,8 @@ class Squid extends WaterAnimal{ $pk = new AddEntityPacket(); $pk->entityRuntimeId = $this->getId(); $pk->type = Squid::NETWORK_ID; - $pk->x = $this->x; - $pk->y = $this->y; - $pk->z = $this->z; - $pk->speedX = $this->motionX; - $pk->speedY = $this->motionY; - $pk->speedZ = $this->motionZ; + $pk->position = $this->asVector3(); + $pk->motion = $this->getMotion(); $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->metadata = $this->dataProperties; diff --git a/src/pocketmine/entity/Villager.php b/src/pocketmine/entity/Villager.php index fd757f4b61..2401fe9bfd 100644 --- a/src/pocketmine/entity/Villager.php +++ b/src/pocketmine/entity/Villager.php @@ -56,12 +56,8 @@ class Villager extends Creature implements NPC, Ageable{ $pk = new AddEntityPacket(); $pk->entityRuntimeId = $this->getId(); $pk->type = Villager::NETWORK_ID; - $pk->x = $this->x; - $pk->y = $this->y; - $pk->z = $this->z; - $pk->speedX = $this->motionX; - $pk->speedY = $this->motionY; - $pk->speedZ = $this->motionZ; + $pk->position = $this->asVector3(); + $pk->motion = $this->getMotion(); $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->metadata = $this->dataProperties; diff --git a/src/pocketmine/entity/Zombie.php b/src/pocketmine/entity/Zombie.php index e926ed282e..df38d9b95d 100644 --- a/src/pocketmine/entity/Zombie.php +++ b/src/pocketmine/entity/Zombie.php @@ -43,12 +43,8 @@ class Zombie extends Monster{ $pk = new AddEntityPacket(); $pk->entityRuntimeId = $this->getId(); $pk->type = Zombie::NETWORK_ID; - $pk->x = $this->x; - $pk->y = $this->y; - $pk->z = $this->z; - $pk->speedX = $this->motionX; - $pk->speedY = $this->motionY; - $pk->speedZ = $this->motionZ; + $pk->position = $this->asVector3(); + $pk->motion = $this->getMotion(); $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->metadata = $this->dataProperties; diff --git a/src/pocketmine/level/Explosion.php b/src/pocketmine/level/Explosion.php index 742f831f29..39ce70f27c 100644 --- a/src/pocketmine/level/Explosion.php +++ b/src/pocketmine/level/Explosion.php @@ -195,9 +195,7 @@ class Explosion{ } $pk = new ExplodePacket(); - $pk->x = $this->source->x; - $pk->y = $this->source->y; - $pk->z = $this->source->z; + $pk->position = $this->source->asVector3(); $pk->radius = $this->size; $pk->records = $send; $this->level->addChunkPacket($source->x >> 4, $source->z >> 4, $pk); diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index b702e29414..7c36e4acdc 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -97,8 +97,6 @@ use pocketmine\network\mcpe\protocol\BatchPacket; use pocketmine\network\mcpe\protocol\DataPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket; 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\UpdateBlockPacket; use pocketmine\Player; @@ -518,7 +516,7 @@ class Level implements ChunkManager, Metadatable{ $pk->extraData = $extraData; $pk->unknownBool = $unknown; $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); } @@ -2922,25 +2920,4 @@ class Level implements ChunkManager, Metadatable{ public function removeMetadata($metadataKey, Plugin $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); - } } diff --git a/src/pocketmine/level/particle/DestroyBlockParticle.php b/src/pocketmine/level/particle/DestroyBlockParticle.php index 8e1e1ca2a1..a245f08442 100644 --- a/src/pocketmine/level/particle/DestroyBlockParticle.php +++ b/src/pocketmine/level/particle/DestroyBlockParticle.php @@ -39,9 +39,7 @@ class DestroyBlockParticle extends Particle{ public function encode(){ $pk = new LevelEventPacket; $pk->evid = LevelEventPacket::EVENT_PARTICLE_DESTROY; - $pk->x = $this->x; - $pk->y = $this->y; - $pk->z = $this->z; + $pk->position = $this->asVector3(); $pk->data = $this->data; return $pk; diff --git a/src/pocketmine/level/particle/FloatingTextParticle.php b/src/pocketmine/level/particle/FloatingTextParticle.php index 1951151f2b..83a6f0022d 100644 --- a/src/pocketmine/level/particle/FloatingTextParticle.php +++ b/src/pocketmine/level/particle/FloatingTextParticle.php @@ -81,12 +81,7 @@ class FloatingTextParticle extends Particle{ $pk = new AddEntityPacket(); $pk->entityRuntimeId = $this->entityId; $pk->type = ItemEntity::NETWORK_ID; - $pk->x = $this->x; - $pk->y = $this->y - 0.75; - $pk->z = $this->z; - $pk->speedX = 0; - $pk->speedY = 0; - $pk->speedZ = 0; + $pk->position = $this->asVector3()->subtract(0, 0.75, 0); $pk->yaw = 0; $pk->pitch = 0; $flags = ( diff --git a/src/pocketmine/level/particle/GenericParticle.php b/src/pocketmine/level/particle/GenericParticle.php index a893aed537..156a2a5019 100644 --- a/src/pocketmine/level/particle/GenericParticle.php +++ b/src/pocketmine/level/particle/GenericParticle.php @@ -40,9 +40,7 @@ class GenericParticle extends Particle{ public function encode(){ $pk = new LevelEventPacket; $pk->evid = LevelEventPacket::EVENT_ADD_PARTICLE_MASK | $this->id; - $pk->x = $this->x; - $pk->y = $this->y; - $pk->z = $this->z; + $pk->position = $this->asVector3(); $pk->data = $this->data; return $pk; diff --git a/src/pocketmine/level/particle/MobSpawnParticle.php b/src/pocketmine/level/particle/MobSpawnParticle.php index 9745d5f041..62498c0673 100644 --- a/src/pocketmine/level/particle/MobSpawnParticle.php +++ b/src/pocketmine/level/particle/MobSpawnParticle.php @@ -40,9 +40,7 @@ class MobSpawnParticle extends Particle{ public function encode(){ $pk = new LevelEventPacket; $pk->evid = LevelEventPacket::EVENT_PARTICLE_SPAWN; - $pk->x = $this->x; - $pk->y = $this->y; - $pk->z = $this->z; + $pk->position = $this->asVector3(); $pk->data = ($this->width & 0xff) + (($this->height & 0xff) << 8); return $pk; diff --git a/src/pocketmine/level/sound/GenericSound.php b/src/pocketmine/level/sound/GenericSound.php index 945cd7b2e4..c7071d2ead 100644 --- a/src/pocketmine/level/sound/GenericSound.php +++ b/src/pocketmine/level/sound/GenericSound.php @@ -49,9 +49,7 @@ class GenericSound extends Sound{ public function encode(){ $pk = new LevelEventPacket; $pk->evid = $this->id; - $pk->x = $this->x; - $pk->y = $this->y; - $pk->z = $this->z; + $pk->position = $this->asVector3(); $pk->data = (int) $this->pitch; return $pk; diff --git a/src/pocketmine/network/mcpe/protocol/AddEntityPacket.php b/src/pocketmine/network/mcpe/protocol/AddEntityPacket.php index a310d6e338..17d74c5281 100644 --- a/src/pocketmine/network/mcpe/protocol/AddEntityPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AddEntityPacket.php @@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol; #include use pocketmine\entity\Attribute; +use pocketmine\math\Vector3; use pocketmine\network\mcpe\NetworkSession; class AddEntityPacket extends DataPacket{ @@ -35,26 +36,30 @@ class AddEntityPacket extends DataPacket{ public $entityUniqueId = null; //TODO /** @var int */ public $entityRuntimeId; + /** @var int */ public $type; - public $x; - public $y; - public $z; - public $speedX = 0.0; - public $speedY = 0.0; - public $speedZ = 0.0; + /** @var Vector3 */ + public $position; + /** @var Vector3|null */ + public $motion; + /** @var float */ public $yaw = 0.0; + /** @var float */ public $pitch = 0.0; + /** @var Attribute[] */ public $attributes = []; + /** @var array */ public $metadata = []; + /** @var array */ public $links = []; protected function decodePayload(){ $this->entityUniqueId = $this->getEntityUniqueId(); $this->entityRuntimeId = $this->getEntityRuntimeId(); $this->type = $this->getUnsignedVarInt(); - $this->getVector3f($this->x, $this->y, $this->z); - $this->getVector3f($this->speedX, $this->speedY, $this->speedZ); + $this->position = $this->getVector3Obj(); + $this->motion = $this->getVector3Obj(); $this->pitch = $this->getLFloat(); $this->yaw = $this->getLFloat(); @@ -87,8 +92,8 @@ class AddEntityPacket extends DataPacket{ $this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId); $this->putUnsignedVarInt($this->type); - $this->putVector3f($this->x, $this->y, $this->z); - $this->putVector3f($this->speedX, $this->speedY, $this->speedZ); + $this->putVector3Obj($this->position); + $this->putVector3ObjNullable($this->motion); $this->putLFloat($this->pitch); $this->putLFloat($this->yaw); diff --git a/src/pocketmine/network/mcpe/protocol/AddHangingEntityPacket.php b/src/pocketmine/network/mcpe/protocol/AddHangingEntityPacket.php index a3f895977d..201ce6260c 100644 --- a/src/pocketmine/network/mcpe/protocol/AddHangingEntityPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AddHangingEntityPacket.php @@ -30,11 +30,17 @@ use pocketmine\network\mcpe\NetworkSession; class AddHangingEntityPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::ADD_HANGING_ENTITY_PACKET; + /** @var int */ public $entityUniqueId; + /** @var int */ public $entityRuntimeId; + /** @var int */ public $x; + /** @var int */ public $y; + /** @var int */ public $z; + /** @var int */ public $unknown; //TODO (rotation?) protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/AddItemEntityPacket.php b/src/pocketmine/network/mcpe/protocol/AddItemEntityPacket.php index e0f16bee4a..87946a95ee 100644 --- a/src/pocketmine/network/mcpe/protocol/AddItemEntityPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AddItemEntityPacket.php @@ -25,7 +25,8 @@ namespace pocketmine\network\mcpe\protocol; #include - +use pocketmine\item\Item; +use pocketmine\math\Vector3; use pocketmine\network\mcpe\NetworkSession; class AddItemEntityPacket extends DataPacket{ @@ -35,21 +36,21 @@ class AddItemEntityPacket extends DataPacket{ public $entityUniqueId = null; //TODO /** @var int */ public $entityRuntimeId; + /** @var Item */ public $item; - public $x; - public $y; - public $z; - public $speedX = 0.0; - public $speedY = 0.0; - public $speedZ = 0.0; + /** @var Vector3 */ + public $position; + /** @var Vector3|null */ + public $motion; + /** @var array */ public $metadata = []; protected function decodePayload(){ $this->entityUniqueId = $this->getEntityUniqueId(); $this->entityRuntimeId = $this->getEntityRuntimeId(); $this->item = $this->getSlot(); - $this->getVector3f($this->x, $this->y, $this->z); - $this->getVector3f($this->speedX, $this->speedY, $this->speedZ); + $this->position = $this->getVector3Obj(); + $this->motion = $this->getVector3Obj(); $this->metadata = $this->getEntityMetadata(); } @@ -57,8 +58,8 @@ class AddItemEntityPacket extends DataPacket{ $this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId); $this->putSlot($this->item); - $this->putVector3f($this->x, $this->y, $this->z); - $this->putVector3f($this->speedX, $this->speedY, $this->speedZ); + $this->putVector3Obj($this->position); + $this->putVector3ObjNullable($this->motion); $this->putEntityMetadata($this->metadata); } diff --git a/src/pocketmine/network/mcpe/protocol/AddPaintingPacket.php b/src/pocketmine/network/mcpe/protocol/AddPaintingPacket.php index 30893d6364..550e393c42 100644 --- a/src/pocketmine/network/mcpe/protocol/AddPaintingPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AddPaintingPacket.php @@ -35,10 +35,15 @@ class AddPaintingPacket extends DataPacket{ public $entityUniqueId = null; //TODO /** @var int */ public $entityRuntimeId; + /** @var int */ public $x; + /** @var int */ public $y; + /** @var int */ public $z; + /** @var int */ public $direction; + /** @var string */ public $title; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/AddPlayerPacket.php b/src/pocketmine/network/mcpe/protocol/AddPlayerPacket.php index aaafda6276..68adb04641 100644 --- a/src/pocketmine/network/mcpe/protocol/AddPlayerPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AddPlayerPacket.php @@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol; #include use pocketmine\item\Item; +use pocketmine\math\Vector3; use pocketmine\network\mcpe\NetworkSession; use pocketmine\utils\UUID; @@ -40,17 +41,19 @@ class AddPlayerPacket extends DataPacket{ public $entityUniqueId = null; //TODO /** @var int */ public $entityRuntimeId; - public $x; - public $y; - public $z; - public $speedX = 0.0; - public $speedY = 0.0; - public $speedZ = 0.0; + /** @var Vector3 */ + public $position; + /** @var Vector3|null */ + public $motion; + /** @var float */ public $pitch = 0.0; + /** @var float|null */ public $headYaw = null; //TODO + /** @var float */ public $yaw = 0.0; /** @var Item */ public $item; + /** @var array */ public $metadata = []; //TODO: adventure settings stuff @@ -68,8 +71,8 @@ class AddPlayerPacket extends DataPacket{ $this->username = $this->getString(); $this->entityUniqueId = $this->getEntityUniqueId(); $this->entityRuntimeId = $this->getEntityRuntimeId(); - $this->getVector3f($this->x, $this->y, $this->z); - $this->getVector3f($this->speedX, $this->speedY, $this->speedZ); + $this->position = $this->getVector3Obj(); + $this->motion = $this->getVector3Obj(); $this->pitch = $this->getLFloat(); $this->headYaw = $this->getLFloat(); $this->yaw = $this->getLFloat(); @@ -94,8 +97,8 @@ class AddPlayerPacket extends DataPacket{ $this->putString($this->username); $this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId); $this->putEntityRuntimeId($this->entityRuntimeId); - $this->putVector3f($this->x, $this->y, $this->z); - $this->putVector3f($this->speedX, $this->speedY, $this->speedZ); + $this->putVector3Obj($this->position); + $this->putVector3ObjNullable($this->motion); $this->putLFloat($this->pitch); $this->putLFloat($this->headYaw ?? $this->yaw); $this->putLFloat($this->yaw); diff --git a/src/pocketmine/network/mcpe/protocol/AdventureSettingsPacket.php b/src/pocketmine/network/mcpe/protocol/AdventureSettingsPacket.php index 94a98e73b1..9252d24a88 100644 --- a/src/pocketmine/network/mcpe/protocol/AdventureSettingsPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AdventureSettingsPacket.php @@ -65,10 +65,15 @@ class AdventureSettingsPacket extends DataPacket{ const OPERATOR = 0x20 | self::BITFLAG_SECOND_SET; const TELEPORT = 0x80 | self::BITFLAG_SECOND_SET; + /** @var int */ public $flags = 0; + /** @var int */ public $commandPermission = self::PERMISSION_NORMAL; + /** @var int */ public $flags2 = -1; + /** @var int */ public $playerPermission = PlayerPermissions::MEMBER; + /** @var int */ public $entityUniqueId; //This is a little-endian long, NOT a var-long. (WTF Mojang) protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/AnimatePacket.php b/src/pocketmine/network/mcpe/protocol/AnimatePacket.php index 8e489760c8..fd4d0418e9 100644 --- a/src/pocketmine/network/mcpe/protocol/AnimatePacket.php +++ b/src/pocketmine/network/mcpe/protocol/AnimatePacket.php @@ -36,8 +36,11 @@ class AnimatePacket extends DataPacket{ const ACTION_STOP_SLEEP = 3; const ACTION_CRITICAL_HIT = 4; + /** @var int */ public $action; + /** @var int */ public $entityRuntimeId; + /** @var float */ public $float = 0.0; //TODO (Boat rowing time?) protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/BlockEntityDataPacket.php b/src/pocketmine/network/mcpe/protocol/BlockEntityDataPacket.php index 8c93545636..5f2d743b2e 100644 --- a/src/pocketmine/network/mcpe/protocol/BlockEntityDataPacket.php +++ b/src/pocketmine/network/mcpe/protocol/BlockEntityDataPacket.php @@ -31,9 +31,13 @@ use pocketmine\network\mcpe\NetworkSession; class BlockEntityDataPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::BLOCK_ENTITY_DATA_PACKET; + /** @var int */ public $x; + /** @var int */ public $y; + /** @var int */ public $z; + /** @var string */ public $namedtag; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/BlockEventPacket.php b/src/pocketmine/network/mcpe/protocol/BlockEventPacket.php index 836c736902..b331f21eb1 100644 --- a/src/pocketmine/network/mcpe/protocol/BlockEventPacket.php +++ b/src/pocketmine/network/mcpe/protocol/BlockEventPacket.php @@ -31,10 +31,15 @@ use pocketmine\network\mcpe\NetworkSession; class BlockEventPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::BLOCK_EVENT_PACKET; + /** @var int */ public $x; + /** @var int */ public $y; + /** @var int */ public $z; + /** @var int */ public $case1; + /** @var int */ public $case2; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/BlockPickRequestPacket.php b/src/pocketmine/network/mcpe/protocol/BlockPickRequestPacket.php index e4bd4db599..f53d047ef3 100644 --- a/src/pocketmine/network/mcpe/protocol/BlockPickRequestPacket.php +++ b/src/pocketmine/network/mcpe/protocol/BlockPickRequestPacket.php @@ -32,10 +32,15 @@ use pocketmine\network\mcpe\NetworkSession; class BlockPickRequestPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::BLOCK_PICK_REQUEST_PACKET; + /** @var int */ public $tileX; + /** @var int */ public $tileY; + /** @var int */ public $tileZ; + /** @var bool */ public $addUserData = false; + /** @var int */ public $hotbarSlot; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/BossEventPacket.php b/src/pocketmine/network/mcpe/protocol/BossEventPacket.php index d3be1551e3..ba9ac90864 100644 --- a/src/pocketmine/network/mcpe/protocol/BossEventPacket.php +++ b/src/pocketmine/network/mcpe/protocol/BossEventPacket.php @@ -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. */ const TYPE_TEXTURE = 7; + /** @var int */ public $bossEid; + /** @var int */ public $eventType; /** @var int (long) */ diff --git a/src/pocketmine/network/mcpe/protocol/ChangeDimensionPacket.php b/src/pocketmine/network/mcpe/protocol/ChangeDimensionPacket.php index 35bab51bb3..3c77f9c6a9 100644 --- a/src/pocketmine/network/mcpe/protocol/ChangeDimensionPacket.php +++ b/src/pocketmine/network/mcpe/protocol/ChangeDimensionPacket.php @@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol; #include +use pocketmine\math\Vector3; use pocketmine\network\mcpe\NetworkSession; class ChangeDimensionPacket extends DataPacket{ @@ -33,24 +34,20 @@ class ChangeDimensionPacket extends DataPacket{ /** @var int */ public $dimension; - /** @var float */ - public $x; - /** @var float */ - public $y; - /** @var float */ - public $z; + /** @var Vector3 */ + public $position; /** @var bool */ public $respawn = false; protected function decodePayload(){ $this->dimension = $this->getVarInt(); - $this->getVector3f($this->x, $this->y, $this->z); + $this->position = $this->getVector3Obj(); $this->respawn = $this->getBool(); } protected function encodePayload(){ $this->putVarInt($this->dimension); - $this->putVector3f($this->x, $this->y, $this->z); + $this->putVector3Obj($this->position); $this->putBool($this->respawn); } diff --git a/src/pocketmine/network/mcpe/protocol/ChunkRadiusUpdatedPacket.php b/src/pocketmine/network/mcpe/protocol/ChunkRadiusUpdatedPacket.php index 2112e07189..bb5d572768 100644 --- a/src/pocketmine/network/mcpe/protocol/ChunkRadiusUpdatedPacket.php +++ b/src/pocketmine/network/mcpe/protocol/ChunkRadiusUpdatedPacket.php @@ -31,6 +31,7 @@ use pocketmine\network\mcpe\NetworkSession; class ChunkRadiusUpdatedPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::CHUNK_RADIUS_UPDATED_PACKET; + /** @var int */ public $radius; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/ClientboundMapItemDataPacket.php b/src/pocketmine/network/mcpe/protocol/ClientboundMapItemDataPacket.php index 9d54eca25f..89dbd831e6 100644 --- a/src/pocketmine/network/mcpe/protocol/ClientboundMapItemDataPacket.php +++ b/src/pocketmine/network/mcpe/protocol/ClientboundMapItemDataPacket.php @@ -36,16 +36,25 @@ class ClientboundMapItemDataPacket extends DataPacket{ const BITFLAG_TEXTURE_UPDATE = 0x02; const BITFLAG_DECORATION_UPDATE = 0x04; + /** @var int */ public $mapId; + /** @var int */ public $type; + /** @var int[] */ public $eids = []; + /** @var int */ public $scale; + /** @var array */ public $decorations = []; + /** @var int */ public $width; + /** @var int */ public $height; + /** @var int */ public $xOffset = 0; + /** @var int */ public $yOffset = 0; /** @var Color[][] */ public $colors = []; diff --git a/src/pocketmine/network/mcpe/protocol/CommandBlockUpdatePacket.php b/src/pocketmine/network/mcpe/protocol/CommandBlockUpdatePacket.php index 3d7bdcc35d..f6fdaddafa 100644 --- a/src/pocketmine/network/mcpe/protocol/CommandBlockUpdatePacket.php +++ b/src/pocketmine/network/mcpe/protocol/CommandBlockUpdatePacket.php @@ -32,21 +32,32 @@ use pocketmine\network\mcpe\NetworkSession; class CommandBlockUpdatePacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::COMMAND_BLOCK_UPDATE_PACKET; + /** @var bool */ public $isBlock; + /** @var int */ public $x; + /** @var int */ public $y; + /** @var int */ public $z; + /** @var int */ public $commandBlockMode; + /** @var bool */ public $isRedstoneMode; + /** @var bool */ public $isConditional; + /** @var int */ public $minecartEid; + /** @var string */ public $command; + /** @var string */ public $lastOutput; + /** @var string */ public $name; - + /** @var bool */ public $shouldTrackOutput; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/CommandRequestPacket.php b/src/pocketmine/network/mcpe/protocol/CommandRequestPacket.php index d18d0f7462..5a14906690 100644 --- a/src/pocketmine/network/mcpe/protocol/CommandRequestPacket.php +++ b/src/pocketmine/network/mcpe/protocol/CommandRequestPacket.php @@ -30,6 +30,7 @@ use pocketmine\network\mcpe\NetworkSession; class CommandRequestPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::COMMAND_REQUEST_PACKET; + /** @var string */ public $command; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/ContainerClosePacket.php b/src/pocketmine/network/mcpe/protocol/ContainerClosePacket.php index fbfd32752e..8147867f04 100644 --- a/src/pocketmine/network/mcpe/protocol/ContainerClosePacket.php +++ b/src/pocketmine/network/mcpe/protocol/ContainerClosePacket.php @@ -31,6 +31,7 @@ use pocketmine\network\mcpe\NetworkSession; class ContainerClosePacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::CONTAINER_CLOSE_PACKET; + /** @var int */ public $windowId; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/ContainerOpenPacket.php b/src/pocketmine/network/mcpe/protocol/ContainerOpenPacket.php index ea616d3a74..e9a60cd735 100644 --- a/src/pocketmine/network/mcpe/protocol/ContainerOpenPacket.php +++ b/src/pocketmine/network/mcpe/protocol/ContainerOpenPacket.php @@ -31,11 +31,17 @@ use pocketmine\network\mcpe\NetworkSession; class ContainerOpenPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::CONTAINER_OPEN_PACKET; + /** @var int */ public $windowId; + /** @var int */ public $type; + /** @var int */ public $x; + /** @var int */ public $y; + /** @var int */ public $z; + /** @var int */ public $entityUniqueId = -1; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/ContainerSetDataPacket.php b/src/pocketmine/network/mcpe/protocol/ContainerSetDataPacket.php index efe60c7c6c..91e183e93f 100644 --- a/src/pocketmine/network/mcpe/protocol/ContainerSetDataPacket.php +++ b/src/pocketmine/network/mcpe/protocol/ContainerSetDataPacket.php @@ -41,8 +41,11 @@ class ContainerSetDataPacket extends DataPacket{ const PROPERTY_BREWING_STAND_FUEL_AMOUNT = 1; const PROPERTY_BREWING_STAND_FUEL_TOTAL = 2; + /** @var int */ public $windowId; + /** @var int */ public $property; + /** @var int */ public $value; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/CraftingDataPacket.php b/src/pocketmine/network/mcpe/protocol/CraftingDataPacket.php index dc13a48470..7f8b8d14d2 100644 --- a/src/pocketmine/network/mcpe/protocol/CraftingDataPacket.php +++ b/src/pocketmine/network/mcpe/protocol/CraftingDataPacket.php @@ -45,6 +45,7 @@ class CraftingDataPacket extends DataPacket{ /** @var object[] */ public $entries = []; + /** @var bool */ public $cleanRecipes = false; public function clean(){ diff --git a/src/pocketmine/network/mcpe/protocol/CraftingEventPacket.php b/src/pocketmine/network/mcpe/protocol/CraftingEventPacket.php index ae6945cff4..3c35ae7f33 100644 --- a/src/pocketmine/network/mcpe/protocol/CraftingEventPacket.php +++ b/src/pocketmine/network/mcpe/protocol/CraftingEventPacket.php @@ -32,7 +32,9 @@ use pocketmine\utils\UUID; class CraftingEventPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::CRAFTING_EVENT_PACKET; + /** @var int */ public $windowId; + /** @var int */ public $type; /** @var UUID */ public $id; diff --git a/src/pocketmine/network/mcpe/protocol/DataPacket.php b/src/pocketmine/network/mcpe/protocol/DataPacket.php index dd9c8dc66f..09c6db665c 100644 --- a/src/pocketmine/network/mcpe/protocol/DataPacket.php +++ b/src/pocketmine/network/mcpe/protocol/DataPacket.php @@ -38,9 +38,12 @@ abstract class DataPacket extends BinaryStream{ const NETWORK_ID = 0; + /** @var bool */ public $isEncoded = false; + /** @var int */ public $extraByte1 = 0; + /** @var int */ public $extraByte2 = 0; public function pid(){ diff --git a/src/pocketmine/network/mcpe/protocol/DisconnectPacket.php b/src/pocketmine/network/mcpe/protocol/DisconnectPacket.php index a17b3b7980..62c8345e48 100644 --- a/src/pocketmine/network/mcpe/protocol/DisconnectPacket.php +++ b/src/pocketmine/network/mcpe/protocol/DisconnectPacket.php @@ -31,7 +31,9 @@ use pocketmine\network\mcpe\NetworkSession; class DisconnectPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::DISCONNECT_PACKET; + /** @var bool */ public $hideDisconnectionScreen = false; + /** @var string */ public $message; public function canBeSentBeforeLogin() : bool{ diff --git a/src/pocketmine/network/mcpe/protocol/EntityEventPacket.php b/src/pocketmine/network/mcpe/protocol/EntityEventPacket.php index 3bd00af81e..42860941f0 100644 --- a/src/pocketmine/network/mcpe/protocol/EntityEventPacket.php +++ b/src/pocketmine/network/mcpe/protocol/EntityEventPacket.php @@ -50,8 +50,11 @@ class EntityEventPacket extends DataPacket{ //TODO: add more events + /** @var int */ public $entityRuntimeId; + /** @var int */ public $event; + /** @var int */ public $data = 0; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/EntityFallPacket.php b/src/pocketmine/network/mcpe/protocol/EntityFallPacket.php index fe2b2a6d7d..92b7075204 100644 --- a/src/pocketmine/network/mcpe/protocol/EntityFallPacket.php +++ b/src/pocketmine/network/mcpe/protocol/EntityFallPacket.php @@ -31,8 +31,11 @@ use pocketmine\network\mcpe\NetworkSession; class EntityFallPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::ENTITY_FALL_PACKET; + /** @var int */ public $entityRuntimeId; + /** @var float */ public $fallDistance; + /** @var bool */ public $bool1; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/EntityPickRequestPacket.php b/src/pocketmine/network/mcpe/protocol/EntityPickRequestPacket.php index 6ac2c5a9fc..323ddbb352 100644 --- a/src/pocketmine/network/mcpe/protocol/EntityPickRequestPacket.php +++ b/src/pocketmine/network/mcpe/protocol/EntityPickRequestPacket.php @@ -30,7 +30,9 @@ use pocketmine\network\mcpe\NetworkSession; class EntityPickRequestPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::ENTITY_PICK_REQUEST_PACKET; + /** @var int */ public $entityTypeId; + /** @var int */ public $hotbarSlot; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/EventPacket.php b/src/pocketmine/network/mcpe/protocol/EventPacket.php index ff7ddfde3a..5c8f863846 100644 --- a/src/pocketmine/network/mcpe/protocol/EventPacket.php +++ b/src/pocketmine/network/mcpe/protocol/EventPacket.php @@ -41,8 +41,11 @@ class EventPacket extends DataPacket{ const TYPE_AGENT_COMMAND = 8; const TYPE_AGENT_CREATED = 9; + /** @var int */ public $playerRuntimeId; + /** @var int */ public $eventData; + /** @var int */ public $type; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/ExplodePacket.php b/src/pocketmine/network/mcpe/protocol/ExplodePacket.php index 9d7dd6c1b6..5b73ed624b 100644 --- a/src/pocketmine/network/mcpe/protocol/ExplodePacket.php +++ b/src/pocketmine/network/mcpe/protocol/ExplodePacket.php @@ -32,9 +32,8 @@ use pocketmine\network\mcpe\NetworkSession; class ExplodePacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::EXPLODE_PACKET; - public $x; - public $y; - public $z; + /** @var Vector3 */ + public $position; /** @var float */ public $radius; /** @var Vector3[] */ @@ -46,7 +45,7 @@ class ExplodePacket extends DataPacket{ } protected function decodePayload(){ - $this->getVector3f($this->x, $this->y, $this->z); + $this->position = $this->getVector3Obj(); $this->radius = (float) ($this->getVarInt() / 32); $count = $this->getUnsignedVarInt(); for($i = 0; $i < $count; ++$i){ @@ -57,7 +56,7 @@ class ExplodePacket extends DataPacket{ } protected function encodePayload(){ - $this->putVector3f($this->x, $this->y, $this->z); + $this->putVector3Obj($this->position); $this->putVarInt((int) ($this->radius * 32)); $this->putUnsignedVarInt(count($this->records)); if(count($this->records) > 0){ diff --git a/src/pocketmine/network/mcpe/protocol/FullChunkDataPacket.php b/src/pocketmine/network/mcpe/protocol/FullChunkDataPacket.php index 18fe731985..1e426b21fd 100644 --- a/src/pocketmine/network/mcpe/protocol/FullChunkDataPacket.php +++ b/src/pocketmine/network/mcpe/protocol/FullChunkDataPacket.php @@ -31,8 +31,11 @@ use pocketmine\network\mcpe\NetworkSession; class FullChunkDataPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::FULL_CHUNK_DATA_PACKET; + /** @var int */ public $chunkX; + /** @var int */ public $chunkZ; + /** @var string */ public $data; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/GameRulesChangedPacket.php b/src/pocketmine/network/mcpe/protocol/GameRulesChangedPacket.php index d7fc26f702..2a535cd1a6 100644 --- a/src/pocketmine/network/mcpe/protocol/GameRulesChangedPacket.php +++ b/src/pocketmine/network/mcpe/protocol/GameRulesChangedPacket.php @@ -30,6 +30,7 @@ use pocketmine\network\mcpe\NetworkSession; class GameRulesChangedPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::GAME_RULES_CHANGED_PACKET; + /** @var array */ public $gameRules = []; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/HurtArmorPacket.php b/src/pocketmine/network/mcpe/protocol/HurtArmorPacket.php index 0cee4e64a9..bb407565da 100644 --- a/src/pocketmine/network/mcpe/protocol/HurtArmorPacket.php +++ b/src/pocketmine/network/mcpe/protocol/HurtArmorPacket.php @@ -31,6 +31,7 @@ use pocketmine\network\mcpe\NetworkSession; class HurtArmorPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::HURT_ARMOR_PACKET; + /** @var int */ public $health; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/InteractPacket.php b/src/pocketmine/network/mcpe/protocol/InteractPacket.php index 4c7f71ef7d..37a9e20536 100644 --- a/src/pocketmine/network/mcpe/protocol/InteractPacket.php +++ b/src/pocketmine/network/mcpe/protocol/InteractPacket.php @@ -53,6 +53,7 @@ class InteractPacket extends DataPacket{ $this->target = $this->getEntityRuntimeId(); if($this->action === self::ACTION_MOUSEOVER){ + //TODO: should this be a vector3? $this->x = $this->getLFloat(); $this->y = $this->getLFloat(); $this->z = $this->getLFloat(); diff --git a/src/pocketmine/network/mcpe/protocol/InventoryTransactionPacket.php b/src/pocketmine/network/mcpe/protocol/InventoryTransactionPacket.php index 24dd003b05..1d3fa315bb 100644 --- a/src/pocketmine/network/mcpe/protocol/InventoryTransactionPacket.php +++ b/src/pocketmine/network/mcpe/protocol/InventoryTransactionPacket.php @@ -95,6 +95,7 @@ class InventoryTransactionPacket extends DataPacket{ /** @var InventoryAction[] */ public $actions = []; + /** @var \stdClass */ public $transactionData; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/ItemFrameDropItemPacket.php b/src/pocketmine/network/mcpe/protocol/ItemFrameDropItemPacket.php index b99fa7af42..65b3d76410 100644 --- a/src/pocketmine/network/mcpe/protocol/ItemFrameDropItemPacket.php +++ b/src/pocketmine/network/mcpe/protocol/ItemFrameDropItemPacket.php @@ -31,8 +31,11 @@ class ItemFrameDropItemPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::ITEM_FRAME_DROP_ITEM_PACKET; + /** @var int */ public $x; + /** @var int */ public $y; + /** @var int */ public $z; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/LevelEventPacket.php b/src/pocketmine/network/mcpe/protocol/LevelEventPacket.php index 39063edcbc..206bf97b2b 100644 --- a/src/pocketmine/network/mcpe/protocol/LevelEventPacket.php +++ b/src/pocketmine/network/mcpe/protocol/LevelEventPacket.php @@ -25,6 +25,7 @@ namespace pocketmine\network\mcpe\protocol; #include +use pocketmine\math\Vector3; use pocketmine\network\mcpe\NetworkSession; class LevelEventPacket extends DataPacket{ @@ -100,21 +101,22 @@ class LevelEventPacket extends DataPacket{ const EVENT_ADD_PARTICLE_MASK = 0x4000; + /** @var int */ public $evid; - public $x = 0; //Weather effects don't have coordinates - public $y = 0; - public $z = 0; + /** @var Vector3|null */ + public $position; + /** @var int */ public $data; protected function decodePayload(){ $this->evid = $this->getVarInt(); - $this->getVector3f($this->x, $this->y, $this->z); + $this->position = $this->getVector3Obj(); $this->data = $this->getVarInt(); } protected function encodePayload(){ $this->putVarInt($this->evid); - $this->putVector3f($this->x, $this->y, $this->z); + $this->putVector3ObjNullable($this->position); $this->putVarInt($this->data); } diff --git a/src/pocketmine/network/mcpe/protocol/LevelSoundEventPacket.php b/src/pocketmine/network/mcpe/protocol/LevelSoundEventPacket.php index ee3efdc85e..d5a702ba11 100644 --- a/src/pocketmine/network/mcpe/protocol/LevelSoundEventPacket.php +++ b/src/pocketmine/network/mcpe/protocol/LevelSoundEventPacket.php @@ -25,6 +25,7 @@ namespace pocketmine\network\mcpe\protocol; #include +use pocketmine\math\Vector3; use pocketmine\network\mcpe\NetworkSession; class LevelSoundEventPacket extends DataPacket{ @@ -192,18 +193,22 @@ class LevelSoundEventPacket extends DataPacket{ const SOUND_DEFAULT = 161; const SOUND_UNDEFINED = 162; + /** @var int */ public $sound; - public $x; - public $y; - public $z; + /** @var Vector3 */ + public $position; + /** @var int */ public $extraData = -1; + /** @var int */ public $pitch = 1; + /** @var bool */ public $unknownBool = false; + /** @var bool */ public $disableRelativeVolume = false; protected function decodePayload(){ $this->sound = $this->getByte(); - $this->getVector3f($this->x, $this->y, $this->z); + $this->position = $this->getVector3Obj(); $this->extraData = $this->getVarInt(); $this->pitch = $this->getVarInt(); $this->unknownBool = $this->getBool(); @@ -212,7 +217,7 @@ class LevelSoundEventPacket extends DataPacket{ protected function encodePayload(){ $this->putByte($this->sound); - $this->putVector3f($this->x, $this->y, $this->z); + $this->putVector3Obj($this->position); $this->putVarInt($this->extraData); $this->putVarInt($this->pitch); $this->putBool($this->unknownBool); diff --git a/src/pocketmine/network/mcpe/protocol/LoginPacket.php b/src/pocketmine/network/mcpe/protocol/LoginPacket.php index c6d8bded31..d6d33ce89e 100644 --- a/src/pocketmine/network/mcpe/protocol/LoginPacket.php +++ b/src/pocketmine/network/mcpe/protocol/LoginPacket.php @@ -34,14 +34,22 @@ class LoginPacket extends DataPacket{ const EDITION_POCKET = 0; + /** @var string */ public $username; + /** @var int */ public $protocol; + /** @var string */ public $clientUUID; + /** @var int */ public $clientId; + /** @var string */ public $identityPublicKey; + /** @var string */ public $serverAddress; + /** @var string */ public $skinId; + /** @var string */ public $skin = ""; /** @var array (the "chain" index contains one or more JWTs) */ diff --git a/src/pocketmine/network/mcpe/protocol/MapInfoRequestPacket.php b/src/pocketmine/network/mcpe/protocol/MapInfoRequestPacket.php index 13835214cc..78c14141da 100644 --- a/src/pocketmine/network/mcpe/protocol/MapInfoRequestPacket.php +++ b/src/pocketmine/network/mcpe/protocol/MapInfoRequestPacket.php @@ -32,6 +32,7 @@ use pocketmine\network\mcpe\NetworkSession; class MapInfoRequestPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::MAP_INFO_REQUEST_PACKET; + /** @var int */ public $mapId; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/MobArmorEquipmentPacket.php b/src/pocketmine/network/mcpe/protocol/MobArmorEquipmentPacket.php index b8ba8d59ac..16e4569b00 100644 --- a/src/pocketmine/network/mcpe/protocol/MobArmorEquipmentPacket.php +++ b/src/pocketmine/network/mcpe/protocol/MobArmorEquipmentPacket.php @@ -32,24 +32,23 @@ use pocketmine\network\mcpe\NetworkSession; class MobArmorEquipmentPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::MOB_ARMOR_EQUIPMENT_PACKET; + /** @var int */ public $entityRuntimeId; /** @var Item[] */ public $slots = []; protected function decodePayload(){ $this->entityRuntimeId = $this->getEntityRuntimeId(); - $this->slots[0] = $this->getSlot(); - $this->slots[1] = $this->getSlot(); - $this->slots[2] = $this->getSlot(); - $this->slots[3] = $this->getSlot(); + for($i = 0; $i < 4; ++$i){ + $this->slots[$i] = $this->getSlot(); + } } protected function encodePayload(){ $this->putEntityRuntimeId($this->entityRuntimeId); - $this->putSlot($this->slots[0]); - $this->putSlot($this->slots[1]); - $this->putSlot($this->slots[2]); - $this->putSlot($this->slots[3]); + for($i = 0; $i < 4; ++$i){ + $this->putSlot($this->slots[$i]); + } } public function handle(NetworkSession $session) : bool{ diff --git a/src/pocketmine/network/mcpe/protocol/MobEffectPacket.php b/src/pocketmine/network/mcpe/protocol/MobEffectPacket.php index c11c8fec44..d2d3efe412 100644 --- a/src/pocketmine/network/mcpe/protocol/MobEffectPacket.php +++ b/src/pocketmine/network/mcpe/protocol/MobEffectPacket.php @@ -35,11 +35,17 @@ class MobEffectPacket extends DataPacket{ const EVENT_MODIFY = 2; const EVENT_REMOVE = 3; + /** @var int */ public $entityRuntimeId; + /** @var int */ public $eventId; + /** @var int */ public $effectId; + /** @var int */ public $amplifier = 0; + /** @var bool */ public $particles = true; + /** @var int */ public $duration = 0; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/MobEquipmentPacket.php b/src/pocketmine/network/mcpe/protocol/MobEquipmentPacket.php index 9ffe1164a8..6f8b7211a9 100644 --- a/src/pocketmine/network/mcpe/protocol/MobEquipmentPacket.php +++ b/src/pocketmine/network/mcpe/protocol/MobEquipmentPacket.php @@ -26,15 +26,21 @@ namespace pocketmine\network\mcpe\protocol; #include +use pocketmine\item\Item; use pocketmine\network\mcpe\NetworkSession; class MobEquipmentPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::MOB_EQUIPMENT_PACKET; + /** @var int */ public $entityRuntimeId; + /** @var Item */ public $item; + /** @var int */ public $inventorySlot; + /** @var int */ public $hotbarSlot; + /** @var int */ public $windowId = 0; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/MoveEntityPacket.php b/src/pocketmine/network/mcpe/protocol/MoveEntityPacket.php index 92b301d0fa..699089f732 100644 --- a/src/pocketmine/network/mcpe/protocol/MoveEntityPacket.php +++ b/src/pocketmine/network/mcpe/protocol/MoveEntityPacket.php @@ -26,24 +26,30 @@ namespace pocketmine\network\mcpe\protocol; #include +use pocketmine\math\Vector3; use pocketmine\network\mcpe\NetworkSession; class MoveEntityPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::MOVE_ENTITY_PACKET; + /** @var int */ public $entityRuntimeId; - public $x; - public $y; - public $z; + /** @var Vector3 */ + public $position; + /** @var float */ public $yaw; + /** @var float */ public $headYaw; + /** @var float */ public $pitch; + /** @var bool */ public $onGround = false; + /** @var bool */ public $teleported = false; protected function decodePayload(){ $this->entityRuntimeId = $this->getEntityRuntimeId(); - $this->getVector3f($this->x, $this->y, $this->z); + $this->position = $this->getVector3Obj(); $this->pitch = $this->getByteRotation(); $this->headYaw = $this->getByteRotation(); $this->yaw = $this->getByteRotation(); @@ -53,7 +59,7 @@ class MoveEntityPacket extends DataPacket{ protected function encodePayload(){ $this->putEntityRuntimeId($this->entityRuntimeId); - $this->putVector3f($this->x, $this->y, $this->z); + $this->putVector3Obj($this->position); $this->putByteRotation($this->pitch); $this->putByteRotation($this->headYaw); $this->putByteRotation($this->yaw); diff --git a/src/pocketmine/network/mcpe/protocol/MovePlayerPacket.php b/src/pocketmine/network/mcpe/protocol/MovePlayerPacket.php index 48f66ddad0..3d51755f28 100644 --- a/src/pocketmine/network/mcpe/protocol/MovePlayerPacket.php +++ b/src/pocketmine/network/mcpe/protocol/MovePlayerPacket.php @@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol; #include +use pocketmine\math\Vector3; use pocketmine\network\mcpe\NetworkSession; class MovePlayerPacket extends DataPacket{ @@ -36,22 +37,30 @@ class MovePlayerPacket extends DataPacket{ const MODE_TELEPORT = 2; const MODE_PITCH = 3; //facepalm Mojang + /** @var int */ public $entityRuntimeId; - public $x; - public $y; - public $z; + /** @var Vector3 */ + public $position; + /** @var float */ public $yaw; + /** @var float */ public $bodyYaw; + /** @var float */ public $pitch; + /** @var int */ public $mode = self::MODE_NORMAL; + /** @var bool */ public $onGround = false; //TODO + /** @var int */ public $ridingEid = 0; + /** @var int */ public $int1 = 0; + /** @var int */ public $int2 = 0; protected function decodePayload(){ $this->entityRuntimeId = $this->getEntityRuntimeId(); - $this->getVector3f($this->x, $this->y, $this->z); + $this->position = $this->getVector3Obj(); $this->pitch = $this->getLFloat(); $this->yaw = $this->getLFloat(); $this->bodyYaw = $this->getLFloat(); @@ -66,7 +75,7 @@ class MovePlayerPacket extends DataPacket{ protected function encodePayload(){ $this->putEntityRuntimeId($this->entityRuntimeId); - $this->putVector3f($this->x, $this->y, $this->z); + $this->putVector3Obj($this->position); $this->putLFloat($this->pitch); $this->putLFloat($this->yaw); $this->putLFloat($this->bodyYaw); //TODO diff --git a/src/pocketmine/network/mcpe/protocol/PlaySoundPacket.php b/src/pocketmine/network/mcpe/protocol/PlaySoundPacket.php index e44a1da948..54d48cc073 100644 --- a/src/pocketmine/network/mcpe/protocol/PlaySoundPacket.php +++ b/src/pocketmine/network/mcpe/protocol/PlaySoundPacket.php @@ -32,11 +32,17 @@ use pocketmine\network\mcpe\NetworkSession; class PlaySoundPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::PLAY_SOUND_PACKET; + /** @var string */ public $soundName; + /** @var int */ public $x; + /** @var int */ public $y; + /** @var int */ public $z; + /** @var float */ public $volume; + /** @var float */ public $pitch; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/PlayStatusPacket.php b/src/pocketmine/network/mcpe/protocol/PlayStatusPacket.php index 1f79a601e3..38b48e60ed 100644 --- a/src/pocketmine/network/mcpe/protocol/PlayStatusPacket.php +++ b/src/pocketmine/network/mcpe/protocol/PlayStatusPacket.php @@ -39,6 +39,7 @@ class PlayStatusPacket extends DataPacket{ const LOGIN_FAILED_VANILLA_EDU = 5; const LOGIN_FAILED_EDU_VANILLA = 6; + /** @var int */ public $status; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/PlayerActionPacket.php b/src/pocketmine/network/mcpe/protocol/PlayerActionPacket.php index 61e2e80d1e..d2123d1302 100644 --- a/src/pocketmine/network/mcpe/protocol/PlayerActionPacket.php +++ b/src/pocketmine/network/mcpe/protocol/PlayerActionPacket.php @@ -54,11 +54,17 @@ class PlayerActionPacket extends DataPacket{ const ACTION_RELEASE_ITEM = 99999; //TODO REMOVE + /** @var int */ public $entityRuntimeId; + /** @var int */ public $action; + /** @var int */ public $x; + /** @var int */ public $y; + /** @var int */ public $z; + /** @var int */ public $face; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/PlayerInputPacket.php b/src/pocketmine/network/mcpe/protocol/PlayerInputPacket.php index 5e41bc37e1..a398d0c2d5 100644 --- a/src/pocketmine/network/mcpe/protocol/PlayerInputPacket.php +++ b/src/pocketmine/network/mcpe/protocol/PlayerInputPacket.php @@ -31,9 +31,13 @@ use pocketmine\network\mcpe\NetworkSession; class PlayerInputPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::PLAYER_INPUT_PACKET; + /** @var float */ public $motionX; + /** @var float */ public $motionY; + /** @var bool */ public $unknownBool1; + /** @var bool */ public $unknownBool2; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/PlayerListPacket.php b/src/pocketmine/network/mcpe/protocol/PlayerListPacket.php index 50515ba2e0..47b74f2032 100644 --- a/src/pocketmine/network/mcpe/protocol/PlayerListPacket.php +++ b/src/pocketmine/network/mcpe/protocol/PlayerListPacket.php @@ -37,6 +37,7 @@ class PlayerListPacket extends DataPacket{ //REMOVE: UUID, ADD: UUID, entity id, name, skinId, skin, geometric model, geometry data /** @var array[] */ public $entries = []; + /** @var int */ public $type; public function clean(){ diff --git a/src/pocketmine/network/mcpe/protocol/RemoveEntityPacket.php b/src/pocketmine/network/mcpe/protocol/RemoveEntityPacket.php index cb79adc0fc..7dd2b98874 100644 --- a/src/pocketmine/network/mcpe/protocol/RemoveEntityPacket.php +++ b/src/pocketmine/network/mcpe/protocol/RemoveEntityPacket.php @@ -31,6 +31,7 @@ use pocketmine\network\mcpe\NetworkSession; class RemoveEntityPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::REMOVE_ENTITY_PACKET; + /** @var int */ public $entityUniqueId; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/RequestChunkRadiusPacket.php b/src/pocketmine/network/mcpe/protocol/RequestChunkRadiusPacket.php index 82a25cd41d..4864932903 100644 --- a/src/pocketmine/network/mcpe/protocol/RequestChunkRadiusPacket.php +++ b/src/pocketmine/network/mcpe/protocol/RequestChunkRadiusPacket.php @@ -31,6 +31,7 @@ use pocketmine\network\mcpe\NetworkSession; class RequestChunkRadiusPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::REQUEST_CHUNK_RADIUS_PACKET; + /** @var int */ public $radius; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/ResourcePackChunkDataPacket.php b/src/pocketmine/network/mcpe/protocol/ResourcePackChunkDataPacket.php index 3c61e79fdd..180985546b 100644 --- a/src/pocketmine/network/mcpe/protocol/ResourcePackChunkDataPacket.php +++ b/src/pocketmine/network/mcpe/protocol/ResourcePackChunkDataPacket.php @@ -32,9 +32,13 @@ use pocketmine\network\mcpe\NetworkSession; class ResourcePackChunkDataPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_CHUNK_DATA_PACKET; + /** @var string */ public $packId; + /** @var int */ public $chunkIndex; + /** @var int */ public $progress; + /** @var string */ public $data; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/ResourcePackChunkRequestPacket.php b/src/pocketmine/network/mcpe/protocol/ResourcePackChunkRequestPacket.php index 40d5a06cc0..711d238c7c 100644 --- a/src/pocketmine/network/mcpe/protocol/ResourcePackChunkRequestPacket.php +++ b/src/pocketmine/network/mcpe/protocol/ResourcePackChunkRequestPacket.php @@ -32,7 +32,9 @@ use pocketmine\network\mcpe\NetworkSession; class ResourcePackChunkRequestPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_CHUNK_REQUEST_PACKET; + /** @var string */ public $packId; + /** @var int */ public $chunkIndex; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/ResourcePackClientResponsePacket.php b/src/pocketmine/network/mcpe/protocol/ResourcePackClientResponsePacket.php index de814edadf..41f3a47a21 100644 --- a/src/pocketmine/network/mcpe/protocol/ResourcePackClientResponsePacket.php +++ b/src/pocketmine/network/mcpe/protocol/ResourcePackClientResponsePacket.php @@ -36,7 +36,9 @@ class ResourcePackClientResponsePacket extends DataPacket{ const STATUS_HAVE_ALL_PACKS = 3; const STATUS_COMPLETED = 4; + /** @var int */ public $status; + /** @var string[] */ public $packIds = []; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/ResourcePackDataInfoPacket.php b/src/pocketmine/network/mcpe/protocol/ResourcePackDataInfoPacket.php index 07838912af..f237952ec6 100644 --- a/src/pocketmine/network/mcpe/protocol/ResourcePackDataInfoPacket.php +++ b/src/pocketmine/network/mcpe/protocol/ResourcePackDataInfoPacket.php @@ -32,10 +32,15 @@ use pocketmine\network\mcpe\NetworkSession; class ResourcePackDataInfoPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_DATA_INFO_PACKET; + /** @var string */ public $packId; + /** @var int */ public $maxChunkSize; + /** @var int */ public $chunkCount; + /** @var int */ public $compressedPackSize; + /** @var string */ public $sha256; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/ResourcePackStackPacket.php b/src/pocketmine/network/mcpe/protocol/ResourcePackStackPacket.php index 547aa1d1b1..ae070c55ce 100644 --- a/src/pocketmine/network/mcpe/protocol/ResourcePackStackPacket.php +++ b/src/pocketmine/network/mcpe/protocol/ResourcePackStackPacket.php @@ -34,6 +34,7 @@ use pocketmine\resourcepacks\ResourcePackInfoEntry; class ResourcePackStackPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_STACK_PACKET; + /** @var bool */ public $mustAccept = false; /** @var ResourcePack[] */ diff --git a/src/pocketmine/network/mcpe/protocol/ResourcePacksInfoPacket.php b/src/pocketmine/network/mcpe/protocol/ResourcePacksInfoPacket.php index 8a43521e67..1dc2b3853f 100644 --- a/src/pocketmine/network/mcpe/protocol/ResourcePacksInfoPacket.php +++ b/src/pocketmine/network/mcpe/protocol/ResourcePacksInfoPacket.php @@ -33,6 +33,7 @@ use pocketmine\resourcepacks\ResourcePackInfoEntry; class ResourcePacksInfoPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::RESOURCE_PACKS_INFO_PACKET; + /** @var bool */ public $mustAccept = false; //if true, forces client to use selected resource packs /** @var ResourcePack[] */ public $behaviorPackEntries = []; diff --git a/src/pocketmine/network/mcpe/protocol/RespawnPacket.php b/src/pocketmine/network/mcpe/protocol/RespawnPacket.php index 5b479a2608..5553713cd4 100644 --- a/src/pocketmine/network/mcpe/protocol/RespawnPacket.php +++ b/src/pocketmine/network/mcpe/protocol/RespawnPacket.php @@ -26,21 +26,21 @@ namespace pocketmine\network\mcpe\protocol; #include +use pocketmine\math\Vector3; use pocketmine\network\mcpe\NetworkSession; class RespawnPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::RESPAWN_PACKET; - public $x; - public $y; - public $z; + /** @var Vector3 */ + public $position; protected function decodePayload(){ - $this->getVector3f($this->x, $this->y, $this->z); + $this->position = $this->getVector3Obj(); } protected function encodePayload(){ - $this->putVector3f($this->x, $this->y, $this->z); + $this->putVector3Obj($this->position); } public function handle(NetworkSession $session) : bool{ diff --git a/src/pocketmine/network/mcpe/protocol/RiderJumpPacket.php b/src/pocketmine/network/mcpe/protocol/RiderJumpPacket.php index 98bb7571c0..9b9eb7dcc8 100644 --- a/src/pocketmine/network/mcpe/protocol/RiderJumpPacket.php +++ b/src/pocketmine/network/mcpe/protocol/RiderJumpPacket.php @@ -32,6 +32,7 @@ use pocketmine\network\mcpe\NetworkSession; class RiderJumpPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::RIDER_JUMP_PACKET; + /** @var int */ public $unknown; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/SetCommandsEnabledPacket.php b/src/pocketmine/network/mcpe/protocol/SetCommandsEnabledPacket.php index 75b1e6a528..8151b99ea7 100644 --- a/src/pocketmine/network/mcpe/protocol/SetCommandsEnabledPacket.php +++ b/src/pocketmine/network/mcpe/protocol/SetCommandsEnabledPacket.php @@ -31,6 +31,7 @@ use pocketmine\network\mcpe\NetworkSession; class SetCommandsEnabledPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::SET_COMMANDS_ENABLED_PACKET; + /** @var bool */ public $enabled; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/SetDifficultyPacket.php b/src/pocketmine/network/mcpe/protocol/SetDifficultyPacket.php index 9ea8baa3b5..f4c75ebd9f 100644 --- a/src/pocketmine/network/mcpe/protocol/SetDifficultyPacket.php +++ b/src/pocketmine/network/mcpe/protocol/SetDifficultyPacket.php @@ -31,6 +31,7 @@ use pocketmine\network\mcpe\NetworkSession; class SetDifficultyPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::SET_DIFFICULTY_PACKET; + /** @var int */ public $difficulty; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/SetEntityDataPacket.php b/src/pocketmine/network/mcpe/protocol/SetEntityDataPacket.php index ddefb2409f..38cf670fe9 100644 --- a/src/pocketmine/network/mcpe/protocol/SetEntityDataPacket.php +++ b/src/pocketmine/network/mcpe/protocol/SetEntityDataPacket.php @@ -31,7 +31,9 @@ use pocketmine\network\mcpe\NetworkSession; class SetEntityDataPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::SET_ENTITY_DATA_PACKET; + /** @var int */ public $entityRuntimeId; + /** @var array */ public $metadata; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/SetEntityMotionPacket.php b/src/pocketmine/network/mcpe/protocol/SetEntityMotionPacket.php index 9dcf2f1bca..4ddce4db73 100644 --- a/src/pocketmine/network/mcpe/protocol/SetEntityMotionPacket.php +++ b/src/pocketmine/network/mcpe/protocol/SetEntityMotionPacket.php @@ -26,24 +26,25 @@ namespace pocketmine\network\mcpe\protocol; #include +use pocketmine\math\Vector3; use pocketmine\network\mcpe\NetworkSession; class SetEntityMotionPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::SET_ENTITY_MOTION_PACKET; + /** @var int */ public $entityRuntimeId; - public $motionX; - public $motionY; - public $motionZ; + /** @var Vector3 */ + public $motion; protected function decodePayload(){ $this->entityRuntimeId = $this->getEntityRuntimeId(); - $this->getVector3f($this->motionX, $this->motionY, $this->motionZ); + $this->motion = $this->getVector3Obj(); } protected function encodePayload(){ $this->putEntityRuntimeId($this->entityRuntimeId); - $this->putVector3f($this->motionX, $this->motionY, $this->motionZ); + $this->putVector3Obj($this->motion); } public function handle(NetworkSession $session) : bool{ diff --git a/src/pocketmine/network/mcpe/protocol/SetHealthPacket.php b/src/pocketmine/network/mcpe/protocol/SetHealthPacket.php index f989bf6c93..522c762c4d 100644 --- a/src/pocketmine/network/mcpe/protocol/SetHealthPacket.php +++ b/src/pocketmine/network/mcpe/protocol/SetHealthPacket.php @@ -31,6 +31,7 @@ use pocketmine\network\mcpe\NetworkSession; class SetHealthPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::SET_HEALTH_PACKET; + /** @var int */ public $health; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/SetLastHurtByPacket.php b/src/pocketmine/network/mcpe/protocol/SetLastHurtByPacket.php index a27864b36c..94c84c5923 100644 --- a/src/pocketmine/network/mcpe/protocol/SetLastHurtByPacket.php +++ b/src/pocketmine/network/mcpe/protocol/SetLastHurtByPacket.php @@ -30,6 +30,7 @@ use pocketmine\network\mcpe\NetworkSession; class SetLastHurtByPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::SET_LAST_HURT_BY_PACKET; + /** @var int */ public $entityTypeId; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/SetPlayerGameTypePacket.php b/src/pocketmine/network/mcpe/protocol/SetPlayerGameTypePacket.php index 4f5dc0e6ed..ec5a12bf57 100644 --- a/src/pocketmine/network/mcpe/protocol/SetPlayerGameTypePacket.php +++ b/src/pocketmine/network/mcpe/protocol/SetPlayerGameTypePacket.php @@ -31,6 +31,7 @@ use pocketmine\network\mcpe\NetworkSession; class SetPlayerGameTypePacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::SET_PLAYER_GAME_TYPE_PACKET; + /** @var int */ public $gamemode; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/SetSpawnPositionPacket.php b/src/pocketmine/network/mcpe/protocol/SetSpawnPositionPacket.php index c8d7862616..a691a007dd 100644 --- a/src/pocketmine/network/mcpe/protocol/SetSpawnPositionPacket.php +++ b/src/pocketmine/network/mcpe/protocol/SetSpawnPositionPacket.php @@ -34,10 +34,15 @@ class SetSpawnPositionPacket extends DataPacket{ const TYPE_PLAYER_SPAWN = 0; const TYPE_WORLD_SPAWN = 1; + /** @var int */ public $spawnType; + /** @var int */ public $x; + /** @var int */ public $y; + /** @var int */ public $z; + /** @var bool */ public $spawnForced; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/SetTimePacket.php b/src/pocketmine/network/mcpe/protocol/SetTimePacket.php index 09dedbd6e0..7c3db17b11 100644 --- a/src/pocketmine/network/mcpe/protocol/SetTimePacket.php +++ b/src/pocketmine/network/mcpe/protocol/SetTimePacket.php @@ -30,6 +30,7 @@ use pocketmine\network\mcpe\NetworkSession; class SetTimePacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::SET_TIME_PACKET; + /** @var int */ public $time; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/SetTitlePacket.php b/src/pocketmine/network/mcpe/protocol/SetTitlePacket.php index 2531c2c32d..53093806cd 100644 --- a/src/pocketmine/network/mcpe/protocol/SetTitlePacket.php +++ b/src/pocketmine/network/mcpe/protocol/SetTitlePacket.php @@ -39,10 +39,15 @@ class SetTitlePacket extends DataPacket{ const TYPE_SET_ACTIONBAR_MESSAGE = 4; const TYPE_SET_ANIMATION_TIMES = 5; + /** @var int */ public $type; + /** @var string */ public $text = ""; + /** @var int */ public $fadeInTime = 0; + /** @var int */ public $stayTime = 0; + /** @var int */ public $fadeOutTime = 0; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/ShowCreditsPacket.php b/src/pocketmine/network/mcpe/protocol/ShowCreditsPacket.php index feb65cff1d..ae8a1ce342 100644 --- a/src/pocketmine/network/mcpe/protocol/ShowCreditsPacket.php +++ b/src/pocketmine/network/mcpe/protocol/ShowCreditsPacket.php @@ -35,7 +35,9 @@ class ShowCreditsPacket extends DataPacket{ const STATUS_START_CREDITS = 0; const STATUS_END_CREDITS = 1; + /** @var int */ public $playerEid; + /** @var int */ public $status; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/ShowStoreOfferPacket.php b/src/pocketmine/network/mcpe/protocol/ShowStoreOfferPacket.php index f8871ac565..6892e5a680 100644 --- a/src/pocketmine/network/mcpe/protocol/ShowStoreOfferPacket.php +++ b/src/pocketmine/network/mcpe/protocol/ShowStoreOfferPacket.php @@ -30,8 +30,11 @@ use pocketmine\network\mcpe\NetworkSession; class ShowStoreOfferPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::SHOW_STORE_OFFER_PACKET; + /** @var string */ public $offerId; + /** @var bool */ public $unknownBool; + /** @var string */ public $unknownString; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/SimpleEventPacket.php b/src/pocketmine/network/mcpe/protocol/SimpleEventPacket.php index 151c788a90..f9e70a0563 100644 --- a/src/pocketmine/network/mcpe/protocol/SimpleEventPacket.php +++ b/src/pocketmine/network/mcpe/protocol/SimpleEventPacket.php @@ -30,6 +30,7 @@ use pocketmine\network\mcpe\NetworkSession; class SimpleEventPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::SIMPLE_EVENT_PACKET; + /** @var int */ public $unknownShort1; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/SpawnExperienceOrbPacket.php b/src/pocketmine/network/mcpe/protocol/SpawnExperienceOrbPacket.php index ce7846461c..bf60e8c00f 100644 --- a/src/pocketmine/network/mcpe/protocol/SpawnExperienceOrbPacket.php +++ b/src/pocketmine/network/mcpe/protocol/SpawnExperienceOrbPacket.php @@ -26,23 +26,24 @@ namespace pocketmine\network\mcpe\protocol; #include +use pocketmine\math\Vector3; use pocketmine\network\mcpe\NetworkSession; class SpawnExperienceOrbPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::SPAWN_EXPERIENCE_ORB_PACKET; - public $x; - public $y; - public $z; + /** @var Vector3 */ + public $position; + /** @var int */ public $amount; protected function decodePayload(){ - $this->getVector3f($this->x, $this->y, $this->z); + $this->position = $this->getVector3Obj(); $this->amount = $this->getVarInt(); } protected function encodePayload(){ - $this->putVector3f($this->x, $this->y, $this->z); + $this->putVector3Obj($this->position); $this->putVarInt($this->amount); } diff --git a/src/pocketmine/network/mcpe/protocol/StartGamePacket.php b/src/pocketmine/network/mcpe/protocol/StartGamePacket.php index b12c5bf466..c503c8d996 100644 --- a/src/pocketmine/network/mcpe/protocol/StartGamePacket.php +++ b/src/pocketmine/network/mcpe/protocol/StartGamePacket.php @@ -26,54 +26,88 @@ namespace pocketmine\network\mcpe\protocol; #include +use pocketmine\math\Vector3; use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\protocol\types\PlayerPermissions; class StartGamePacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::START_GAME_PACKET; + /** @var int */ public $entityUniqueId; + /** @var int */ public $entityRuntimeId; + /** @var int */ public $playerGamemode; - public $x; - public $y; - public $z; + /** @var Vector3 */ + public $playerPosition; + /** @var float */ public $pitch; + /** @var float */ public $yaw; + /** @var int */ public $seed; + /** @var int */ public $dimension; + /** @var int */ public $generator = 1; //default infinite - 0 old, 1 infinite, 2 flat + /** @var int */ public $worldGamemode; + /** @var int */ public $difficulty; + /** @var int */ public $spawnX; + /** @var int*/ public $spawnY; + /** @var int */ public $spawnZ; + /** @var bool */ public $hasAchievementsDisabled = true; + /** @var int */ public $time = -1; + /** @var bool */ public $eduMode = false; + /** @var float */ public $rainLevel; + /** @var float */ public $lightningLevel; + /** @var bool */ public $isMultiplayerGame = true; + /** @var bool */ public $hasLANBroadcast = true; + /** @var bool */ public $hasXboxLiveBroadcast = false; + /** @var bool */ public $commandsEnabled; + /** @var bool */ public $isTexturePacksRequired = true; + /** @var array */ public $gameRules = []; //TODO: implement this + /** @var bool */ 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 string */ public $levelId = ""; //base64 string, usually the same as world folder name in vanilla + /** @var string */ public $worldName; + /** @var string */ public $premiumWorldTemplateId = ""; + /** @var bool */ public $unknownBool = false; + /** @var int */ public $currentTick = 0; - + /** @var int */ public $unknownVarInt = 0; protected function decodePayload(){ @@ -81,7 +115,7 @@ class StartGamePacket extends DataPacket{ $this->entityRuntimeId = $this->getEntityRuntimeId(); $this->playerGamemode = $this->getVarInt(); - $this->getVector3f($this->x, $this->y, $this->z); + $this->playerPosition = $this->getVector3Obj(); $this->pitch = $this->getLFloat(); $this->yaw = $this->getLFloat(); @@ -124,7 +158,7 @@ class StartGamePacket extends DataPacket{ $this->putEntityRuntimeId($this->entityRuntimeId); $this->putVarInt($this->playerGamemode); - $this->putVector3f($this->x, $this->y, $this->z); + $this->putVector3Obj($this->playerPosition); $this->putLFloat($this->pitch); $this->putLFloat($this->yaw); diff --git a/src/pocketmine/network/mcpe/protocol/StopSoundPacket.php b/src/pocketmine/network/mcpe/protocol/StopSoundPacket.php index f69ef6817c..dc671f9ca5 100644 --- a/src/pocketmine/network/mcpe/protocol/StopSoundPacket.php +++ b/src/pocketmine/network/mcpe/protocol/StopSoundPacket.php @@ -32,7 +32,9 @@ use pocketmine\network\mcpe\NetworkSession; class StopSoundPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::STOP_SOUND_PACKET; + /** @var string */ public $soundName; + /** @var bool */ public $stopAll; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/TakeItemEntityPacket.php b/src/pocketmine/network/mcpe/protocol/TakeItemEntityPacket.php index 31ab3220b6..02b3fd210e 100644 --- a/src/pocketmine/network/mcpe/protocol/TakeItemEntityPacket.php +++ b/src/pocketmine/network/mcpe/protocol/TakeItemEntityPacket.php @@ -31,7 +31,9 @@ use pocketmine\network\mcpe\NetworkSession; class TakeItemEntityPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::TAKE_ITEM_ENTITY_PACKET; + /** @var int */ public $target; + /** @var int */ public $eid; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/TransferPacket.php b/src/pocketmine/network/mcpe/protocol/TransferPacket.php index d6bb00d83c..5d40e5ac95 100644 --- a/src/pocketmine/network/mcpe/protocol/TransferPacket.php +++ b/src/pocketmine/network/mcpe/protocol/TransferPacket.php @@ -30,7 +30,9 @@ use pocketmine\network\mcpe\NetworkSession; class TransferPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::TRANSFER_PACKET; + /** @var string */ public $address; + /** @var int */ public $port = 19132; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/UnknownPacket.php b/src/pocketmine/network/mcpe/protocol/UnknownPacket.php index cd4844a26a..f628181d71 100644 --- a/src/pocketmine/network/mcpe/protocol/UnknownPacket.php +++ b/src/pocketmine/network/mcpe/protocol/UnknownPacket.php @@ -30,6 +30,7 @@ use pocketmine\network\mcpe\NetworkSession; class UnknownPacket extends DataPacket{ const NETWORK_ID = -1; //Invalid, do not try to write this + /** @var string */ public $payload; public function pid(){ diff --git a/src/pocketmine/network/mcpe/protocol/UpdateAttributesPacket.php b/src/pocketmine/network/mcpe/protocol/UpdateAttributesPacket.php index e2e9233256..1b02360787 100644 --- a/src/pocketmine/network/mcpe/protocol/UpdateAttributesPacket.php +++ b/src/pocketmine/network/mcpe/protocol/UpdateAttributesPacket.php @@ -32,6 +32,7 @@ use pocketmine\network\mcpe\NetworkSession; class UpdateAttributesPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::UPDATE_ATTRIBUTES_PACKET; + /** @var int */ public $entityRuntimeId; /** @var Attribute[] */ public $entries = []; diff --git a/src/pocketmine/network/mcpe/protocol/UpdateBlockPacket.php b/src/pocketmine/network/mcpe/protocol/UpdateBlockPacket.php index adcbe1d355..e46dbe96e2 100644 --- a/src/pocketmine/network/mcpe/protocol/UpdateBlockPacket.php +++ b/src/pocketmine/network/mcpe/protocol/UpdateBlockPacket.php @@ -40,11 +40,17 @@ class UpdateBlockPacket extends DataPacket{ const FLAG_ALL = self::FLAG_NEIGHBORS | self::FLAG_NETWORK; const FLAG_ALL_PRIORITY = self::FLAG_ALL | self::FLAG_PRIORITY; + /** @var int */ public $x; + /** @var int */ public $z; + /** @var int */ public $y; + /** @var int */ public $blockId; + /** @var int */ public $blockData; + /** @var int */ public $flags; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/UpdateEquipPacket.php b/src/pocketmine/network/mcpe/protocol/UpdateEquipPacket.php index 08d4136d69..b7de164549 100644 --- a/src/pocketmine/network/mcpe/protocol/UpdateEquipPacket.php +++ b/src/pocketmine/network/mcpe/protocol/UpdateEquipPacket.php @@ -30,10 +30,15 @@ use pocketmine\network\mcpe\NetworkSession; class UpdateEquipPacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::UPDATE_EQUIP_PACKET; + /** @var int */ public $windowId; + /** @var int */ public $windowType; + /** @var int */ public $unknownVarint; //TODO: find out what this is (vanilla always sends 0) + /** @var int */ public $entityUniqueId; + /** @var string */ public $namedtag; protected function decodePayload(){ diff --git a/src/pocketmine/network/mcpe/protocol/UpdateTradePacket.php b/src/pocketmine/network/mcpe/protocol/UpdateTradePacket.php index 41b122aef6..e6a11fa30d 100644 --- a/src/pocketmine/network/mcpe/protocol/UpdateTradePacket.php +++ b/src/pocketmine/network/mcpe/protocol/UpdateTradePacket.php @@ -34,14 +34,24 @@ class UpdateTradePacket extends DataPacket{ const NETWORK_ID = ProtocolInfo::UPDATE_TRADE_PACKET; //TODO: find fields + + /** @var int */ public $windowId; + /** @var int */ public $windowType = WindowTypes::TRADING; //Mojang hardcoded this -_- + /** @var int */ public $varint1; + /** @var int */ public $varint2; + /** @var bool */ public $isWilling; + /** @var int */ public $traderEid; + /** @var int */ public $playerEid; + /** @var string */ public $displayName; + /** @var string */ public $offers; protected function decodePayload(){