23 public const NETWORK_ID = 0;
25 public const PID_MASK = 0x3ff;
27 private const SUBCLIENT_ID_MASK = 0x03;
28 private const SENDER_SUBCLIENT_ID_SHIFT = 10;
29 private const RECIPIENT_SUBCLIENT_ID_SHIFT = 12;
31 public int $senderSubId = 0;
32 public int $recipientSubId = 0;
34 public function pid() :
int{
35 return $this::NETWORK_ID;
38 public function getName() :
string{
39 return (
new \ReflectionClass($this))->getShortName();
42 public function canBeSentBeforeLogin() :
bool{
54 throw PacketDecodeException::wrap($e, $this->getName());
63 $header = $in->getUnsignedVarInt();
64 $pid = $header & self::PID_MASK;
65 if($pid !== static::NETWORK_ID){
69 $this->senderSubId = ($header >> self::SENDER_SUBCLIENT_ID_SHIFT) & self::SUBCLIENT_ID_MASK;
70 $this->recipientSubId = ($header >> self::RECIPIENT_SUBCLIENT_ID_SHIFT) & self::SUBCLIENT_ID_MASK;
83 $this->encodeHeader($out);
84 $this->encodePayload($out);
88 $out->putUnsignedVarInt(
90 ($this->senderSubId << self::SENDER_SUBCLIENT_ID_SHIFT) |
91 ($this->recipientSubId << self::RECIPIENT_SUBCLIENT_ID_SHIFT)
106 throw new \Error(
"Undefined property: " . get_class($this) .
"::\$" . $name);
113 public function __set($name, $value) : void{
114 throw new \Error(
"Undefined property: " . get_class($this) .
"::\$" . $name);