Hey, Im trying to make some custom packets, but I have no idea what to add into the encode() or decode() functions. Here is a basic packet template: PHP: class PlayerListPacket extends DataPacket { const NETWORK_ID = 0xc3; public function pid(){ return 0xc3; } public function decode(){ } public function encode(){ $this->buffer = \chr(self::NETWORK_ID); $this->offset = 0;; }} Now, at the moment, the encode makes the client freeze. Im not too sure how it is formatted as each type of data value is encoded in a strange way. Here is an example of the encode function in the AddPlayerPacket: PHP: public function encode(){ $this->buffer = \chr(self::NETWORK_ID); $this->offset = 0;; $this->buffer .= Binary::writeLong($this->clientID); $this->putString($this->username); $this->buffer .= Binary::writeLong($this->eid); $this->buffer .= (\ENDIANNESS === 0 ? \pack("f", $this->x) : \strrev(\pack("f", $this->x))); $this->buffer .= (\ENDIANNESS === 0 ? \pack("f", $this->y) : \strrev(\pack("f", $this->y))); $this->buffer .= (\ENDIANNESS === 0 ? \pack("f", $this->z) : \strrev(\pack("f", $this->z))); $this->buffer .= (\ENDIANNESS === 0 ? \pack("f", $this->speedX) : \strrev(\pack("f", $this->speedX))); $this->buffer .= (\ENDIANNESS === 0 ? \pack("f", $this->speedY) : \strrev(\pack("f", $this->speedY))); $this->buffer .= (\ENDIANNESS === 0 ? \pack("f", $this->speedZ) : \strrev(\pack("f", $this->speedZ))); $this->buffer .= (\ENDIANNESS === 0 ? \pack("f", $this->yaw) : \strrev(\pack("f", $this->yaw))); $this->buffer .= (\ENDIANNESS === 0 ? \pack("f", $this->yaw) : \strrev(\pack("f", $this->yaw))); $this->buffer .= (\ENDIANNESS === 0 ? \pack("f", $this->pitch) : \strrev(\pack("f", $this->pitch))); $this->buffer .= \pack("n", $this->item);$this->buffer .= \pack("n", $this->meta); $this->buffer .= \chr($this->slim ? 1 : 0); $this->putString($this->skin); $meta = Binary::writeMetadata($this->metadata); $this->buffer .= $meta;} Any ideas?
This is what I meant by PocketMine source. https://github.com/PocketMine/Pocke...cketmine/network/protocol/AddPlayerPacket.php This is the unprocessed version of PocketMine.
ah, thats really helpful, thanks (I was getting the classes from my IDE, so i thought it would have been an unprocessed version but it clearly isnt xD)