Documentation
¶
Overview ¶
Package mcproto provides functions to read types and decode frames declared at https://minecraft.wiki/w/Java_Edition_protocol
Index ¶
- Constants
- func ReadBoolean(reader io.Reader) (bool, error)
- func ReadByte(reader io.Reader) (byte, error)
- func ReadByteArray(reader io.Reader, length int) ([]byte, error)
- func ReadLong(reader io.Reader) (int64, error)
- func ReadString(reader io.Reader) (string, error)
- func ReadUTF16BEString(reader io.Reader, symbolLen uint16) (string, error)
- func ReadUnsignedInt(reader io.Reader) (uint32, error)
- func ReadUnsignedShort(reader io.Reader) (uint16, error)
- func ReadUuid(reader io.Reader) (uuid.UUID, error)
- func ReadVarInt(reader io.Reader) (int, error)
- type ByteReader
- type Frame
- type Handshake
- type LegacyServerListPing
- type LoginStart
- type Packet
- type ProtocolVersion
- type State
Constants ¶
const ( PacketIdHandshake = 0x00 PacketIdLogin = 0x00 // during StateLogin PacketIdLegacyServerListPing = 0xFE )
const MaxFrameLength = 2097151
MaxFrameLength is declared at https://minecraft.wiki/w/Java_Edition_protocol#Packet_format to be 2^21 - 1
const (
PacketLengthFieldBytes = 1
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ByteReader ¶
type Handshake ¶
type Handshake struct { ProtocolVersion ProtocolVersion ServerAddress string ServerPort uint16 NextState State }
func DecodeHandshake ¶
DecodeHandshake takes the Packet.Data bytes and decodes a Handshake message from it
type LegacyServerListPing ¶
type LoginStart ¶
func DecodeLoginStart ¶
func DecodeLoginStart(protocolVersion ProtocolVersion, data interface{}) (*LoginStart, error)
DecodeLoginStart takes the Packet.Data bytes and decodes a LoginStart message from it
func NewLoginStart ¶
func NewLoginStart() *LoginStart
type Packet ¶
type Packet struct { Length int PacketID int // Data is either a byte slice of raw content or a decoded message Data interface{} }
func ReadPacket ¶
ReadPacket reads a packet from the given reader based on the provided connection state. Returns a pointer to the Packet and an error if reading fails. Handles legacy server list ping packet when in the handshaking state. The provided addr is used for logging purposes.
type ProtocolVersion ¶
type ProtocolVersion int
const ( // ProtocolVersion1_18_2 is the protocol version for Minecraft 1.18.2 // Docs: https://minecraft.wiki/w/Java_Edition_protocol/Packets?oldid=2772791 ProtocolVersion1_18_2 ProtocolVersion = 758 // ProtocolVersion1_19 is the protocol version for Minecraft 1.19 // Docs: https://minecraft.wiki/w/Java_Edition_protocol/Packets?oldid=2772904 ProtocolVersion1_19 ProtocolVersion = 759 // ProtocolVersion1_19_2 is the protocol version for Minecraft 1.19.2 // Docs: https://minecraft.wiki/w/Java_Edition_protocol/Packets?oldid=2772944 ProtocolVersion1_19_2 ProtocolVersion = 760 // ProtocolVersion1_19_2 is the protocol version for Minecraft 1.19.3 ProtocolVersion1_19_3 ProtocolVersion = 761 // ProtocolVersion1_20_2 is the protocol version for Minecraft 1.20.2 ProtocolVersion1_20_2 ProtocolVersion = 764 // ProtocolVersion1_21_5 is the protocol version for Minecraft 1.21.5 ProtocolVersion1_21_5 ProtocolVersion = 770 )
Source: https://minecraft.wiki/w/Minecraft_Wiki:Projects/wiki.vg_merge/Protocol_History