Skip to content
This repository was archived by the owner on Nov 13, 2022. It is now read-only.

Creating new Packet

Vitalij edited this page Mar 14, 2014 · 2 revisions

Don't panic if a new version of Minecraft with new packets is released. Adding new packets is very simple. Just mark is as IPacket and implement Id, ReadPacket and WritePacket

public struct YourPacket : IPacket
    {
        public *put here used objects*

        public const byte PacketId = *Packet Id*;
        public byte Id { get { return *Packet Id*; } }

        public void ReadPacket(ref Wrapped stream)
        {
            *Read here your objects*
        }

        public void WritePacket(ref Wrapped stream)
        {
            stream.WriteVarInt(Id);
            *Write here your objects*
            stream.Purge();
        }
    }

Don't forget to add it in PacketResponse.cs in used section (Login, Status or Play) (position is important, put it in right place, see commented hex) for reading it from server.

Clone this wiki locally