Refactored entity IDs in packets for consistency and to clarify on types

This commit is contained in:
Dylan K. Taylor
2017-06-05 15:41:27 +01:00
parent 51d510aa4f
commit 54453d0b0a
21 changed files with 58 additions and 58 deletions

View File

@ -30,12 +30,12 @@ class AnimatePacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::ANIMATE_PACKET;
public $action;
public $eid;
public $entityRuntimeId;
public $float; //TODO (Boat rowing time?)
public function decode(){
$this->action = $this->getVarInt();
$this->eid = $this->getEntityRuntimeId();
$this->entityRuntimeId = $this->getEntityRuntimeId();
if($this->action & 0x80){
$this->float = $this->getLFloat();
}
@ -44,7 +44,7 @@ class AnimatePacket extends DataPacket{
public function encode(){
$this->reset();
$this->putVarInt($this->action);
$this->putEntityRuntimeId($this->eid);
$this->putEntityRuntimeId($this->entityRuntimeId);
if($this->action & 0x80){
$this->putLFloat($this->float);
}

View File

@ -48,19 +48,19 @@ class EntityEventPacket extends DataPacket{
//TODO: add more events
public $eid;
public $entityRuntimeId;
public $event;
public $data = 0;
public function decode(){
$this->eid = $this->getEntityRuntimeId();
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->event = $this->getByte();
$this->data = $this->getVarInt();
}
public function encode(){
$this->reset();
$this->putEntityRuntimeId($this->eid);
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putByte($this->event);
$this->putVarInt($this->data);
}

View File

@ -30,12 +30,12 @@ use pocketmine\network\mcpe\NetworkSession;
class MobArmorEquipmentPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::MOB_ARMOR_EQUIPMENT_PACKET;
public $eid;
public $entityRuntimeId;
/** @var Item[] */
public $slots = [];
public function decode(){
$this->eid = $this->getEntityRuntimeId();
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->slots[0] = $this->getSlot();
$this->slots[1] = $this->getSlot();
$this->slots[2] = $this->getSlot();
@ -44,7 +44,7 @@ class MobArmorEquipmentPacket extends DataPacket{
public function encode(){
$this->reset();
$this->putEntityRuntimeId($this->eid);
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putSlot($this->slots[0]);
$this->putSlot($this->slots[1]);
$this->putSlot($this->slots[2]);

View File

@ -33,7 +33,7 @@ class MobEffectPacket extends DataPacket{
const EVENT_MODIFY = 2;
const EVENT_REMOVE = 3;
public $eid;
public $entityRuntimeId;
public $eventId;
public $effectId;
public $amplifier = 0;
@ -41,7 +41,7 @@ class MobEffectPacket extends DataPacket{
public $duration = 0;
public function decode(){
$this->eid = $this->getEntityRuntimeId();
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->eventId = $this->getByte();
$this->effectId = $this->getVarInt();
$this->amplifier = $this->getVarInt();
@ -51,7 +51,7 @@ class MobEffectPacket extends DataPacket{
public function encode(){
$this->reset();
$this->putEntityRuntimeId($this->eid);
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putByte($this->eventId);
$this->putVarInt($this->effectId);
$this->putVarInt($this->amplifier);

View File

@ -29,14 +29,14 @@ use pocketmine\network\mcpe\NetworkSession;
class MobEquipmentPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::MOB_EQUIPMENT_PACKET;
public $eid;
public $entityRuntimeId;
public $item;
public $inventorySlot;
public $hotbarSlot;
public $unknownByte = 0;
public function decode(){
$this->eid = $this->getEntityRuntimeId();
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->item = $this->getSlot();
$this->inventorySlot = $this->getByte();
$this->hotbarSlot = $this->getByte();
@ -45,7 +45,7 @@ class MobEquipmentPacket extends DataPacket{
public function encode(){
$this->reset();
$this->putEntityRuntimeId($this->eid);
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putSlot($this->item);
$this->putByte($this->inventorySlot);
$this->putByte($this->hotbarSlot);

View File

@ -29,7 +29,7 @@ use pocketmine\network\mcpe\NetworkSession;
class MoveEntityPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::MOVE_ENTITY_PACKET;
public $eid;
public $entityRuntimeId;
public $x;
public $y;
public $z;
@ -40,7 +40,7 @@ class MoveEntityPacket extends DataPacket{
public $teleported;
public function decode(){
$this->eid = $this->getEntityRuntimeId();
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->getVector3f($this->x, $this->y, $this->z);
$this->pitch = $this->getByteRotation();
$this->headYaw = $this->getByteRotation();
@ -51,7 +51,7 @@ class MoveEntityPacket extends DataPacket{
public function encode(){
$this->reset();
$this->putEntityRuntimeId($this->eid);
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putVector3f($this->x, $this->y, $this->z);
$this->putByteRotation($this->pitch);
$this->putByteRotation($this->headYaw);

View File

@ -34,7 +34,7 @@ class MovePlayerPacket extends DataPacket{
const MODE_TELEPORT = 2;
const MODE_PITCH = 3; //facepalm Mojang
public $eid;
public $entityRuntimeId;
public $x;
public $y;
public $z;
@ -48,7 +48,7 @@ class MovePlayerPacket extends DataPacket{
public $int2 = 0;
public function decode(){
$this->eid = $this->getEntityRuntimeId();
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->getVector3f($this->x, $this->y, $this->z);
$this->pitch = $this->getLFloat();
$this->yaw = $this->getLFloat();
@ -64,7 +64,7 @@ class MovePlayerPacket extends DataPacket{
public function encode(){
$this->reset();
$this->putEntityRuntimeId($this->eid);
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putVector3f($this->x, $this->y, $this->z);
$this->putLFloat($this->pitch);
$this->putLFloat($this->yaw);

View File

@ -49,7 +49,7 @@ class PlayerActionPacket extends DataPacket{
const ACTION_CONTINUE_BREAK = 18;
public $eid;
public $entityRuntimeId;
public $action;
public $x;
public $y;
@ -57,7 +57,7 @@ class PlayerActionPacket extends DataPacket{
public $face;
public function decode(){
$this->eid = $this->getEntityRuntimeId();
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->action = $this->getVarInt();
$this->getBlockPosition($this->x, $this->y, $this->z);
$this->face = $this->getVarInt();
@ -65,7 +65,7 @@ class PlayerActionPacket extends DataPacket{
public function encode(){
$this->reset();
$this->putEntityRuntimeId($this->eid);
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putVarInt($this->action);
$this->putBlockPosition($this->x, $this->y, $this->z);
$this->putVarInt($this->face);

View File

@ -29,15 +29,15 @@ use pocketmine\network\mcpe\NetworkSession;
class RemoveEntityPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::REMOVE_ENTITY_PACKET;
public $eid;
public $entityUniqueId;
public function decode(){
$this->eid = $this->getEntityUniqueId();
$this->entityUniqueId = $this->getEntityUniqueId();
}
public function encode(){
$this->reset();
$this->putEntityUniqueId($this->eid);
$this->putEntityUniqueId($this->entityUniqueId);
}
public function handle(NetworkSession $session) : bool{

View File

@ -29,17 +29,17 @@ use pocketmine\network\mcpe\NetworkSession;
class SetEntityDataPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::SET_ENTITY_DATA_PACKET;
public $eid;
public $entityRuntimeId;
public $metadata;
public function decode(){
$this->eid = $this->getEntityRuntimeId();
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->metadata = $this->getEntityMetadata();
}
public function encode(){
$this->reset();
$this->putEntityRuntimeId($this->eid);
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putEntityMetadata($this->metadata);
}

View File

@ -29,19 +29,19 @@ use pocketmine\network\mcpe\NetworkSession;
class SetEntityMotionPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::SET_ENTITY_MOTION_PACKET;
public $eid;
public $entityRuntimeId;
public $motionX;
public $motionY;
public $motionZ;
public function decode(){
$this->eid = $this->getEntityRuntimeId();
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->getVector3f($this->motionX, $this->motionY, $this->motionZ);
}
public function encode(){
$this->reset();
$this->putEntityRuntimeId($this->eid);
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putVector3f($this->motionX, $this->motionY, $this->motionZ);
}

View File

@ -30,18 +30,18 @@ use pocketmine\network\mcpe\NetworkSession;
class UpdateAttributesPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::UPDATE_ATTRIBUTES_PACKET;
public $entityId;
public $entityRuntimeId;
/** @var Attribute[] */
public $entries = [];
public function decode(){
$this->entityId = $this->getEntityRuntimeId();
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->entries = $this->getAttributeList();
}
public function encode(){
$this->reset();
$this->putEntityRuntimeId($this->entityId);
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putAttributeList(...$this->entries);
}