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

@ -1195,7 +1195,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$this->level->sleepTicks = 0; $this->level->sleepTicks = 0;
$pk = new AnimatePacket(); $pk = new AnimatePacket();
$pk->eid = $this->id; $pk->entityRuntimeId = $this->id;
$pk->action = 3; //Wake up $pk->action = 3; //Wake up
$this->dataPacket($pk); $this->dataPacket($pk);
} }
@ -1638,7 +1638,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$entries = $sendAll ? $this->attributeMap->getAll() : $this->attributeMap->needSend(); $entries = $sendAll ? $this->attributeMap->getAll() : $this->attributeMap->needSend();
if(count($entries) > 0){ if(count($entries) > 0){
$pk = new UpdateAttributesPacket(); $pk = new UpdateAttributesPacket();
$pk->entityId = $this->id; $pk->entityRuntimeId = $this->id;
$pk->entries = $entries; $pk->entries = $entries;
$this->dataPacket($pk); $this->dataPacket($pk);
foreach($entries as $entry){ foreach($entries as $entry){
@ -2573,7 +2573,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
return true; return true;
} }
$packet->eid = $this->id; $packet->entityRuntimeId = $this->id;
$pos = new Vector3($packet->x, $packet->y, $packet->z); $pos = new Vector3($packet->x, $packet->y, $packet->z);
switch($packet->action){ switch($packet->action){
@ -2684,7 +2684,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
} }
$pk = new EntityEventPacket(); $pk = new EntityEventPacket();
$pk->eid = $this->getId(); $pk->entityRuntimeId = $this->getId();
$pk->event = EntityEventPacket::USE_ITEM; $pk->event = EntityEventPacket::USE_ITEM;
$this->dataPacket($pk); $this->dataPacket($pk);
$this->server->broadcastPacket($this->getViewers(), $pk); $this->server->broadcastPacket($this->getViewers(), $pk);
@ -2840,7 +2840,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
} }
$pk = new AnimatePacket(); $pk = new AnimatePacket();
$pk->eid = $this->getId(); $pk->entityRuntimeId = $this->getId();
$pk->action = $ev->getAnimationType(); $pk->action = $ev->getAnimationType();
$this->server->broadcastPacket($this->getViewers(), $pk); $this->server->broadcastPacket($this->getViewers(), $pk);
@ -3936,7 +3936,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
return; return;
}elseif($this->getLastDamageCause() === $source and $this->spawned){ }elseif($this->getLastDamageCause() === $source and $this->spawned){
$pk = new EntityEventPacket(); $pk = new EntityEventPacket();
$pk->eid = $this->id; $pk->entityRuntimeId = $this->id;
$pk->event = EntityEventPacket::HURT_ANIMATION; $pk->event = EntityEventPacket::HURT_ANIMATION;
$this->dataPacket($pk); $this->dataPacket($pk);
@ -3951,7 +3951,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$pitch = $pitch === null ? $this->pitch : $pitch; $pitch = $pitch === null ? $this->pitch : $pitch;
$pk = new MovePlayerPacket(); $pk = new MovePlayerPacket();
$pk->eid = $this->getId(); $pk->entityRuntimeId = $this->getId();
$pk->x = $pos->x; $pk->x = $pos->x;
$pk->y = $pos->y + $this->getEyeHeight(); $pk->y = $pos->y + $this->getEyeHeight();
$pk->z = $pos->z; $pk->z = $pos->z;

View File

@ -396,7 +396,7 @@ class Effect{
} }
if($entity instanceof Player){ if($entity instanceof Player){
$pk = new MobEffectPacket(); $pk = new MobEffectPacket();
$pk->eid = $entity->getId(); $pk->entityRuntimeId = $entity->getId();
$pk->effectId = $this->getId(); $pk->effectId = $this->getId();
$pk->amplifier = $this->getAmplifier(); $pk->amplifier = $this->getAmplifier();
$pk->particles = $this->isVisible(); $pk->particles = $this->isVisible();
@ -468,7 +468,7 @@ class Effect{
} }
if($entity instanceof Player){ if($entity instanceof Player){
$pk = new MobEffectPacket(); $pk = new MobEffectPacket();
$pk->eid = $entity->getId(); $pk->entityRuntimeId = $entity->getId();
$pk->eventId = MobEffectPacket::EVENT_REMOVE; $pk->eventId = MobEffectPacket::EVENT_REMOVE;
$pk->effectId = $this->getId(); $pk->effectId = $this->getId();

View File

@ -834,7 +834,7 @@ abstract class Entity extends Location implements Metadatable{
public function sendPotionEffects(Player $player){ public function sendPotionEffects(Player $player){
foreach($this->effects as $effect){ foreach($this->effects as $effect){
$pk = new MobEffectPacket(); $pk = new MobEffectPacket();
$pk->eid = $this->id; $pk->entityRuntimeId = $this->id;
$pk->effectId = $effect->getId(); $pk->effectId = $effect->getId();
$pk->amplifier = $effect->getAmplifier(); $pk->amplifier = $effect->getAmplifier();
$pk->particles = $effect->isVisible(); $pk->particles = $effect->isVisible();
@ -855,7 +855,7 @@ abstract class Entity extends Location implements Metadatable{
} }
$pk = new SetEntityDataPacket(); $pk = new SetEntityDataPacket();
$pk->eid = $this->getId(); $pk->entityRuntimeId = $this->getId();
$pk->metadata = $data === null ? $this->dataProperties : $data; $pk->metadata = $data === null ? $this->dataProperties : $data;
foreach($player as $p){ foreach($player as $p){
@ -878,7 +878,7 @@ abstract class Entity extends Location implements Metadatable{
if(isset($this->hasSpawned[$player->getLoaderId()])){ if(isset($this->hasSpawned[$player->getLoaderId()])){
if($send){ if($send){
$pk = new RemoveEntityPacket(); $pk = new RemoveEntityPacket();
$pk->eid = $this->id; $pk->entityUniqueId = $this->id;
$player->dataPacket($pk); $player->dataPacket($pk);
} }
unset($this->hasSpawned[$player->getLoaderId()]); unset($this->hasSpawned[$player->getLoaderId()]);

View File

@ -73,7 +73,7 @@ abstract class Living extends Entity implements Damageable{
$this->attributeMap->getAttribute(Attribute::HEALTH)->setValue($this->getHealth(), true); $this->attributeMap->getAttribute(Attribute::HEALTH)->setValue($this->getHealth(), true);
if($this->isAlive() and !$wasAlive){ if($this->isAlive() and !$wasAlive){
$pk = new EntityEventPacket(); $pk = new EntityEventPacket();
$pk->eid = $this->getId(); $pk->entityRuntimeId = $this->getId();
$pk->event = EntityEventPacket::RESPAWN; $pk->event = EntityEventPacket::RESPAWN;
$this->server->broadcastPacket($this->hasSpawned, $pk); $this->server->broadcastPacket($this->hasSpawned, $pk);
} }
@ -166,7 +166,7 @@ abstract class Living extends Entity implements Damageable{
} }
$pk = new EntityEventPacket(); $pk = new EntityEventPacket();
$pk->eid = $this->getId(); $pk->entityRuntimeId = $this->getId();
$pk->event = $this->getHealth() <= 0 ? EntityEventPacket::DEATH_ANIMATION : EntityEventPacket::HURT_ANIMATION; //Ouch! $pk->event = $this->getHealth() <= 0 ? EntityEventPacket::DEATH_ANIMATION : EntityEventPacket::HURT_ANIMATION; //Ouch!
$this->server->broadcastPacket($this->hasSpawned, $pk); $this->server->broadcastPacket($this->hasSpawned, $pk);

View File

@ -65,7 +65,7 @@ class Squid extends WaterAnimal implements Ageable{
} }
$pk = new EntityEventPacket(); $pk = new EntityEventPacket();
$pk->eid = $this->getId(); $pk->entityRuntimeId = $this->getId();
$pk->event = EntityEventPacket::SQUID_INK_CLOUD; $pk->event = EntityEventPacket::SQUID_INK_CLOUD;
$this->server->broadcastPacket($this->hasSpawned, $pk); $this->server->broadcastPacket($this->hasSpawned, $pk);
} }

View File

@ -232,7 +232,7 @@ class PlayerInventory extends BaseInventory{
$item = $this->getItemInHand(); $item = $this->getItemInHand();
$pk = new MobEquipmentPacket(); $pk = new MobEquipmentPacket();
$pk->eid = $this->getHolder()->getId(); $pk->entityRuntimeId = $this->getHolder()->getId();
$pk->item = $item; $pk->item = $item;
$pk->inventorySlot = $this->getHeldItemSlot(); $pk->inventorySlot = $this->getHeldItemSlot();
$pk->hotbarSlot = $this->getHeldItemIndex(); $pk->hotbarSlot = $this->getHeldItemIndex();
@ -413,7 +413,7 @@ class PlayerInventory extends BaseInventory{
$armor = $this->getArmorContents(); $armor = $this->getArmorContents();
$pk = new MobArmorEquipmentPacket(); $pk = new MobArmorEquipmentPacket();
$pk->eid = $this->getHolder()->getId(); $pk->entityRuntimeId = $this->getHolder()->getId();
$pk->slots = $armor; $pk->slots = $armor;
$pk->encode(); $pk->encode();
$pk->isEncoded = true; $pk->isEncoded = true;
@ -461,7 +461,7 @@ class PlayerInventory extends BaseInventory{
$armor = $this->getArmorContents(); $armor = $this->getArmorContents();
$pk = new MobArmorEquipmentPacket(); $pk = new MobArmorEquipmentPacket();
$pk->eid = $this->getHolder()->getId(); $pk->entityRuntimeId = $this->getHolder()->getId();
$pk->slots = $armor; $pk->slots = $armor;
$pk->encode(); $pk->encode();
$pk->isEncoded = true; $pk->isEncoded = true;

View File

@ -52,7 +52,7 @@ abstract class Food extends Item implements FoodSource{
public function onConsume(Entity $human){ public function onConsume(Entity $human){
$pk = new EntityEventPacket(); $pk = new EntityEventPacket();
$pk->eid = $human->getId(); $pk->entityRuntimeId = $human->getId();
$pk->event = EntityEventPacket::USE_ITEM; $pk->event = EntityEventPacket::USE_ITEM;
if($human instanceof Player){ if($human instanceof Player){
$human->dataPacket($pk); $human->dataPacket($pk);

View File

@ -2904,7 +2904,7 @@ class Level implements ChunkManager, Metadatable{
public function addEntityMotion(int $chunkX, int $chunkZ, int $entityId, float $x, float $y, float $z){ public function addEntityMotion(int $chunkX, int $chunkZ, int $entityId, float $x, float $y, float $z){
$pk = new SetEntityMotionPacket(); $pk = new SetEntityMotionPacket();
$pk->eid = $entityId; $pk->entityRuntimeId = $entityId;
$pk->motionX = $x; $pk->motionX = $x;
$pk->motionY = $y; $pk->motionY = $y;
$pk->motionZ = $z; $pk->motionZ = $z;
@ -2913,7 +2913,7 @@ class Level implements ChunkManager, Metadatable{
public function addEntityMovement(int $chunkX, int $chunkZ, int $entityId, float $x, float $y, float $z, float $yaw, float $pitch, $headYaw = null){ public function addEntityMovement(int $chunkX, int $chunkZ, int $entityId, float $x, float $y, float $z, float $yaw, float $pitch, $headYaw = null){
$pk = new MoveEntityPacket(); $pk = new MoveEntityPacket();
$pk->eid = $entityId; $pk->entityRuntimeId = $entityId;
$pk->x = $x; $pk->x = $x;
$pk->y = $y; $pk->y = $y;
$pk->z = $z; $pk->z = $z;

View File

@ -69,7 +69,7 @@ class FloatingTextParticle extends Particle{
$this->entityId = (int) bcadd("1095216660480", mt_rand(0, 0x7fffffff)); //No conflict with other things $this->entityId = (int) bcadd("1095216660480", mt_rand(0, 0x7fffffff)); //No conflict with other things
}else{ }else{
$pk0 = new RemoveEntityPacket(); $pk0 = new RemoveEntityPacket();
$pk0->eid = $this->entityId; $pk0->entityUniqueId = $this->entityId;
$p[] = $pk0; $p[] = $pk0;
} }

View File

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

View File

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

View File

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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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