mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 10:22:56 +00:00
Refactored entity IDs in packets for consistency and to clarify on types
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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]);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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{
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user