Added encode and decode methods for more packets

This commit is contained in:
Dylan K. Taylor 2017-05-15 15:56:59 +01:00
parent 162a08b8cb
commit 0a4d62b405
57 changed files with 244 additions and 78 deletions

View File

@ -1866,6 +1866,8 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->pitch = $this->pitch;
$pk->yaw = $this->yaw;
$pk->seed = -1;
$pk->dimension = 0; //TODO: implement this properly
$pk->worldGamemode = Player::getClientFriendlyGamemode($this->server->getGamemode());

View File

@ -86,7 +86,7 @@ class Arrow extends Projectile{
public function spawnTo(Player $player){
$pk = new AddEntityPacket();
$pk->type = Arrow::NETWORK_ID;
$pk->eid = $this->getId();
$pk->entityRuntimeId = $this->getId();
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;

View File

@ -145,7 +145,7 @@ class FallingSand extends Entity{
public function spawnTo(Player $player){
$pk = new AddEntityPacket();
$pk->type = FallingSand::NETWORK_ID;
$pk->eid = $this->getId();
$pk->entityRuntimeId = $this->getId();
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;

View File

@ -511,7 +511,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
$pk = new AddPlayerPacket();
$pk->uuid = $this->getUniqueId();
$pk->username = $this->getName();
$pk->eid = $this->getId();
$pk->entityRuntimeId = $this->getId();
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;

View File

@ -228,7 +228,7 @@ class Item extends Entity{
public function spawnTo(Player $player){
$pk = new AddItemEntityPacket();
$pk->eid = $this->getId();
$pk->entityRuntimeId = $this->getId();
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;

View File

@ -146,7 +146,7 @@ class PrimedTNT extends Entity implements Explosive{
public function spawnTo(Player $player){
$pk = new AddEntityPacket();
$pk->type = PrimedTNT::NETWORK_ID;
$pk->eid = $this->getId();
$pk->entityRuntimeId = $this->getId();
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;

View File

@ -62,7 +62,7 @@ class Snowball extends Projectile{
public function spawnTo(Player $player){
$pk = new AddEntityPacket();
$pk->type = Snowball::NETWORK_ID;
$pk->eid = $this->getId();
$pk->entityRuntimeId = $this->getId();
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;

View File

@ -148,7 +148,7 @@ class Squid extends WaterAnimal implements Ageable{
public function spawnTo(Player $player){
$pk = new AddEntityPacket();
$pk->eid = $this->getId();
$pk->entityRuntimeId = $this->getId();
$pk->type = Squid::NETWORK_ID;
$pk->x = $this->x;
$pk->y = $this->y;

View File

@ -52,7 +52,7 @@ class Villager extends Creature implements NPC, Ageable{
public function spawnTo(Player $player){
$pk = new AddEntityPacket();
$pk->eid = $this->getId();
$pk->entityRuntimeId = $this->getId();
$pk->type = Villager::NETWORK_ID;
$pk->x = $this->x;
$pk->y = $this->y;

View File

@ -39,7 +39,7 @@ class Zombie extends Monster{
public function spawnTo(Player $player){
$pk = new AddEntityPacket();
$pk->eid = $this->getId();
$pk->entityRuntimeId = $this->getId();
$pk->type = Zombie::NETWORK_ID;
$pk->x = $this->x;
$pk->y = $this->y;

View File

@ -77,7 +77,7 @@ class FloatingTextParticle extends Particle{
if(!$this->invisible){
$pk = new AddEntityPacket();
$pk->eid = $this->entityId;
$pk->entityRuntimeId = $this->entityId;
$pk->type = ItemEntity::NETWORK_ID;
$pk->x = $this->x;
$pk->y = $this->y - 0.75;

View File

@ -29,7 +29,8 @@ use pocketmine\network\mcpe\NetworkSession;
class AddEntityPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::ADD_ENTITY_PACKET;
public $eid;
public $entityUniqueId = null; //TODO
public $entityRuntimeId;
public $type;
public $x;
public $y;
@ -45,13 +46,27 @@ class AddEntityPacket extends DataPacket{
public $links = [];
public function decode(){
$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->pitch = $this->getLFloat();
$this->yaw = $this->getLFloat();
$this->attributes = $this->getAttributeList();
$this->metadata = $this->getEntityMetadata();
$linkCount = $this->getUnsignedVarInt();
for($i = 0; $i < $linkCount; ++$i){
$this->links[$i][0] = $this->getEntityUniqueId();
$this->links[$i][1] = $this->getEntityUniqueId();
$this->links[$i][2] = $this->getByte();
}
}
public function encode(){
$this->reset();
$this->putEntityUniqueId($this->eid);
$this->putEntityRuntimeId($this->eid);
$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);

View File

@ -33,10 +33,13 @@ class AddHangingEntityPacket extends DataPacket{
public $x;
public $y;
public $z;
public $unknown;
public $unknown; //TODO (rotation?)
public function decode(){
$this->entityUniqueId = $this->getEntityUniqueId();
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->getBlockPosition($this->x, $this->y, $this->z);
$this->unknown = $this->getVarInt();
}
public function encode(){

View File

@ -29,7 +29,8 @@ use pocketmine\network\mcpe\NetworkSession;
class AddItemEntityPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::ADD_ITEM_ENTITY_PACKET;
public $eid;
public $entityUniqueId = null; //TODO
public $entityRuntimeId;
public $item;
public $x;
public $y;
@ -40,13 +41,18 @@ class AddItemEntityPacket extends DataPacket{
public $metadata = [];
public function decode(){
$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->metadata = $this->getEntityMetadata();
}
public function encode(){
$this->reset();
$this->putEntityUniqueId($this->eid);
$this->putEntityRuntimeId($this->eid);
$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);

View File

@ -32,7 +32,7 @@ class AddItemPacket extends DataPacket{
public $item;
public function decode(){
$this->item = $this->getSlot();
}
public function encode(){

View File

@ -29,7 +29,8 @@ use pocketmine\network\mcpe\NetworkSession;
class AddPaintingPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::ADD_PAINTING_PACKET;
public $eid;
public $entityUniqueId = null; //TODO
public $entityRuntimeId;
public $x;
public $y;
public $z;
@ -37,13 +38,17 @@ class AddPaintingPacket extends DataPacket{
public $title;
public function decode(){
$this->entityUniqueId = $this->getEntityUniqueId();
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->getBlockPosition($this->x, $this->y, $this->z);
$this->direction = $this->getVarInt();
$this->title = $this->getString();
}
public function encode(){
$this->reset();
$this->putEntityUniqueId($this->eid);
$this->putEntityRuntimeId($this->eid);
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putBlockPosition($this->x, $this->y, $this->z);
$this->putVarInt($this->direction);
$this->putString($this->title);

View File

@ -30,7 +30,8 @@ class AddPlayerPacket extends DataPacket{
public $uuid;
public $username;
public $eid;
public $entityUniqueId = null; //TODO
public $entityRuntimeId;
public $x;
public $y;
public $z;
@ -44,15 +45,25 @@ class AddPlayerPacket extends DataPacket{
public $metadata = [];
public function decode(){
$this->uuid = $this->getUUID();
$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->pitch = $this->getLFloat();
$this->headYaw = $this->getLFloat();
$this->yaw = $this->getLFloat();
$this->item = $this->getSlot();
$this->metadata = $this->getEntityMetadata();
}
public function encode(){
$this->reset();
$this->putUUID($this->uuid);
$this->putString($this->username);
$this->putEntityUniqueId($this->eid);
$this->putEntityRuntimeId($this->eid);
$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->putLFloat($this->pitch);

View File

@ -31,7 +31,7 @@ class AnimatePacket extends DataPacket{
public $action;
public $eid;
public $float; //Boat rowing time?
public $float; //TODO (Boat rowing time?)
public function decode(){
$this->action = $this->getVarInt();

View File

@ -32,7 +32,8 @@ class AvailableCommandsPacket extends DataPacket{
public $unknown;
public function decode(){
$this->commands = $this->getString();
$this->unknown = $this->getString();
}
public function encode(){

View File

@ -36,7 +36,9 @@ class BlockEventPacket extends DataPacket{
public $case2;
public function decode(){
$this->getBlockPosition($this->x, $this->y, $this->z);
$this->case1 = $this->getVarInt();
$this->case2 = $this->getVarInt();
}
public function encode(){

View File

@ -39,7 +39,9 @@ class ChangeDimensionPacket extends DataPacket{
public $unknown; //bool
public function decode(){
$this->dimension = $this->getVarInt();
$this->getVector3f($this->x, $this->y, $this->z);
$this->unknown = $this->getBool();
}
public function encode(){

View File

@ -32,6 +32,7 @@ class ChunkRadiusUpdatedPacket extends DataPacket{
public $radius;
public function decode(){
$this->radius = $this->getVarInt();
}
public function encode(){

View File

@ -45,13 +45,23 @@ class CommandStepPacket extends DataPacket{
$this->done = $this->getBool();
$this->clientId = $this->getUnsignedVarLong();
$this->inputJson = json_decode($this->getString());
$this->outputJson = $this->getString();
$this->outputJson = json_decode($this->getString());
$this->get(true); //TODO: read command origin data
}
public function encode(){
$this->reset();
$this->putString($this->command);
$this->putString($this->overload);
$this->putUnsignedVarInt($this->uvarint1);
$this->putUnsignedVarInt($this->currentStep);
$this->putBool($this->done);
$this->putUnsignedVarLong($this->clientId);
$this->putString(json_encode($this->inputJson));
$this->putString(json_encode($this->outputJson));
$this->put("\x00\x00\x00"); //TODO: command origin data
}
public function handle(NetworkSession $session) : bool{

View File

@ -34,10 +34,13 @@ class ContainerOpenPacket extends DataPacket{
public $x;
public $y;
public $z;
public $entityId = -1;
public $entityUniqueId = -1;
public function decode(){
$this->windowid = $this->getByte();
$this->type = $this->getByte();
$this->getBlockPosition($this->x, $this->y, $this->z);
$this->entityUniqueId = $this->getEntityUniqueId();
}
public function encode(){
@ -45,7 +48,7 @@ class ContainerOpenPacket extends DataPacket{
$this->putByte($this->windowid);
$this->putByte($this->type);
$this->putBlockPosition($this->x, $this->y, $this->z);
$this->putEntityUniqueId($this->entityId);
$this->putEntityUniqueId($this->entityUniqueId);
}
public function handle(NetworkSession $session) : bool{

View File

@ -34,7 +34,9 @@ class ContainerSetDataPacket extends DataPacket{
public $value;
public function decode(){
$this->windowid = $this->getByte();
$this->property = $this->getVarInt();
$this->value = $this->getVarInt();
}
public function encode(){

View File

@ -25,12 +25,14 @@ namespace pocketmine\network\mcpe\protocol;
use pocketmine\item\Item;
use pocketmine\network\mcpe\NetworkSession;
use pocketmine\utils\UUID;
class CraftingEventPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::CRAFTING_EVENT_PACKET;
public $windowId;
public $type;
/** @var UUID */
public $id;
/** @var Item[] */
public $input = [];
@ -60,7 +62,20 @@ class CraftingEventPacket extends DataPacket{
}
public function encode(){
$this->reset();
$this->putByte($this->windowId);
$this->putVarInt($this->type);
$this->putUUID($this->id);
$this->putUnsignedVarInt(count($this->input));
foreach($this->input as $item){
$this->putSlot($item);
}
$this->putUnsignedVarInt(count($this->output));
foreach($this->output as $item){
$this->putSlot($item);
}
}
public function handle(NetworkSession $session) : bool{

View File

@ -40,7 +40,9 @@ class DropItemPacket extends DataPacket{
}
public function encode(){
$this->reset();
$this->putByte($this->type);
$this->putByte($this->item);
}
public function handle(NetworkSession $session) : bool{

View File

@ -29,18 +29,21 @@ use pocketmine\network\mcpe\NetworkSession;
class EntityFallPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::ENTITY_FALL_PACKET;
public $eid;
public $entityRuntimeId;
public $fallDistance;
public $bool1;
public function decode(){
$this->eid = $this->getEntityRuntimeId();
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->fallDistance = $this->getLFloat();
$this->bool1 = $this->getBool();
}
public function encode(){
$this->reset();
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putLFloat($this->fallDistance);
$this->putBool($this->bool1);
}
public function handle(NetworkSession $session) : bool{

View File

@ -24,6 +24,7 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\NetworkSession;
class ExplodePacket extends DataPacket{
@ -33,6 +34,7 @@ class ExplodePacket extends DataPacket{
public $y;
public $z;
public $radius;
/** @var Vector3[] */
public $records = [];
public function clean(){
@ -41,7 +43,14 @@ class ExplodePacket extends DataPacket{
}
public function decode(){
$this->getVector3f($this->x, $this->y, $this->z);
$this->radius = $this->getLFloat();
$count = $this->getUnsignedVarInt();
for($i = 0; $i < $count; ++$i){
$x = $y = $z = null;
$this->getBlockPosition($x, $y, $z);
$this->records[$i] = new Vector3($x, $y, $z);
}
}
public function encode(){

View File

@ -34,7 +34,9 @@ class FullChunkDataPacket extends DataPacket{
public $data;
public function decode(){
$this->chunkX = $this->getVarInt();
$this->chunkZ = $this->getVarInt();
$this->data = $this->getString();
}
public function encode(){

View File

@ -32,7 +32,7 @@ class HurtArmorPacket extends DataPacket{
public $health;
public function decode(){
$this->health = $this->getVarInt();
}
public function encode(){

View File

@ -34,10 +34,14 @@ class InventoryActionPacket extends DataPacket{
public $varint2;
public function decode(){
$this->uvarint0 = $this->getUnsignedVarInt();
$this->item = $this->getSlot();
$this->varint1 = $this->getVarInt();
$this->varint2 = $this->getVarInt();
}
public function encode(){
$this->reset();
$this->putUnsignedVarInt($this->uvarint0);
$this->putSlot($this->item);
$this->putVarInt($this->varint1);

View File

@ -38,7 +38,8 @@ class ItemFrameDropItemPacket extends DataPacket{
}
public function encode(){
$this->reset();
$this->putBlockPosition($this->x, $this->y, $this->z);
}
public function handle(NetworkSession $session) : bool{

View File

@ -104,7 +104,9 @@ class LevelEventPacket extends DataPacket{
public $data;
public function decode(){
$this->evid = $this->getVarInt();
$this->getVector3f($this->x, $this->y, $this->z);
$this->data = $this->getVarInt();
}
public function encode(){

View File

@ -85,7 +85,7 @@ class LoginPacket extends DataPacket{
}
public function encode(){
//TODO
}
public function decodeToken($token){

View File

@ -33,12 +33,12 @@ class MapInfoRequestPacket extends DataPacket{
public $mapId;
public function decode(){
$this->mapId = $this->getVarInt(); //signed var-long, actually entity ID (needs fixing)
$this->mapId = $this->getEntityUniqueId();
}
public function encode(){
$this->reset();
$this->putVarInt($this->mapId);
$this->putEntityUniqueId($this->mapId);
}
public function handle(NetworkSession $session) : bool{

View File

@ -30,6 +30,7 @@ class MobArmorEquipmentPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::MOB_ARMOR_EQUIPMENT_PACKET;
public $eid;
/** @var Item[] */
public $slots = [];
public function decode(){

View File

@ -41,7 +41,12 @@ class MobEffectPacket extends DataPacket{
public $duration;
public function decode(){
$this->eid = $this->getEntityRuntimeId();
$this->eventId = $this->getByte();
$this->effectId = $this->getVarInt();
$this->amplifier = $this->getVarInt();
$this->particles = $this->getBool();
$this->duration = $this->getVarInt();
}
public function encode(){

View File

@ -42,7 +42,11 @@ class PlayerInputPacket extends DataPacket{
}
public function encode(){
$this->reset();
$this->putLFloat($this->motionX);
$this->putLFloat($this->motionY);
$this->putBool($this->unknownBool1);
$this->putBool($this->unknownBool2);
}
public function handle(NetworkSession $session) : bool{

View File

@ -43,7 +43,19 @@ class PlayerListPacket extends DataPacket{
}
public function decode(){
$this->type = $this->getByte();
$count = $this->getUnsignedVarInt();
for($i = 0; $i < $count; ++$i){
if($this->type === self::TYPE_ADD){
$this->entries[$i][0] = $this->getUUID();
$this->entries[$i][1] = $this->getEntityUniqueId();
$this->entries[$i][2] = $this->getString();
$this->entries[$i][3] = $this->getString();
$this->entries[$i][4] = $this->getString();
}else{
$this->entries[$i][0] = $this->getUUID();
}
}
}
public function encode(){

View File

@ -38,7 +38,8 @@ class RemoveBlockPacket extends DataPacket{
}
public function encode(){
$this->reset();
$this->putBlockPosition($this->x, $this->y, $this->z);
}
public function handle(NetworkSession $session) : bool{

View File

@ -32,7 +32,7 @@ class RemoveEntityPacket extends DataPacket{
public $eid;
public function decode(){
$this->eid = $this->getEntityUniqueId();
}
public function encode(){

View File

@ -32,7 +32,7 @@ class ReplaceItemInSlotPacket extends DataPacket{
public $item;
public function decode(){
$this->item = $this->getSlot();
}
public function encode(){

View File

@ -36,7 +36,8 @@ class RequestChunkRadiusPacket extends DataPacket{
}
public function encode(){
$this->reset();
$this->putVarInt($this->radius);
}
public function handle(NetworkSession $session) : bool{

View File

@ -34,16 +34,12 @@ class RespawnPacket extends DataPacket{
public $z;
public function decode(){
$this->x = $this->getLFloat();
$this->y = $this->getLFloat();
$this->z = $this->getLFloat();
$this->getVector3f($this->x, $this->y, $this->z);
}
public function encode(){
$this->reset();
$this->putLFloat($this->x);
$this->putLFloat($this->y);
$this->putLFloat($this->z);
$this->putVector3f($this->x, $this->y, $this->z);
}
public function handle(NetworkSession $session) : bool{

View File

@ -32,7 +32,7 @@ class SetCommandsEnabledPacket extends DataPacket{
public $enabled;
public function decode(){
$this->enabled = $this->getBool();
}
public function encode(){

View File

@ -33,7 +33,8 @@ class SetEntityDataPacket extends DataPacket{
public $metadata;
public function decode(){
$this->eid = $this->getEntityRuntimeId();
$this->metadata = $this->getEntityMetadata();
}
public function encode(){

View File

@ -34,7 +34,9 @@ class SetEntityLinkPacket extends DataPacket{
public $type;
public function decode(){
$this->from = $this->getEntityUniqueId();
$this->to = $this->getEntityUniqueId();
$this->type = $this->getByte();
}
public function encode(){

View File

@ -35,7 +35,8 @@ class SetEntityMotionPacket extends DataPacket{
public $motionZ;
public function decode(){
$this->eid = $this->getEntityRuntimeId();
$this->getVector3f($this->motionX, $this->motionY, $this->motionZ);
}
public function encode(){

View File

@ -36,7 +36,9 @@ class SetSpawnPositionPacket extends DataPacket{
public $unknownBool;
public function decode(){
$this->unknown = $this->getVarInt();
$this->getBlockPosition($this->x, $this->y, $this->z);
$this->unknownBool = $this->getBool();
}
public function encode(){

View File

@ -31,7 +31,7 @@ class SetTimePacket extends DataPacket{
public $time;
public function decode(){
$this->time = $this->getVarInt();
}
public function encode(){

View File

@ -35,7 +35,8 @@ class SpawnExperienceOrbPacket extends DataPacket{
public $amount;
public function decode(){
$this->getVector3f($this->x, $this->y, $this->z);
$this->amount = $this->getVarInt();
}
public function encode(){

View File

@ -35,6 +35,8 @@ class StartGamePacket extends DataPacket{
public $x;
public $y;
public $z;
public $pitch;
public $yaw;
public $seed;
public $dimension;
public $generator = 1; //default infinite - 0 old, 1 infinite, 2 flat
@ -55,6 +57,29 @@ class StartGamePacket extends DataPacket{
public $premiumWorldTemplateId = "";
public function decode(){
$this->entityUniqueId = $this->getEntityUniqueId();
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->playerGamemode = $this->getVarInt();
$this->getVector3f($this->x, $this->y, $this->z);
$this->pitch = $this->getLFloat();
$this->yaw = $this->getLFloat();
$this->seed = $this->getVarInt();
$this->dimension = $this->getVarInt();
$this->generator = $this->getVarInt();
$this->worldGamemode = $this->getVarInt();
$this->difficulty = $this->getVarInt();
$this->getBlockPosition($this->spawnX, $this->spawnY, $this->spawnZ);
$this->hasAchievementsDisabled = $this->getBool();
$this->dayCycleStopTime = $this->getVarInt();
$this->eduMode = $this->getBool();
$this->rainLevel = $this->getLFloat();
$this->lightningLevel = $this->getLFloat();
$this->commandsEnabled = $this->getBool();
$this->isTexturePacksRequired = $this->getBool();
/*$gameRulesCount = */$this->getUnsignedVarInt(); //TODO
$this->levelId = $this->getString();
$this->worldName = $this->getString();
$this->premiumWorldTemplateId = $this->getString();
}
@ -64,8 +89,8 @@ class StartGamePacket extends DataPacket{
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putVarInt($this->playerGamemode); //client gamemode, other field is world gamemode
$this->putVector3f($this->x, $this->y, $this->z);
$this->putLFloat(0); //TODO: yaw/pitch
$this->putLFloat(0);
$this->putLFloat($this->pitch);
$this->putLFloat($this->yaw);
$this->putVarInt($this->seed);
$this->putVarInt($this->dimension);
$this->putVarInt($this->generator);

View File

@ -32,7 +32,8 @@ class TransferPacket extends DataPacket{
public $port = 19132;
public function decode(){
$this->address = $this->getString();
$this->port = $this->getLShort();
}
public function encode(){

View File

@ -35,7 +35,8 @@ class UpdateAttributesPacket extends DataPacket{
public $entries = [];
public function decode(){
$this->entityId = $this->getEntityRuntimeId();
$this->entries = $this->getAttributeList();
}
public function encode(){

View File

@ -46,7 +46,11 @@ class UpdateBlockPacket extends DataPacket{
public $flags;
public function decode(){
$this->getBlockPosition($this->x, $this->y, $this->z);
$this->blockId = $this->getUnsignedVarInt();
$aux = $this->getUnsignedVarInt();
$this->blockData = $aux & 0x0f;
$this->flags = $aux >> 4;
}
public function encode(){

View File

@ -34,7 +34,6 @@ class UseItemPacket extends DataPacket{
public $z;
public $blockId;
public $face;
public $item;
public $fx;
public $fy;
public $fz;
@ -42,6 +41,8 @@ class UseItemPacket extends DataPacket{
public $posY;
public $posZ;
public $slot;
/** @var Item */
public $item;
public function decode(){
$this->getBlockPosition($this->x, $this->y, $this->z);
@ -54,7 +55,13 @@ class UseItemPacket extends DataPacket{
}
public function encode(){
$this->reset();
$this->putUnsignedVarInt($this->blockId);
$this->putUnsignedVarInt($this->face);
$this->putVector3f($this->fx, $this->fy, $this->fz);
$this->putVector3f($this->posX, $this->posY, $this->posZ);
$this->putVarInt($this->slot);
$this->putSlot($this->item);
}
public function handle(NetworkSession $session) : bool{