Updated existing packets and added new ones

This commit is contained in:
Dylan K. Taylor 2016-10-04 15:07:53 +01:00
parent affed33066
commit 86ed0f1397
49 changed files with 597 additions and 220 deletions

View File

@ -1451,7 +1451,10 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
if($this->chunk !== null){ if($this->chunk !== null){
$this->level->addEntityMotion($this->chunk->getX(), $this->chunk->getZ(), $this->getId(), $this->motionX, $this->motionY, $this->motionZ); $this->level->addEntityMotion($this->chunk->getX(), $this->chunk->getZ(), $this->getId(), $this->motionX, $this->motionY, $this->motionZ);
$pk = new SetEntityMotionPacket(); $pk = new SetEntityMotionPacket();
$pk->entities[] = [0, $mot->x, $mot->y, $mot->z]; $pk->eid = 0;
$pk->motionX = $mot->x;
$pk->motionY = $mot->y;
$pk->motionZ = $mot->z;
$this->dataPacket($pk); $this->dataPacket($pk);
} }

View File

@ -723,9 +723,14 @@ class Level implements ChunkManager, Metadatable{
foreach($this->motionToSend as $index => $entry){ foreach($this->motionToSend as $index => $entry){
Level::getXZ($index, $chunkX, $chunkZ); Level::getXZ($index, $chunkX, $chunkZ);
$pk = new SetEntityMotionPacket(); foreach($entry as $entity){
$pk->entities = $entry; $pk = new SetEntityMotionPacket();
$this->addChunkPacket($chunkX, $chunkZ, $pk); $pk->eid = $entity[0];
$pk->motionX = $entity[1];
$pk->motionY = $entity[2];
$pk->motionZ = $entity[3];
$this->addChunkPacket($chunkX, $chunkZ, $pk);
}
} }
$this->motionToSend = []; $this->motionToSend = [];

View File

@ -25,7 +25,9 @@
namespace pocketmine\network; namespace pocketmine\network;
use pocketmine\network\protocol\AddEntityPacket; use pocketmine\network\protocol\AddEntityPacket;
use pocketmine\network\protocol\AddHangingEntityPacket;
use pocketmine\network\protocol\AddItemEntityPacket; use pocketmine\network\protocol\AddItemEntityPacket;
use pocketmine\network\protocol\AddItemPacket;
use pocketmine\network\protocol\AddPaintingPacket; use pocketmine\network\protocol\AddPaintingPacket;
use pocketmine\network\protocol\AddPlayerPacket; use pocketmine\network\protocol\AddPlayerPacket;
use pocketmine\network\protocol\AdventureSettingsPacket; use pocketmine\network\protocol\AdventureSettingsPacket;
@ -52,19 +54,25 @@ use pocketmine\network\protocol\HurtArmorPacket;
use pocketmine\network\protocol\Info as ProtocolInfo; use pocketmine\network\protocol\Info as ProtocolInfo;
use pocketmine\network\protocol\Info; use pocketmine\network\protocol\Info;
use pocketmine\network\protocol\InteractPacket; use pocketmine\network\protocol\InteractPacket;
use pocketmine\network\protocol\InventoryActionPacket;
use pocketmine\network\protocol\ItemFrameDropItemPacket;
use pocketmine\network\protocol\LevelEventPacket; use pocketmine\network\protocol\LevelEventPacket;
use pocketmine\network\protocol\LevelSoundEventPacket;
use pocketmine\network\protocol\LoginPacket; use pocketmine\network\protocol\LoginPacket;
use pocketmine\network\protocol\MobArmorEquipmentPacket; use pocketmine\network\protocol\MobArmorEquipmentPacket;
use pocketmine\network\protocol\MobEquipmentPacket; use pocketmine\network\protocol\MobEquipmentPacket;
use pocketmine\network\protocol\MoveEntityPacket; use pocketmine\network\protocol\MoveEntityPacket;
use pocketmine\network\protocol\MovePlayerPacket; use pocketmine\network\protocol\MovePlayerPacket;
use pocketmine\network\protocol\PlayerActionPacket; use pocketmine\network\protocol\PlayerActionPacket;
use pocketmine\network\protocol\PlayerInputPacket;
use pocketmine\network\protocol\PlayerListPacket; use pocketmine\network\protocol\PlayerListPacket;
use pocketmine\network\protocol\PlayStatusPacket; use pocketmine\network\protocol\PlayStatusPacket;
use pocketmine\network\protocol\RemoveBlockPacket; use pocketmine\network\protocol\RemoveBlockPacket;
use pocketmine\network\protocol\RemoveEntityPacket; use pocketmine\network\protocol\RemoveEntityPacket;
use pocketmine\network\protocol\ReplaceSelectedItemPacket;
use pocketmine\network\protocol\RequestChunkRadiusPacket; use pocketmine\network\protocol\RequestChunkRadiusPacket;
use pocketmine\network\protocol\RespawnPacket; use pocketmine\network\protocol\RespawnPacket;
use pocketmine\network\protocol\SetCommandsEnabledPacket;
use pocketmine\network\protocol\SetDifficultyPacket; use pocketmine\network\protocol\SetDifficultyPacket;
use pocketmine\network\protocol\SetEntityDataPacket; use pocketmine\network\protocol\SetEntityDataPacket;
use pocketmine\network\protocol\SetEntityLinkPacket; use pocketmine\network\protocol\SetEntityLinkPacket;
@ -73,6 +81,7 @@ use pocketmine\network\protocol\SetHealthPacket;
use pocketmine\network\protocol\SetPlayerGameTypePacket; use pocketmine\network\protocol\SetPlayerGameTypePacket;
use pocketmine\network\protocol\SetSpawnPositionPacket; use pocketmine\network\protocol\SetSpawnPositionPacket;
use pocketmine\network\protocol\SetTimePacket; use pocketmine\network\protocol\SetTimePacket;
use pocketmine\network\protocol\SpawnExperienceOrbPacket;
use pocketmine\network\protocol\StartGamePacket; use pocketmine\network\protocol\StartGamePacket;
use pocketmine\network\protocol\TakeItemEntityPacket; use pocketmine\network\protocol\TakeItemEntityPacket;
use pocketmine\network\protocol\TextPacket; use pocketmine\network\protocol\TextPacket;
@ -230,6 +239,7 @@ class Network{
$pk->setBuffer($buf, 1); $pk->setBuffer($buf, 1);
$pk->decode(); $pk->decode();
assert($pk->feof(), "Still " . strlen(substr($pk->buffer, $pk->offset)) . " bytes unread in " . get_class($pk));
$p->handleDataPacket($pk); $p->handleDataPacket($pk);
} }
} }
@ -283,56 +293,65 @@ class Network{
private function registerPackets(){ private function registerPackets(){
$this->packetPool = new \SplFixedArray(256); $this->packetPool = new \SplFixedArray(256);
$this->registerPacket(ProtocolInfo::LOGIN_PACKET, LoginPacket::class);
$this->registerPacket(ProtocolInfo::PLAY_STATUS_PACKET, PlayStatusPacket::class);
$this->registerPacket(ProtocolInfo::DISCONNECT_PACKET, DisconnectPacket::class);
$this->registerPacket(ProtocolInfo::BATCH_PACKET, BatchPacket::class);
$this->registerPacket(ProtocolInfo::TEXT_PACKET, TextPacket::class);
$this->registerPacket(ProtocolInfo::SET_TIME_PACKET, SetTimePacket::class);
$this->registerPacket(ProtocolInfo::START_GAME_PACKET, StartGamePacket::class);
$this->registerPacket(ProtocolInfo::ADD_PLAYER_PACKET, AddPlayerPacket::class);
$this->registerPacket(ProtocolInfo::ADD_ENTITY_PACKET, AddEntityPacket::class); $this->registerPacket(ProtocolInfo::ADD_ENTITY_PACKET, AddEntityPacket::class);
$this->registerPacket(ProtocolInfo::REMOVE_ENTITY_PACKET, RemoveEntityPacket::class); $this->registerPacket(ProtocolInfo::ADD_HANGING_ENTITY_PACKET, AddHangingEntityPacket::class);
$this->registerPacket(ProtocolInfo::ADD_ITEM_ENTITY_PACKET, AddItemEntityPacket::class); $this->registerPacket(ProtocolInfo::ADD_ITEM_ENTITY_PACKET, AddItemEntityPacket::class);
$this->registerPacket(ProtocolInfo::TAKE_ITEM_ENTITY_PACKET, TakeItemEntityPacket::class); $this->registerPacket(ProtocolInfo::ADD_ITEM_PACKET, AddItemPacket::class);
$this->registerPacket(ProtocolInfo::MOVE_ENTITY_PACKET, MoveEntityPacket::class);
$this->registerPacket(ProtocolInfo::MOVE_PLAYER_PACKET, MovePlayerPacket::class);
$this->registerPacket(ProtocolInfo::REMOVE_BLOCK_PACKET, RemoveBlockPacket::class);
$this->registerPacket(ProtocolInfo::UPDATE_BLOCK_PACKET, UpdateBlockPacket::class);
$this->registerPacket(ProtocolInfo::ADD_PAINTING_PACKET, AddPaintingPacket::class); $this->registerPacket(ProtocolInfo::ADD_PAINTING_PACKET, AddPaintingPacket::class);
$this->registerPacket(ProtocolInfo::EXPLODE_PACKET, ExplodePacket::class); $this->registerPacket(ProtocolInfo::ADD_PLAYER_PACKET, AddPlayerPacket::class);
$this->registerPacket(ProtocolInfo::LEVEL_EVENT_PACKET, LevelEventPacket::class); $this->registerPacket(ProtocolInfo::ADVENTURE_SETTINGS_PACKET, AdventureSettingsPacket::class);
$this->registerPacket(ProtocolInfo::BLOCK_EVENT_PACKET, BlockEventPacket::class);
$this->registerPacket(ProtocolInfo::ENTITY_EVENT_PACKET, EntityEventPacket::class);
$this->registerPacket(ProtocolInfo::MOB_EQUIPMENT_PACKET, MobEquipmentPacket::class);
$this->registerPacket(ProtocolInfo::MOB_ARMOR_EQUIPMENT_PACKET, MobArmorEquipmentPacket::class);
$this->registerPacket(ProtocolInfo::INTERACT_PACKET, InteractPacket::class);
$this->registerPacket(ProtocolInfo::USE_ITEM_PACKET, UseItemPacket::class);
$this->registerPacket(ProtocolInfo::PLAYER_ACTION_PACKET, PlayerActionPacket::class);
$this->registerPacket(ProtocolInfo::HURT_ARMOR_PACKET, HurtArmorPacket::class);
$this->registerPacket(ProtocolInfo::SET_ENTITY_DATA_PACKET, SetEntityDataPacket::class);
$this->registerPacket(ProtocolInfo::SET_ENTITY_MOTION_PACKET, SetEntityMotionPacket::class);
$this->registerPacket(ProtocolInfo::SET_ENTITY_LINK_PACKET, SetEntityLinkPacket::class);
$this->registerPacket(ProtocolInfo::SET_HEALTH_PACKET, SetHealthPacket::class);
$this->registerPacket(ProtocolInfo::SET_SPAWN_POSITION_PACKET, SetSpawnPositionPacket::class);
$this->registerPacket(ProtocolInfo::ANIMATE_PACKET, AnimatePacket::class); $this->registerPacket(ProtocolInfo::ANIMATE_PACKET, AnimatePacket::class);
$this->registerPacket(ProtocolInfo::RESPAWN_PACKET, RespawnPacket::class); $this->registerPacket(ProtocolInfo::BATCH_PACKET, BatchPacket::class);
$this->registerPacket(ProtocolInfo::DROP_ITEM_PACKET, DropItemPacket::class); $this->registerPacket(ProtocolInfo::BLOCK_ENTITY_DATA_PACKET, BlockEntityDataPacket::class);
$this->registerPacket(ProtocolInfo::CONTAINER_OPEN_PACKET, ContainerOpenPacket::class); $this->registerPacket(ProtocolInfo::BLOCK_EVENT_PACKET, BlockEventPacket::class);
$this->registerPacket(ProtocolInfo::CHANGE_DIMENSION_PACKET, ChangeDimensionPacket::class);
$this->registerPacket(ProtocolInfo::CHUNK_RADIUS_UPDATED_PACKET, ChunkRadiusUpdatedPacket::class);
$this->registerPacket(ProtocolInfo::CONTAINER_CLOSE_PACKET, ContainerClosePacket::class); $this->registerPacket(ProtocolInfo::CONTAINER_CLOSE_PACKET, ContainerClosePacket::class);
$this->registerPacket(ProtocolInfo::CONTAINER_SET_SLOT_PACKET, ContainerSetSlotPacket::class); $this->registerPacket(ProtocolInfo::CONTAINER_OPEN_PACKET, ContainerOpenPacket::class);
$this->registerPacket(ProtocolInfo::CONTAINER_SET_DATA_PACKET, ContainerSetDataPacket::class);
$this->registerPacket(ProtocolInfo::CONTAINER_SET_CONTENT_PACKET, ContainerSetContentPacket::class); $this->registerPacket(ProtocolInfo::CONTAINER_SET_CONTENT_PACKET, ContainerSetContentPacket::class);
$this->registerPacket(ProtocolInfo::CONTAINER_SET_DATA_PACKET, ContainerSetDataPacket::class);
$this->registerPacket(ProtocolInfo::CONTAINER_SET_SLOT_PACKET, ContainerSetSlotPacket::class);
$this->registerPacket(ProtocolInfo::CRAFTING_DATA_PACKET, CraftingDataPacket::class); $this->registerPacket(ProtocolInfo::CRAFTING_DATA_PACKET, CraftingDataPacket::class);
$this->registerPacket(ProtocolInfo::CRAFTING_EVENT_PACKET, CraftingEventPacket::class); $this->registerPacket(ProtocolInfo::CRAFTING_EVENT_PACKET, CraftingEventPacket::class);
$this->registerPacket(ProtocolInfo::ADVENTURE_SETTINGS_PACKET, AdventureSettingsPacket::class); $this->registerPacket(ProtocolInfo::DISCONNECT_PACKET, DisconnectPacket::class);
$this->registerPacket(ProtocolInfo::BLOCK_ENTITY_DATA_PACKET, BlockEntityDataPacket::class); $this->registerPacket(ProtocolInfo::DROP_ITEM_PACKET, DropItemPacket::class);
$this->registerPacket(ProtocolInfo::ENTITY_EVENT_PACKET, EntityEventPacket::class);
$this->registerPacket(ProtocolInfo::EXPLODE_PACKET, ExplodePacket::class);
$this->registerPacket(ProtocolInfo::FULL_CHUNK_DATA_PACKET, FullChunkDataPacket::class); $this->registerPacket(ProtocolInfo::FULL_CHUNK_DATA_PACKET, FullChunkDataPacket::class);
$this->registerPacket(ProtocolInfo::SET_DIFFICULTY_PACKET, SetDifficultyPacket::class); $this->registerPacket(ProtocolInfo::HURT_ARMOR_PACKET, HurtArmorPacket::class);
$this->registerPacket(ProtocolInfo::SET_PLAYER_GAMETYPE_PACKET, SetPlayerGameTypePacket::class); $this->registerPacket(ProtocolInfo::INTERACT_PACKET, InteractPacket::class);
$this->registerPacket(ProtocolInfo::CHANGE_DIMENSION_PACKET, ChangeDimensionPacket::class); $this->registerPacket(ProtocolInfo::INVENTORY_ACTION_PACKET, InventoryActionPacket::class);
$this->registerPacket(ProtocolInfo::ITEM_FRAME_DROP_ITEM_PACKET, ItemFrameDropItemPacket::class);
$this->registerPacket(ProtocolInfo::LEVEL_EVENT_PACKET, LevelEventPacket::class);
$this->registerPacket(ProtocolInfo::LEVEL_SOUND_EVENT_PACKET, LevelSoundEventPacket::class);
$this->registerPacket(ProtocolInfo::LOGIN_PACKET, LoginPacket::class);
$this->registerPacket(ProtocolInfo::MOB_ARMOR_EQUIPMENT_PACKET, MobArmorEquipmentPacket::class);
$this->registerPacket(ProtocolInfo::MOB_EQUIPMENT_PACKET, MobEquipmentPacket::class);
$this->registerPacket(ProtocolInfo::MOVE_ENTITY_PACKET, MoveEntityPacket::class);
$this->registerPacket(ProtocolInfo::MOVE_PLAYER_PACKET, MovePlayerPacket::class);
$this->registerPacket(ProtocolInfo::PLAYER_ACTION_PACKET, PlayerActionPacket::class);
$this->registerPacket(ProtocolInfo::PLAYER_INPUT_PACKET, PlayerInputPacket::class);
$this->registerPacket(ProtocolInfo::PLAYER_LIST_PACKET, PlayerListPacket::class); $this->registerPacket(ProtocolInfo::PLAYER_LIST_PACKET, PlayerListPacket::class);
$this->registerPacket(ProtocolInfo::PLAY_STATUS_PACKET, PlayStatusPacket::class);
$this->registerPacket(ProtocolInfo::REMOVE_BLOCK_PACKET, RemoveBlockPacket::class);
$this->registerPacket(ProtocolInfo::REMOVE_ENTITY_PACKET, RemoveEntityPacket::class);
$this->registerPacket(ProtocolInfo::REPLACE_SELECTED_ITEM_PACKET, ReplaceSelectedItemPacket::class);
$this->registerPacket(ProtocolInfo::REQUEST_CHUNK_RADIUS_PACKET, RequestChunkRadiusPacket::class); $this->registerPacket(ProtocolInfo::REQUEST_CHUNK_RADIUS_PACKET, RequestChunkRadiusPacket::class);
$this->registerPacket(ProtocolInfo::CHUNK_RADIUS_UPDATED_PACKET, ChunkRadiusUpdatedPacket::class); $this->registerPacket(ProtocolInfo::RESPAWN_PACKET, RespawnPacket::class);
$this->registerPacket(ProtocolInfo::SET_COMMANDS_ENABLED_PACKET, SetCommandsEnabledPacket::class);
$this->registerPacket(ProtocolInfo::SET_DIFFICULTY_PACKET, SetDifficultyPacket::class);
$this->registerPacket(ProtocolInfo::SET_ENTITY_DATA_PACKET, SetEntityDataPacket::class);
$this->registerPacket(ProtocolInfo::SET_ENTITY_LINK_PACKET, SetEntityLinkPacket::class);
$this->registerPacket(ProtocolInfo::SET_ENTITY_MOTION_PACKET, SetEntityMotionPacket::class);
$this->registerPacket(ProtocolInfo::SET_HEALTH_PACKET, SetHealthPacket::class);
$this->registerPacket(ProtocolInfo::SET_PLAYER_GAMETYPE_PACKET, SetPlayerGameTypePacket::class);
$this->registerPacket(ProtocolInfo::SET_SPAWN_POSITION_PACKET, SetSpawnPositionPacket::class);
$this->registerPacket(ProtocolInfo::SET_TIME_PACKET, SetTimePacket::class);
$this->registerPacket(ProtocolInfo::SPAWN_EXPERIENCE_ORB_PACKET, SpawnExperienceOrbPacket::class);
$this->registerPacket(ProtocolInfo::START_GAME_PACKET, StartGamePacket::class);
$this->registerPacket(ProtocolInfo::TAKE_ITEM_ENTITY_PACKET, TakeItemEntityPacket::class);
$this->registerPacket(ProtocolInfo::TEXT_PACKET, TextPacket::class);
$this->registerPacket(ProtocolInfo::UPDATE_BLOCK_PACKET, UpdateBlockPacket::class);
$this->registerPacket(ProtocolInfo::USE_ITEM_PACKET, UseItemPacket::class);
} }
} }

View File

@ -132,6 +132,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
$pk = $this->getPacket($packet->buffer); $pk = $this->getPacket($packet->buffer);
if($pk !== null){ if($pk !== null){
$pk->decode(); $pk->decode();
assert($pk->feof(), "Still " . strlen(substr($pk->buffer, $pk->offset)) . " bytes unread!");
$this->players[$identifier]->handleDataPacket($pk); $this->players[$identifier]->handleDataPacket($pk);
} }
} }

View File

@ -51,23 +51,20 @@ class AddEntityPacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putLong($this->eid); $this->putEntityId($this->eid); //EntityUniqueID - TODO: verify this
$this->putInt($this->type); $this->putEntityId($this->eid);
$this->putFloat($this->x); $this->putUnsignedVarInt($this->type);
$this->putFloat($this->y); $this->putVector3f($this->x, $this->y, $this->z);
$this->putFloat($this->z); $this->putVector3f($this->speedX, $this->speedY, $this->speedZ);
$this->putFloat($this->speedX); $this->putLFloat($this->yaw * (256 / 360));
$this->putFloat($this->speedY); $this->putLFloat($this->pitch * (256 / 360));
$this->putFloat($this->speedZ); $this->putUnsignedVarInt($this->modifiers); //attributes?
$this->putFloat($this->yaw * (256 / 360));
$this->putFloat($this->pitch * (256 / 360));
$this->putInt($this->modifiers);
$meta = Binary::writeMetadata($this->metadata); $meta = Binary::writeMetadata($this->metadata);
$this->put($meta); $this->put($meta);
$this->putShort(count($this->links)); $this->putUnsignedVarInt(count($this->links));
foreach($this->links as $link){ foreach($this->links as $link){
$this->putLong($link[0]); $this->putEntityId($link[0]);
$this->putLong($link[1]); $this->putEntityId($link[1]);
$this->putByte($link[2]); $this->putByte($link[2]);
} }
} }

View File

@ -0,0 +1,48 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\network\protocol;
#include <rules/DataPacket.h>
class AddHangingEntityPacket extends DataPacket{
const NETWORK_ID = Info::ADD_HANGING_ENTITY_PACKET;
public $entityUniqueId;
public $entityRuntimeId;
public $x;
public $y;
public $z;
public $unknown;
public function decode(){
}
public function encode(){
$this->reset();
$this->putEntityId($this->entityUniqueId);
$this->putEntityId($this->entityRuntimeId);
$this->putBlockCoords($this->x, $this->y, $this->z);
$this->putVarInt($this->unknown);
}
}

View File

@ -42,14 +42,11 @@ class AddItemEntityPacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putLong($this->eid); $this->putEntityId($this->eid); //EntityUniqueID
$this->putEntityId($this->eid); //EntityRuntimeID
$this->putSlot($this->item); $this->putSlot($this->item);
$this->putFloat($this->x); $this->putVector3f($this->x, $this->y, $this->z);
$this->putFloat($this->y); $this->putVector3f($this->speedX, $this->speedY, $this->speedZ);
$this->putFloat($this->z);
$this->putFloat($this->speedX);
$this->putFloat($this->speedY);
$this->putFloat($this->speedZ);
} }
} }

View File

@ -0,0 +1,41 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\network\protocol;
#include <rules/DataPacket.h>
class AddItemPacket extends DataPacket{
const NETWORK_ID = Info::ADD_ITEM_PACKET;
public $item;
public function decode(){
}
public function encode(){
$this->reset();
$this->putSlot($this->item);
}
}

View File

@ -40,11 +40,10 @@ class AddPaintingPacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putLong($this->eid); $this->putEntityId($this->eid); //EntityUniqueID
$this->putInt($this->x); $this->putEntityId($this->eid); //EntityRuntimeID
$this->putInt($this->y); $this->putBlockCoords($this->x, $this->y, $this->z);
$this->putInt($this->z); $this->putVarInt($this->direction);
$this->putInt($this->direction);
$this->putString($this->title); $this->putString($this->title);
} }

View File

@ -53,16 +53,14 @@ class AddPlayerPacket extends DataPacket{
$this->reset(); $this->reset();
$this->putUUID($this->uuid); $this->putUUID($this->uuid);
$this->putString($this->username); $this->putString($this->username);
$this->putLong($this->eid); $this->putEntityId($this->eid); //EntityUniqueID
$this->putFloat($this->x); $this->putEntityId($this->eid); //EntityRuntimeID
$this->putFloat($this->y); $this->putVector3f($this->x, $this->y, $this->z);
$this->putFloat($this->z); $this->putVector3f($this->speedX, $this->speedY, $this->speedZ);
$this->putFloat($this->speedX); //TODO: check these are in the right order
$this->putFloat($this->speedY); $this->putLFloat($this->yaw);
$this->putFloat($this->speedZ); $this->putLFloat($this->yaw); //TODO headrot
$this->putFloat($this->yaw); $this->putLFloat($this->pitch);
$this->putFloat($this->yaw); //TODO headrot
$this->putFloat($this->pitch);
$this->putSlot($this->item); $this->putSlot($this->item);
$meta = Binary::writeMetadata($this->metadata); $meta = Binary::writeMetadata($this->metadata);

View File

@ -32,13 +32,13 @@ class AnimatePacket extends DataPacket{
public function decode(){ public function decode(){
$this->action = $this->getByte(); $this->action = $this->getByte();
$this->eid = $this->getLong(); $this->eid = $this->getEntityId();
} }
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putByte($this->action); $this->putByte($this->action);
$this->putLong($this->eid); $this->putEntityId($this->eid);
} }
} }

View File

@ -33,17 +33,13 @@ class BlockEntityDataPacket extends DataPacket{
public $namedtag; public $namedtag;
public function decode(){ public function decode(){
$this->x = $this->getInt(); $this->getBlockCoords($this->x, $this->y, $this->z);
$this->y = $this->getInt();
$this->z = $this->getInt();
$this->namedtag = $this->get(true); $this->namedtag = $this->get(true);
} }
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putInt($this->x); $this->putBlockCoords($this->x, $this->y, $this->z);
$this->putInt($this->y);
$this->putInt($this->z);
$this->put($this->namedtag); $this->put($this->namedtag);
} }

View File

@ -39,11 +39,9 @@ class BlockEventPacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putInt($this->x); $this->putBlockCoords($this->x, $this->y, $this->z);
$this->putInt($this->y); $this->putVarInt($this->case1);
$this->putInt($this->z); $this->putVarInt($this->case2);
$this->putInt($this->case1);
$this->putInt($this->case2);
} }
} }

View File

@ -34,7 +34,7 @@ class ChangeDimensionPacket extends DataPacket{
public $x; public $x;
public $y; public $y;
public $z; public $z;
public $unknown; public $unknown; //bool
public function decode(){ public function decode(){
@ -42,10 +42,8 @@ class ChangeDimensionPacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putByte($this->dimension); $this->putVarInt($this->dimension);
$this->putFloat($this->x); $this->putVector3f($this->x, $this->y, $this->z);
$this->putFloat($this->y);
$this->putFloat($this->z);
$this->putByte($this->unknown); $this->putByte($this->unknown);
} }

View File

@ -33,6 +33,7 @@ class ContainerOpenPacket extends DataPacket{
public $x; public $x;
public $y; public $y;
public $z; public $z;
public $entityId = -1;
public function decode(){ public function decode(){
@ -42,10 +43,9 @@ class ContainerOpenPacket extends DataPacket{
$this->reset(); $this->reset();
$this->putByte($this->windowid); $this->putByte($this->windowid);
$this->putByte($this->type); $this->putByte($this->type);
$this->putShort($this->slots); $this->putVarInt($this->slots);
$this->putInt($this->x); $this->putBlockCoords($this->x, $this->y, $this->z);
$this->putInt($this->y); $this->putEntityId($this->entityId);
$this->putInt($this->z);
} }
} }

View File

@ -38,8 +38,8 @@ class ContainerSetDataPacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putByte($this->windowid); $this->putByte($this->windowid);
$this->putShort($this->property); $this->putVarInt($this->property);
$this->putShort($this->value); $this->putVarInt($this->value);
} }
} }

View File

@ -47,16 +47,19 @@ class EntityEventPacket extends DataPacket{
public $eid; public $eid;
public $event; public $event;
public $unknown;
public function decode(){ public function decode(){
$this->eid = $this->getLong(); $this->eid = $this->getEntityId();
$this->event = $this->getByte(); $this->event = $this->getByte();
$this->unknown = $this->getVarInt();
} }
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putLong($this->eid); $this->putEntityId($this->eid);
$this->putByte($this->event); $this->putByte($this->event);
$this->putVarInt($this->unknown);
} }
} }

View File

@ -44,16 +44,12 @@ class ExplodePacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putFloat($this->x); $this->putVector3f($this->x, $this->y, $this->z);
$this->putFloat($this->y); $this->putLFloat($this->radius);
$this->putFloat($this->z); $this->putUnsignedVarInt(count($this->records));
$this->putFloat($this->radius);
$this->putInt(count($this->records));
if(count($this->records) > 0){ if(count($this->records) > 0){
foreach($this->records as $record){ foreach($this->records as $record){
$this->putByte($record->x); $this->putBlockCoords($record->x, $record->y, $record->z);
$this->putByte($record->y);
$this->putByte($record->z);
} }
} }
} }

View File

@ -35,7 +35,7 @@ class HurtArmorPacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putByte($this->health); $this->putVarInt($this->health);
} }
} }

View File

@ -39,13 +39,13 @@ class InteractPacket extends DataPacket{
public function decode(){ public function decode(){
$this->action = $this->getByte(); $this->action = $this->getByte();
$this->target = $this->getLong(); $this->target = $this->getEntityId();
} }
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putByte($this->action); $this->putByte($this->action);
$this->putLong($this->target); $this->putEntityId($this->target);
} }
} }

View File

@ -0,0 +1,40 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\network\protocol;
#include <rules/DataPacket.h>
class InventoryActionPacket extends DataPacket{
const NETWORK_ID = Info::INVENTORY_ACTION_PACKET;
public $unknown;
public $item;
public function decode(){
}
public function encode(){
$this->putUnsignedVarInt($this->unknown);
$this->putSlot($this->item);
}
}

View File

@ -0,0 +1,44 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\network\protocol;
#include <rules/DataPacket.h>
class ItemFrameDropItemPacket extends DataPacket{
const NETWORK_ID = Info::ITEM_FRAME_DROP_ITEM_PACKET;
public $x;
public $y;
public $z;
public $item;
public function decode(){
$this->getBlockCoords($this->x, $this->y, $this->z);
$this->item = $this->getSlot();
}
public function encode(){
}
}

View File

@ -23,7 +23,6 @@ namespace pocketmine\network\protocol;
#include <rules/DataPacket.h> #include <rules/DataPacket.h>
class LevelEventPacket extends DataPacket{ class LevelEventPacket extends DataPacket{
const NETWORK_ID = Info::LEVEL_EVENT_PACKET; const NETWORK_ID = Info::LEVEL_EVENT_PACKET;
@ -67,9 +66,9 @@ class LevelEventPacket extends DataPacket{
const EVENT_ADD_PARTICLE_MASK = 0x4000; const EVENT_ADD_PARTICLE_MASK = 0x4000;
public $evid; public $evid;
public $x; public $x = 0; //Weather effects don't have coordinates
public $y; public $y = 0;
public $z; public $z = 0;
public $data; public $data;
public function decode(){ public function decode(){
@ -78,11 +77,9 @@ class LevelEventPacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putShort($this->evid); $this->putVarInt($this->evid);
$this->putFloat($this->x); $this->putVector3f($this->x, $this->y, $this->z);
$this->putFloat($this->y); $this->putVarInt($this->data);
$this->putFloat($this->z);
$this->putInt($this->data);
} }
} }

View File

@ -0,0 +1,50 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\network\protocol;
#include <rules/DataPacket.h>
class LevelSoundEventPacket extends DataPacket{
const NETWORK_ID = Info::LEVEL_SOUND_EVENT_PACKET;
//TODO: find unknowns
public $unknownByte;
public $x;
public $y;
public $z;
public $unknownVarInt1;
public $unknownVarInt2;
public $unknownBool;
public function decode(){
}
public function encode(){
$this->reset();
$this->putByte($this->unknownByte);
$this->putVector3f($this->x, $this->y, $this->z);
$this->putVarInt($this->unknownVarInt1);
$this->putVarInt($this->unknownVarInt2);
$this->putByte($this->unknownBool);
}
}

View File

@ -31,7 +31,7 @@ class MobArmorEquipmentPacket extends DataPacket{
public $slots = []; public $slots = [];
public function decode(){ public function decode(){
$this->eid = $this->getLong(); $this->eid = $this->getEntityId();
$this->slots[0] = $this->getSlot(); $this->slots[0] = $this->getSlot();
$this->slots[1] = $this->getSlot(); $this->slots[1] = $this->getSlot();
$this->slots[2] = $this->getSlot(); $this->slots[2] = $this->getSlot();
@ -40,7 +40,7 @@ class MobArmorEquipmentPacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putLong($this->eid); $this->putEntityId($this->eid);
$this->putSlot($this->slots[0]); $this->putSlot($this->slots[0]);
$this->putSlot($this->slots[1]); $this->putSlot($this->slots[1]);
$this->putSlot($this->slots[2]); $this->putSlot($this->slots[2]);

View File

@ -44,12 +44,12 @@ class MobEffectPacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putLong($this->eid); $this->putEntityId($this->eid);
$this->putByte($this->eventId); $this->putByte($this->eventId);
$this->putByte($this->effectId); $this->putVarInt($this->effectId);
$this->putByte($this->amplifier); $this->putVarInt($this->amplifier);
$this->putByte($this->particles ? 1 : 0); $this->putByte($this->particles);
$this->putInt($this->duration); $this->putVarInt($this->duration);
} }
} }

View File

@ -31,20 +31,23 @@ class MobEquipmentPacket extends DataPacket{
public $item; public $item;
public $slot; public $slot;
public $selectedSlot; public $selectedSlot;
public $unknownByte;
public function decode(){ public function decode(){
$this->eid = $this->getLong(); $this->eid = $this->getEntityId(); //EntityRuntimeID
$this->item = $this->getSlot(); $this->item = $this->getSlot();
$this->slot = $this->getByte(); $this->slot = $this->getByte();
$this->selectedSlot = $this->getByte(); $this->selectedSlot = $this->getByte();
$this->unknownByte = $this->getByte();
} }
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putLong($this->eid); $this->putEntityId($this->eid); //EntityRuntimeID
$this->putSlot($this->item); $this->putSlot($this->item);
$this->putByte($this->slot); $this->putByte($this->slot);
$this->putByte($this->selectedSlot); $this->putByte($this->selectedSlot);
$this->putByte($this->unknownByte);
} }
} }

View File

@ -36,10 +36,8 @@ class MoveEntityPacket extends DataPacket{
public $pitch; public $pitch;
public function decode(){ public function decode(){
$this->eid = $this->getLong(); $this->eid = $this->getEntityId();
$this->x = $this->getFloat(); $this->getVector3f($this->x, $this->y, $this->z);
$this->y = $this->getFloat();
$this->z = $this->getFloat();
$this->pitch = $this->getByte() * (360.0 / 256); $this->pitch = $this->getByte() * (360.0 / 256);
$this->yaw = $this->getByte() * (360.0 / 256); $this->yaw = $this->getByte() * (360.0 / 256);
$this->headYaw = $this->getByte() * (360.0 / 256); $this->headYaw = $this->getByte() * (360.0 / 256);
@ -47,10 +45,8 @@ class MoveEntityPacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putLong($this->eid); $this->putEntityId($this->eid);
$this->putFloat($this->x); $this->putVector3f($this->x, $this->y, $this->z);
$this->putFloat($this->y);
$this->putFloat($this->z);
$this->putByte($this->pitch / (360.0 / 256)); $this->putByte($this->pitch / (360.0 / 256));
$this->putByte($this->yaw / (360.0 / 256)); $this->putByte($this->yaw / (360.0 / 256));
$this->putByte($this->headYaw / (360.0 / 256)); $this->putByte($this->headYaw / (360.0 / 256));

View File

@ -40,7 +40,7 @@ class PlayerActionPacket extends DataPacket{
const ACTION_STOP_SPRINT = 10; const ACTION_STOP_SPRINT = 10;
const ACTION_START_SNEAK = 11; const ACTION_START_SNEAK = 11;
const ACTION_STOP_SNEAK = 12; const ACTION_STOP_SNEAK = 12;
const ACTION_DIMENSION_CHANGE = 13; const ACTION_DIMENSION_CHANGE = 13; //TODO: correct these
public $eid; public $eid;
public $action; public $action;
@ -50,22 +50,18 @@ class PlayerActionPacket extends DataPacket{
public $face; public $face;
public function decode(){ public function decode(){
$this->eid = $this->getLong(); $this->eid = $this->getEntityId();
$this->action = $this->getInt(); $this->action = $this->getVarInt();
$this->x = $this->getInt(); $this->getBlockCoords($this->x, $this->y, $this->z);
$this->y = $this->getInt(); $this->face = $this->getVarInt();
$this->z = $this->getInt();
$this->face = $this->getInt();
} }
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putLong($this->eid); $this->putEntityId($this->eid);
$this->putInt($this->action); $this->putVarInt($this->action);
$this->putInt($this->x); $this->putBlockCoords($this->x, $this->y, $this->z);
$this->putInt($this->y); $this->putVarInt($this->face);
$this->putInt($this->z);
$this->putInt($this->face);
} }
} }

View File

@ -0,0 +1,46 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\network\protocol;
#include <rules/DataPacket.h>
class PlayerInputPacket extends DataPacket{
const NETWORK_ID = Info::PLAYER_INPUT_PACKET;
public $motionX;
public $motionY;
public $unknownBool1;
public $unknownBool2;
public function decode(){
$this->motionX = $this->getLFloat();
$this->motionY = $this->getLFloat();
$this->unknownBool1 = $this->getByte();
$this->unknownBool2 = $this->getByte();
}
public function encode(){
}
}

View File

@ -30,7 +30,7 @@ class PlayerListPacket extends DataPacket{
const TYPE_ADD = 0; const TYPE_ADD = 0;
const TYPE_REMOVE = 1; const TYPE_REMOVE = 1;
//REMOVE: UUID, ADD: UUID, entity id, name, isSlim, skin //REMOVE: UUID, ADD: UUID, entity id, name, skinId, skin
/** @var array[] */ /** @var array[] */
public $entries = []; public $entries = [];
public $type; public $type;
@ -51,7 +51,7 @@ class PlayerListPacket extends DataPacket{
foreach($this->entries as $d){ foreach($this->entries as $d){
if($this->type === self::TYPE_ADD){ if($this->type === self::TYPE_ADD){
$this->putUUID($d[0]); $this->putUUID($d[0]);
$this->putLong($d[1]); $this->putEntityId($d[1]);
$this->putString($d[2]); $this->putString($d[2]);
$this->putString($d[3]); $this->putString($d[3]);
$this->putString($d[4]); $this->putString($d[4]);

View File

@ -27,16 +27,12 @@ namespace pocketmine\network\protocol;
class RemoveBlockPacket extends DataPacket{ class RemoveBlockPacket extends DataPacket{
const NETWORK_ID = Info::REMOVE_BLOCK_PACKET; const NETWORK_ID = Info::REMOVE_BLOCK_PACKET;
public $eid;
public $x; public $x;
public $y; public $y;
public $z; public $z;
public function decode(){ public function decode(){
$this->eid = $this->getLong(); $this->getBlockCoords($this->x, $this->y, $this->z);
$this->x = $this->getInt();
$this->z = $this->getInt();
$this->y = $this->getByte();
} }
public function encode(){ public function encode(){

View File

@ -35,7 +35,7 @@ class RemoveEntityPacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putLong($this->eid); $this->putEntityId($this->eid);
} }
} }

View File

@ -0,0 +1,41 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\network\protocol;
#include <rules/DataPacket.h>
class ReplaceSelectedItemPacket extends DataPacket{
const NETWORK_ID = Info::REPLACE_SELECTED_ITEM_PACKET;
public $item;
public function decode(){
}
public function encode(){
$this->reset();
$this->putSlot($this->item);
}
}

View File

@ -32,16 +32,16 @@ class RespawnPacket extends DataPacket{
public $z; public $z;
public function decode(){ public function decode(){
$this->x = $this->getFloat(); $this->x = $this->getLFloat();
$this->y = $this->getFloat(); $this->y = $this->getLFloat();
$this->z = $this->getFloat(); $this->z = $this->getLFloat();
} }
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putFloat($this->x); $this->putLFloat($this->x);
$this->putFloat($this->y); $this->putLFloat($this->y);
$this->putFloat($this->z); $this->putLFloat($this->z);
} }
} }

View File

@ -0,0 +1,41 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\network\protocol;
#include <rules/DataPacket.h>
class SetCommandsEnabledPacket extends DataPacket{
const NETWORK_ID = Info::SET_COMMANDS_ENABLED_PACKET;
public $enabled;
public function decode(){
}
public function encode(){
$this->reset();
$this->putByte($this->enabled);
}
}

View File

@ -35,7 +35,7 @@ class SetDifficultyPacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putInt($this->difficulty); $this->putUnsignedVarInt($this->difficulty);
} }
} }

View File

@ -40,7 +40,7 @@ class SetEntityDataPacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putLong($this->eid); $this->putEntityId($this->eid);
$meta = Binary::writeMetadata($this->metadata); $meta = Binary::writeMetadata($this->metadata);
$this->put($meta); $this->put($meta);
} }

View File

@ -37,8 +37,8 @@ class SetEntityLinkPacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putLong($this->from); $this->putEntityId($this->from);
$this->putLong($this->to); $this->putEntityId($this->to);
$this->putByte($this->type); $this->putByte($this->type);
} }

View File

@ -27,10 +27,10 @@ namespace pocketmine\network\protocol;
class SetEntityMotionPacket extends DataPacket{ class SetEntityMotionPacket extends DataPacket{
const NETWORK_ID = Info::SET_ENTITY_MOTION_PACKET; const NETWORK_ID = Info::SET_ENTITY_MOTION_PACKET;
public $eid;
// eid, motX, motY, motZ public $motionX;
/** @var array[] */ public $motionY;
public $entities = []; public $motionZ;
public function clean(){ public function clean(){
$this->entities = []; $this->entities = [];
@ -43,13 +43,8 @@ class SetEntityMotionPacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putInt(count($this->entities)); $this->putEntityId($this->eid);
foreach($this->entities as $d){ $this->putVector3f($this->motionX, $this->motionY, $this->motionZ);
$this->putLong($d[0]); //eid
$this->putFloat($d[1]); //motX
$this->putFloat($d[2]); //motY
$this->putFloat($d[3]); //motZ
}
} }
} }

View File

@ -35,7 +35,7 @@ class SetHealthPacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putInt($this->health); $this->putVarInt($this->health);
} }
} }

View File

@ -35,7 +35,7 @@ class SetPlayerGameTypePacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putInt($this->gamemode); $this->putVarInt($this->gamemode);
} }
} }

View File

@ -27,6 +27,7 @@ namespace pocketmine\network\protocol;
class SetSpawnPositionPacket extends DataPacket{ class SetSpawnPositionPacket extends DataPacket{
const NETWORK_ID = Info::SET_SPAWN_POSITION_PACKET; const NETWORK_ID = Info::SET_SPAWN_POSITION_PACKET;
public $unknown;
public $x; public $x;
public $y; public $y;
public $z; public $z;
@ -37,9 +38,8 @@ class SetSpawnPositionPacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putInt($this->x); $this->putVarInt($this->unknown);
$this->putInt($this->y); $this->putBlockCoords($this->x, $this->y, $this->z);
$this->putInt($this->z);
} }
} }

View File

@ -35,8 +35,8 @@ class SetTimePacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putInt($this->time); $this->putVarInt($this->time);
$this->putByte($this->started ? 1 : 0); $this->putByte((int) $this->started);
} }
} }

View File

@ -0,0 +1,44 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\network\protocol;
#include <rules/DataPacket.h>
class SpawnExperienceOrbPacket extends DataPacket{
const NETWORK_ID = Info::SPAWN_EXPERIENCE_ORB_PACKET;
public $x;
public $y;
public $z;
public $amount;
public function decode(){
}
public function encode(){
$this->reset();
$this->putVector3f($this->x, $this->y, $this->z);
$this->putVarInt($this->amount);
}
}

View File

@ -36,8 +36,8 @@ class TakeItemEntityPacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putLong($this->target); $this->putEntityId($this->target);
$this->putLong($this->eid); $this->putEntityId($this->eid);
} }
} }

View File

@ -40,15 +40,13 @@ class UpdateAttributesPacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putEntityId($this->entityId);
$this->putLong($this->entityId); $this->putUnsignedVarInt(count($this->entries));
$this->putShort(count($this->entries));
foreach($this->entries as $entry){ foreach($this->entries as $entry){
$this->putFloat($entry->getMinValue()); $this->putLFloat($entry->getMinValue());
$this->putFloat($entry->getMaxValue()); $this->putLFloat($entry->getMaxValue());
$this->putFloat($entry->getValue()); $this->putLFloat($entry->getValue());
$this->putLFloat($entry->getDefaultValue());
$this->putString($entry->getName()); $this->putString($entry->getName());
} }
} }

View File

@ -49,11 +49,9 @@ class UpdateBlockPacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putInt($this->x); $this->putBlockCoords($this->x, $this->y, $this->z);
$this->putInt($this->z); $this->putUnsignedVarInt($this->blockId);
$this->putByte($this->y); $this->putUnsignedVarInt(($this->flags << 4) | $this->blockData);
$this->putByte($this->blockId);
$this->putByte(($this->flags << 4) | $this->blockData);
} }
} }

View File

@ -41,18 +41,11 @@ class UseItemPacket extends DataPacket{
public $slot; public $slot;
public function decode(){ public function decode(){
$this->x = $this->getInt(); $this->getBlockCoords($this->x, $this->y, $this->z);
$this->y = $this->getInt(); $this->face = $this->getVarInt();
$this->z = $this->getInt(); $this->getVector3f($this->fx, $this->fy, $this->fz);
$this->face = $this->getByte(); $this->getVector3f($this->posX, $this->posY, $this->posZ);
$this->fx = $this->getFloat(); $this->slot = $this->getVarInt();
$this->fy = $this->getFloat();
$this->fz = $this->getFloat();
$this->posX = $this->getFloat();
$this->posY = $this->getFloat();
$this->posZ = $this->getFloat();
$this->slot = $this->getInt();
$this->item = $this->getSlot(); $this->item = $this->getSlot();
} }