More packets changed, unique IDs D:

This commit is contained in:
Shoghi Cervantes 2015-02-11 12:36:01 +01:00
parent eeeaac04e9
commit 218fd999b0
25 changed files with 65 additions and 137 deletions

View File

@ -61,7 +61,6 @@ use pocketmine\network\protocol\RemoveEntityPacket;
use pocketmine\network\protocol\RemovePlayerPacket;
use pocketmine\network\protocol\RespawnPacket;
use pocketmine\network\protocol\RotateHeadPacket;
use pocketmine\network\protocol\SendInventoryPacket;
use pocketmine\network\protocol\SetDifficultyPacket;
use pocketmine\network\protocol\SetEntityDataPacket;
use pocketmine\network\protocol\SetEntityMotionPacket;
@ -306,9 +305,9 @@ class RakLibInterface implements ServerInstance, SourceInterface{
private function registerPackets(){
$this->packetPool = new \SplFixedArray(256);
$this->registerPacket(ProtocolInfo::DISCONNECT_PACKET, DisconnectPacket::class);
$this->registerPacket(ProtocolInfo::LOGIN_PACKET, LoginPacket::class);
$this->registerPacket(ProtocolInfo::LOGIN_STATUS_PACKET, LoginStatusPacket::class);
$this->registerPacket(ProtocolInfo::DISCONNECT_PACKET, DisconnectPacket::class);
$this->registerPacket(ProtocolInfo::MESSAGE_PACKET, MessagePacket::class);
$this->registerPacket(ProtocolInfo::SET_TIME_PACKET, SetTimePacket::class);
$this->registerPacket(ProtocolInfo::START_GAME_PACKET, StartGamePacket::class);
@ -341,7 +340,6 @@ class RakLibInterface implements ServerInstance, SourceInterface{
$this->registerPacket(ProtocolInfo::SET_SPAWN_POSITION_PACKET, SetSpawnPositionPacket::class);
$this->registerPacket(ProtocolInfo::ANIMATE_PACKET, AnimatePacket::class);
$this->registerPacket(ProtocolInfo::RESPAWN_PACKET, RespawnPacket::class);
$this->registerPacket(ProtocolInfo::SEND_INVENTORY_PACKET, SendInventoryPacket::class);
$this->registerPacket(ProtocolInfo::DROP_ITEM_PACKET, DropItemPacket::class);
$this->registerPacket(ProtocolInfo::CONTAINER_OPEN_PACKET, ContainerOpenPacket::class);
$this->registerPacket(ProtocolInfo::CONTAINER_CLOSE_PACKET, ContainerClosePacket::class);

View File

@ -48,12 +48,12 @@ class AddEntityPacket extends DataPacket{
public function encode(){
$this->reset();
$this->putInt($this->eid);
$this->putLong($this->eid);
$this->putInt($this->type);
$this->putFloat($this->x);
$this->putFloat($this->y);
$this->putFloat($this->z);
$this->putInt($this->did);
$this->putLong($this->did);
if($this->did > 0){
$this->putShort($this->speedX * 8000);
$this->putShort($this->speedY * 8000);

View File

@ -47,7 +47,7 @@ class AddItemEntityPacket extends DataPacket{
public function encode(){
$this->reset();
$this->putInt($this->eid);
$this->putLong($this->eid);
$this->putSlot($this->item);
$this->putFloat($this->x);
$this->putFloat($this->y);

View File

@ -51,7 +51,7 @@ class AddMobPacket extends DataPacket{
public function encode(){
$this->reset();
$this->putInt($this->eid);
$this->putLong($this->eid);
$this->putInt($this->type);
$this->putInt($this->x);
$this->putInt($this->y);

View File

@ -45,7 +45,7 @@ class AddPaintingPacket extends DataPacket{
public function encode(){
$this->reset();
$this->putInt($this->eid);
$this->putLevel($this->eid);
$this->putInt($this->x);
$this->putInt($this->y);
$this->putInt($this->z);

View File

@ -56,7 +56,7 @@ class AddPlayerPacket extends DataPacket{
$this->reset();
$this->putLong($this->clientID);
$this->putString($this->username);
$this->putInt($this->eid);
$this->putLong($this->eid);
$this->putFloat($this->x);
$this->putFloat($this->y);
$this->putFloat($this->z);

View File

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

View File

@ -36,13 +36,13 @@ class EntityEventPacket extends DataPacket{
}
public function decode(){
$this->eid = $this->getInt();
$this->eid = $this->getLong();
$this->event = $this->getByte();
}
public function encode(){
$this->reset();
$this->putInt($this->eid);
$this->putLong($this->eid);
$this->putByte($this->event);
}

View File

@ -80,19 +80,18 @@ interface Info{
const SET_SPAWN_POSITION_PACKET = 0xa4;
const ANIMATE_PACKET = 0xa5;
const RESPAWN_PACKET = 0xa6;
const SEND_INVENTORY_PACKET = 0xa7;
const DROP_ITEM_PACKET = 0xa8;
const CONTAINER_OPEN_PACKET = 0xa9;
const CONTAINER_CLOSE_PACKET = 0xaa;
const CONTAINER_SET_SLOT_PACKET = 0xab;
const CONTAINER_SET_DATA_PACKET = 0xac;
const CONTAINER_SET_CONTENT_PACKET = 0xad;
//const CONTAINER_ACK_PACKET = 0xae;
const CHAT_PACKET = 0xaf;
const ADVENTURE_SETTINGS_PACKET = 0xb0;
const ENTITY_DATA_PACKET = 0xb1;
//const PLAYER_INPUT_PACKET = 0xb2;
const FULL_CHUNK_DATA_PACKET = 0xb3;
const SET_DIFFICULTY_PACKET = 0xb4;
const DROP_ITEM_PACKET = 0xa7;
const CONTAINER_OPEN_PACKET = 0xa8;
const CONTAINER_CLOSE_PACKET = 0xa9;
const CONTAINER_SET_SLOT_PACKET = 0xaa;
const CONTAINER_SET_DATA_PACKET = 0xab;
const CONTAINER_SET_CONTENT_PACKET = 0xac;
//const CONTAINER_ACK_PACKET = 0xad;
const CHAT_PACKET = 0xae;
const ADVENTURE_SETTINGS_PACKET = 0xaf;
const ENTITY_DATA_PACKET = 0xb0;
//const PLAYER_INPUT_PACKET = 0xb1;
const FULL_CHUNK_DATA_PACKET = 0xb2;
const SET_DIFFICULTY_PACKET = 0xb3;
}

View File

@ -45,8 +45,8 @@ class InteractPacket extends DataPacket{
public function encode(){
$this->reset();
$this->putByte($this->action);
$this->putInt($this->eid);
$this->putInt($this->target);
$this->putLong($this->eid);
$this->putLong($this->target);
}
}

View File

@ -50,7 +50,7 @@ class MoveEntityPacket extends DataPacket{
$this->reset();
$this->putInt(count($this->entities));
foreach($this->entities as $d){
$this->putInt($d[0]); //eid
$this->putLong($d[0]); //eid
$this->putFloat($d[1]); //x
$this->putFloat($d[2]); //y
$this->putFloat($d[3]); //z

View File

@ -47,7 +47,7 @@ class MovePlayerPacket extends DataPacket{
}
public function decode(){
$this->eid = $this->getInt();
$this->eid = $this->getLong();
$this->x = $this->getFloat();
$this->y = $this->getFloat();
$this->z = $this->getFloat();
@ -60,7 +60,7 @@ class MovePlayerPacket extends DataPacket{
public function encode(){
$this->reset();
$this->putInt($this->eid);
$this->putLong($this->eid);
$this->putFloat($this->x);
$this->putFloat($this->y);
$this->putFloat($this->z);

View File

@ -45,7 +45,7 @@ class PlayerActionPacket extends DataPacket{
$this->y = $this->getInt();
$this->z = $this->getInt();
$this->face = $this->getInt();
$this->eid = $this->getInt();
$this->eid = $this->getLong();
}
public function encode(){

View File

@ -36,7 +36,7 @@ class PlayerArmorEquipmentPacket extends DataPacket{
}
public function decode(){
$this->eid = $this->getInt();
$this->eid = $this->getLong();
$this->slots[0] = $this->getByte();
$this->slots[1] = $this->getByte();
$this->slots[2] = $this->getByte();
@ -45,7 +45,7 @@ class PlayerArmorEquipmentPacket extends DataPacket{
public function encode(){
$this->reset();
$this->putInt($this->eid);
$this->putLong($this->eid);
$this->putByte($this->slots[0]);
$this->putByte($this->slots[1]);
$this->putByte($this->slots[2]);

View File

@ -38,7 +38,7 @@ class PlayerEquipmentPacket extends DataPacket{
}
public function decode(){
$this->eid = $this->getInt();
$this->eid = $this->getLong();
$this->item = $this->getShort();
$this->meta = $this->getShort();
$this->slot = $this->getByte();
@ -46,7 +46,7 @@ class PlayerEquipmentPacket extends DataPacket{
public function encode(){
$this->reset();
$this->putInt($this->eid);
$this->putLong($this->eid);
$this->putShort($this->item);
$this->putShort($this->meta);
$this->putByte($this->slot);

View File

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

View File

@ -41,7 +41,7 @@ class RemovePlayerPacket extends DataPacket{
public function encode(){
$this->reset();
$this->putInt($this->eid);
$this->putLong($this->eid);
$this->putLong($this->clientID);
}

View File

@ -38,7 +38,7 @@ class RespawnPacket extends DataPacket{
}
public function decode(){
$this->eid = $this->getInt();
$this->eid = $this->getLong();
$this->x = $this->getFloat();
$this->y = $this->getFloat();
$this->z = $this->getFloat();
@ -46,7 +46,7 @@ class RespawnPacket extends DataPacket{
public function encode(){
$this->reset();
$this->putInt($this->eid);
$this->putLong($this->eid);
$this->putFloat($this->x);
$this->putFloat($this->y);
$this->putFloat($this->z);

View File

@ -50,7 +50,7 @@ class RotateHeadPacket extends DataPacket{
$this->reset();
$this->putInt(count($this->entities));
foreach($this->entities as $d){
$this->putInt($d[0]); //eid
$this->putLong($d[0]); //eid
$this->putByte((int) ($d[1] / 360));
}
}

View File

@ -1,69 +0,0 @@
<?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 SendInventoryPacket extends DataPacket{
public static $pool = [];
public static $next = 0;
public $eid;
public $windowid;
public $slots = [];
public $armor = [];
public function pid(){
return Info::SEND_INVENTORY_PACKET;
}
public function decode(){
$this->eid = $this->getInt();
$this->windowid = $this->getByte();
$count = $this->getShort();
for($s = 0; $s < $count and !$this->feof(); ++$s){
$this->slots[$s] = $this->getSlot();
}
if($this->windowid === 1){ //Armor is sent
for($s = 0; $s < 4; ++$s){
$this->armor[$s] = $this->getSlot();
}
}
}
public function encode(){
$this->reset();
$this->putInt($this->eid);
$this->putByte($this->windowid);
$this->putShort(count($this->slots));
foreach($this->slots as $slot){
$this->putSlot($slot);
}
if($this->windowid === 1 and count($this->armor) === 4){
for($s = 0; $s < 4; ++$s){
$this->putSlot($this->armor[$s]);
}
}
}
}

View File

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

View File

@ -50,7 +50,7 @@ class SetEntityMotionPacket extends DataPacket{
$this->reset();
$this->putInt(count($this->entities));
foreach($this->entities as $d){
$this->putInt($d[0]); //eid
$this->putLong($d[0]); //eid
$this->putShort((int) ($d[1] * 8000)); //motX
$this->putShort((int) ($d[2] * 8000)); //motY
$this->putShort((int) ($d[3] * 8000)); //motZ

View File

@ -52,7 +52,7 @@ class StartGamePacket extends DataPacket{
$this->putInt($this->seed);
$this->putInt($this->generator);
$this->putInt($this->gamemode);
$this->putInt($this->eid);
$this->putLong($this->eid);
$this->putInt($this->spawnX);
$this->putInt($this->spawnY);
$this->putInt($this->spawnZ);

View File

@ -42,7 +42,7 @@ class TakeItemEntityPacket extends DataPacket{
public function encode(){
$this->reset();
$this->putInt($this->target);
$this->putInt($this->eid);
$this->putLong($this->eid);
}
}

View File

@ -53,7 +53,7 @@ class UseItemPacket extends DataPacket{
$this->face = $this->getByte();
$this->item = $this->getShort();
$this->meta = $this->getShort();
$this->eid = $this->getInt();
$this->eid = $this->getLong();
$this->fx = $this->getFloat();
$this->fy = $this->getFloat();
$this->fz = $this->getFloat();