Updated protocol packet ids

This commit is contained in:
Shoghi Cervantes 2015-08-03 10:53:23 +02:00
parent 5621ab0c49
commit 1b812d373c
6 changed files with 74 additions and 82 deletions

View File

@ -355,10 +355,10 @@ namespace pocketmine {
$args = $trace[$i]["params"]; $args = $trace[$i]["params"];
} }
foreach($args as $name => $value){ foreach($args as $name => $value){
$params .= (is_object($value) ? get_class($value) . " " . (method_exists($value, "__toString") ? $value->__toString() : "object") : gettype($value) . " " . (is_array($value) ? "Array()" : @strval($value))) . ", "; $params .= (is_object($value) ? get_class($value) . " " . (method_exists($value, "__toString") ? $value->__toString() : "object") : gettype($value) . " " . (is_array($value) ? "Array()" : Utils::printable(@strval($value)))) . ", ";
} }
} }
$messages[] = "#$j " . (isset($trace[$i]["file"]) ? cleanPath($trace[$i]["file"]) : "") . "(" . (isset($trace[$i]["line"]) ? $trace[$i]["line"] : "") . "): " . (isset($trace[$i]["class"]) ? $trace[$i]["class"] . (($trace[$i]["type"] === "dynamic" or $trace[$i]["type"] === "->") ? "->" : "::") : "") . $trace[$i]["function"] . "(" . substr($params, 0, -2) . ")"; $messages[] = "#$j " . (isset($trace[$i]["file"]) ? cleanPath($trace[$i]["file"]) : "") . "(" . (isset($trace[$i]["line"]) ? $trace[$i]["line"] : "") . "): " . (isset($trace[$i]["class"]) ? $trace[$i]["class"] . (($trace[$i]["type"] === "dynamic" or $trace[$i]["type"] === "->") ? "->" : "::") : "") . $trace[$i]["function"] . "(" . Utils::printable(substr($params, 0, -2)) . ")";
} }
return $messages; return $messages;

View File

@ -2334,7 +2334,7 @@ class Server{
public function addOnlinePlayer(Player $player){ public function addOnlinePlayer(Player $player){
$this->playerList[$player->getRawUniqueId()] = $player; $this->playerList[$player->getRawUniqueId()] = $player;
$this->updatePlayerListData($player->getUniqueId(), $player->getUniqueId(), $player->getDisplayName(), $player->isSkinSlim(), $player->getSkinData()); $this->updatePlayerListData($player->getUniqueId(), $player->getId(), $player->getDisplayName(), $player->isSkinSlim(), $player->getSkinData());
} }
public function removeOnlinePlayer(Player $player){ public function removeOnlinePlayer(Player $player){
@ -2366,7 +2366,7 @@ class Server{
$pk = new PlayerListPacket(); $pk = new PlayerListPacket();
$pk->type = PlayerListPacket::TYPE_ADD; $pk->type = PlayerListPacket::TYPE_ADD;
foreach($this->playerList as $player){ foreach($this->playerList as $player){
$pk->entries[] = [$player->getUniqueId(), $player->getUniqueId(), $player->getDisplayName(), $player->isSkinSlim(), $player->getSkinData()]; $pk->entries[] = [$player->getUniqueId(), $player->getId(), $player->getDisplayName(), $player->isSkinSlim(), $player->getSkinData()];
} }
$p->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); $p->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));

View File

@ -128,8 +128,7 @@ class PlayerInventory extends BaseInventory{
$pk = new MobEquipmentPacket(); $pk = new MobEquipmentPacket();
$pk->eid = ($target === $this->getHolder() ? 0 : $this->getHolder()->getId()); $pk->eid = ($target === $this->getHolder() ? 0 : $this->getHolder()->getId());
$pk->item = $item->getId(); $pk->item = $item;
$pk->meta = $item->getDamage();
$pk->slot = $this->getHeldItemSlot(); $pk->slot = $this->getHeldItemSlot();
$pk->selectedSlot = $this->getHeldItemIndex(); $pk->selectedSlot = $this->getHeldItemIndex();
@ -304,20 +303,12 @@ class PlayerInventory extends BaseInventory{
if($target instanceof Player){ if($target instanceof Player){
$target = [$target]; $target = [$target];
} }
$armor = $this->getArmorContents();
$slots = [];
foreach($armor as $i => $slot){ $armor = $this->getArmorContents();
if($slot->getId() === Item::AIR){
$slots[$i] = 255;
}else{
$slots[$i] = $slot->getId();
}
}
$pk = new MobArmorEquipmentPacket(); $pk = new MobArmorEquipmentPacket();
$pk->eid = $this->getHolder()->getId(); $pk->eid = $this->getHolder()->getId();
$pk->slots = $slots; $pk->slots = $armor;
$pk->encode(); $pk->encode();
$pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING); $pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING);
$pk->isEncoded = true; $pk->isEncoded = true;
@ -362,19 +353,10 @@ class PlayerInventory extends BaseInventory{
} }
$armor = $this->getArmorContents(); $armor = $this->getArmorContents();
$slots = [];
foreach($armor as $i => $slot){
if($slot->getId() === Item::AIR){
$slots[$i] = 255;
}else{
$slots[$i] = $slot->getId();
}
}
$pk = new MobArmorEquipmentPacket(); $pk = new MobArmorEquipmentPacket();
$pk->eid = $this->getHolder()->getId(); $pk->eid = $this->getHolder()->getId();
$pk->slots = $slots; $pk->slots = $armor;
$pk->encode(); $pk->encode();
$pk->isEncoded = true; $pk->isEncoded = true;

View File

@ -112,11 +112,12 @@ class CraftingDataPacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putByte($this->type);
$this->putInt(count($this->entries)); $this->putInt(count($this->entries));
foreach($this->entries as $d){ foreach($this->entries as $d){
$this->writeEntry($d);
} }
$this->putByte($this->cleanRecipes ? 1 : 0);
} }
} }

View File

@ -232,4 +232,8 @@ abstract class DataPacket extends \stdClass{
$this->offset = 0; $this->offset = 0;
return $this; return $this;
} }
public function __debugInfo(){
return bin2hex($this->buffer);
}
} }

View File

@ -32,60 +32,60 @@ interface Info{
*/ */
const CURRENT_PROTOCOL = 30; const CURRENT_PROTOCOL = 30;
const LOGIN_PACKET = 0x82; const LOGIN_PACKET = 0x87;
const PLAY_STATUS_PACKET = 0x83; const PLAY_STATUS_PACKET = 0x88;
const DISCONNECT_PACKET = 0x84; const DISCONNECT_PACKET = 0x89;
const BATCH_PACKET = 0x85; const BATCH_PACKET = 0x8a;
const TEXT_PACKET = 0x86; const TEXT_PACKET = 0x8b;
const SET_TIME_PACKET = 0x87; const SET_TIME_PACKET = 0x8c;
const START_GAME_PACKET = 0x88; const START_GAME_PACKET = 0x8d;
const ADD_PLAYER_PACKET = 0x89; const ADD_PLAYER_PACKET = 0x8e;
const REMOVE_PLAYER_PACKET = 0x8a; const REMOVE_PLAYER_PACKET = 0x8f;
const ADD_ENTITY_PACKET = 0x8b; const ADD_ENTITY_PACKET = 0x90;
const REMOVE_ENTITY_PACKET = 0x8c; const REMOVE_ENTITY_PACKET = 0x91;
const ADD_ITEM_ENTITY_PACKET = 0x8d; const ADD_ITEM_ENTITY_PACKET = 0x92;
const TAKE_ITEM_ENTITY_PACKET = 0x8e; const TAKE_ITEM_ENTITY_PACKET = 0x93;
const MOVE_ENTITY_PACKET = 0x8f; const MOVE_ENTITY_PACKET = 0x94;
const MOVE_PLAYER_PACKET = 0x90; const MOVE_PLAYER_PACKET = 0x95;
const REMOVE_BLOCK_PACKET = 0x91; const REMOVE_BLOCK_PACKET = 0x96;
const UPDATE_BLOCK_PACKET = 0x92; const UPDATE_BLOCK_PACKET = 0x97;
const ADD_PAINTING_PACKET = 0x93; const ADD_PAINTING_PACKET = 0x98;
const EXPLODE_PACKET = 0x94; const EXPLODE_PACKET = 0x99;
const LEVEL_EVENT_PACKET = 0x95; const LEVEL_EVENT_PACKET = 0x9a;
const TILE_EVENT_PACKET = 0x96; const TILE_EVENT_PACKET = 0x9b;
const ENTITY_EVENT_PACKET = 0x97; const ENTITY_EVENT_PACKET = 0x9c;
const MOB_EFFECT_PACKET = 0x98; const MOB_EFFECT_PACKET = 0x9d;
const UPDATE_ATTRIBUTES_PACKET = 0x99; const UPDATE_ATTRIBUTES_PACKET = 0x9e;
const MOB_EQUIPMENT_PACKET = 0x9a; const MOB_EQUIPMENT_PACKET = 0x9f;
const MOB_ARMOR_EQUIPMENT_PACKET = 0x9b; const MOB_ARMOR_EQUIPMENT_PACKET = 0xa0;
const INTERACT_PACKET = 0x9c; const INTERACT_PACKET = 0xa1;
const USE_ITEM_PACKET = 0x9d; const USE_ITEM_PACKET = 0xa2;
const PLAYER_ACTION_PACKET = 0x9e; const PLAYER_ACTION_PACKET = 0xa3;
const HURT_ARMOR_PACKET = 0x9f; const HURT_ARMOR_PACKET = 0xa4;
const SET_ENTITY_DATA_PACKET = 0xa0; const SET_ENTITY_DATA_PACKET = 0xa5;
const SET_ENTITY_MOTION_PACKET = 0xa1; const SET_ENTITY_MOTION_PACKET = 0xa6;
const SET_ENTITY_LINK_PACKET = 0xa2; const SET_ENTITY_LINK_PACKET = 0xa7;
const SET_HEALTH_PACKET = 0xa3; const SET_HEALTH_PACKET = 0xa8;
const SET_SPAWN_POSITION_PACKET = 0xa4; const SET_SPAWN_POSITION_PACKET = 0xa9;
const ANIMATE_PACKET = 0xa5; const ANIMATE_PACKET = 0xaa;
const RESPAWN_PACKET = 0xa6; const RESPAWN_PACKET = 0xab;
const DROP_ITEM_PACKET = 0xa7; const DROP_ITEM_PACKET = 0xac;
const CONTAINER_OPEN_PACKET = 0xa8; const CONTAINER_OPEN_PACKET = 0xad;
const CONTAINER_CLOSE_PACKET = 0xa9; const CONTAINER_CLOSE_PACKET = 0xae;
const CONTAINER_SET_SLOT_PACKET = 0xaa; const CONTAINER_SET_SLOT_PACKET = 0xaf;
const CONTAINER_SET_DATA_PACKET = 0xab; const CONTAINER_SET_DATA_PACKET = 0xb0;
const CONTAINER_SET_CONTENT_PACKET = 0xac; const CONTAINER_SET_CONTENT_PACKET = 0xb1;
const CRAFTING_DATA_PACKET = 0xad; const CRAFTING_DATA_PACKET = 0xb2;
const CRAFTING_EVENT_PACKET = 0xae; const CRAFTING_EVENT_PACKET = 0xb3;
const ADVENTURE_SETTINGS_PACKET = 0xaf; const ADVENTURE_SETTINGS_PACKET = 0xb4;
const TILE_ENTITY_DATA_PACKET = 0xb0; const TILE_ENTITY_DATA_PACKET = 0xb5;
//const PLAYER_INPUT_PACKET = 0xb1; //const PLAYER_INPUT_PACKET = 0xb6;
const FULL_CHUNK_DATA_PACKET = 0xb2; const FULL_CHUNK_DATA_PACKET = 0xb7;
const SET_DIFFICULTY_PACKET = 0xb3; const SET_DIFFICULTY_PACKET = 0xb8;
//const CHANGE_DIMENSION_PACKET = 0xb4; //const CHANGE_DIMENSION_PACKET = 0xb9;
//const SET_PLAYER_GAMETYPE_PACKET = 0xb5; //const SET_PLAYER_GAMETYPE_PACKET = 0xba;
const PLAYER_LIST_PACKET = 0xb6; const PLAYER_LIST_PACKET = 0xbb;
//const TELEMETRY_EVENT_PACKET = 0xb7; //const TELEMETRY_EVENT_PACKET = 0xbc;
} }
@ -93,3 +93,8 @@ interface Info{