protocol

package
v0.0.0-...-6314b16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Code generated by GopherMc/generator. DO NOT EDIT. See generator/main.go for more details.

Code generated by GopherMc/generator. DO NOT EDIT. See generator/main.go for more details.

Index

Constants

View Source
const (
	MaxVarIntSize     = 5
	MaxPacketDataSize = 2097152
)
View Source
const First = V1_7
View Source
const Latest = V1_21_9

Variables

View Source
var ErrUnknownPacket = errors.New("unknown packet")
View Source
var (
	Versions []Version
)

Functions

func GetPacketID

func GetPacketID(v Version, s State, d Direction, p Packet) (int32, bool)

func OfflineUUID

func OfflineUUID(username string) uuid.UUID

func ReadBool

func ReadBool(r io.Reader) (bool, error)

func ReadByte

func ReadByte(r io.Reader) (byte, error)

func ReadBytes

func ReadBytes(r io.Reader) ([]byte, error)

func ReadLong

func ReadLong(r io.Reader) (int64, error)

func ReadString

func ReadString(r io.Reader) (string, error)

func ReadStringUUID

func ReadStringUUID(r io.Reader) (uuid.UUID, error)

func ReadUShort

func ReadUShort(r io.Reader) (uint16, error)

func ReadUUID

func ReadUUID(r io.Reader) (uuid.UUID, error)

func ReadVarInt

func ReadVarInt(r io.Reader) (int32, error)

func WriteBool

func WriteBool(w io.Writer, v bool) error

func WriteByte

func WriteByte(w io.Writer, b byte) error

func WriteByteSlice

func WriteByteSlice(w io.Writer, data []byte) error

func WriteLong

func WriteLong(w io.Writer, v int64) error

func WriteString

func WriteString(w io.Writer, value string) error

func WriteUShort

func WriteUShort(w io.Writer, v uint16) error

func WriteVarInt

func WriteVarInt(w io.Writer, value int32) error

Types

type ClientSettings

type ClientSettings struct {
	Locale     string
	View       byte
	ChatMode   int32
	ChatColors bool
	SkinParts  byte
	MainHand   int32
}

type ClientboundChatMessage

type ClientboundChatMessage struct {
	Component component.ChatComponent
	Sender    string
}

func (*ClientboundChatMessage) Decode

func (p *ClientboundChatMessage) Decode(r io.Reader, v Version) (err error)

func (*ClientboundChatMessage) Encode

func (p *ClientboundChatMessage) Encode(_ io.Writer, _ Version) error

type ClientboundConfigKeepAlive

type ClientboundConfigKeepAlive struct{ ID int64 }

func (*ClientboundConfigKeepAlive) Decode

func (p *ClientboundConfigKeepAlive) Decode(r io.Reader, _ Version) (err error)

func (*ClientboundConfigKeepAlive) Encode

type ClientboundConfigPing

type ClientboundConfigPing struct{ ID int32 }

func (*ClientboundConfigPing) Decode

func (p *ClientboundConfigPing) Decode(r io.Reader, _ Version) error

func (*ClientboundConfigPing) Encode

func (p *ClientboundConfigPing) Encode(w io.Writer, _ Version) error

type ClientboundCookieRequest

type ClientboundCookieRequest struct {
	Key string
}

func (*ClientboundCookieRequest) Decode

func (*ClientboundCookieRequest) Encode

type ClientboundCustomPayload

type ClientboundCustomPayload struct{ CustomPayloadData }

func (*ClientboundCustomPayload) Decode

func (*ClientboundCustomPayload) Encode

type ClientboundDisconnect

type ClientboundDisconnect struct{ Reason string }

func (*ClientboundDisconnect) Decode

func (p *ClientboundDisconnect) Decode(r io.Reader, _ Version) (err error)

func (*ClientboundDisconnect) Encode

func (p *ClientboundDisconnect) Encode(w io.Writer, _ Version) error

type ClientboundFeatureFlags

type ClientboundFeatureFlags struct {
	Features []string
}

func (*ClientboundFeatureFlags) Decode

func (p *ClientboundFeatureFlags) Decode(r io.Reader, _ Version) error

func (*ClientboundFeatureFlags) Encode

func (p *ClientboundFeatureFlags) Encode(_ io.Writer, _ Version) error

type ClientboundFinishConfiguration

type ClientboundFinishConfiguration struct{}

func (*ClientboundFinishConfiguration) Decode

func (*ClientboundFinishConfiguration) Encode

type ClientboundJoinGame

type ClientboundJoinGame struct{}

func (*ClientboundJoinGame) Decode

func (p *ClientboundJoinGame) Decode(r io.Reader, _ Version) error

func (*ClientboundJoinGame) Encode

func (p *ClientboundJoinGame) Encode(_ io.Writer, _ Version) error

type ClientboundKeepAlive

type ClientboundKeepAlive struct{ ID int64 }

func (*ClientboundKeepAlive) Decode

func (p *ClientboundKeepAlive) Decode(r io.Reader, v Version) (err error)

func (*ClientboundKeepAlive) Encode

func (p *ClientboundKeepAlive) Encode(_ io.Writer, _ Version) error

type ClientboundLoginSuccess

type ClientboundLoginSuccess struct {
	Username string
	UUID     uuid.UUID
}

func (*ClientboundLoginSuccess) Decode

func (p *ClientboundLoginSuccess) Decode(r io.Reader, v Version) (err error)

func (*ClientboundLoginSuccess) Encode

func (p *ClientboundLoginSuccess) Encode(_ io.Writer, _ Version) error

type ClientboundPong

type ClientboundPong struct{ Payload int64 }

func (*ClientboundPong) Decode

func (p *ClientboundPong) Decode(r io.Reader, _ Version) (err error)

func (*ClientboundPong) Encode

func (p *ClientboundPong) Encode(w io.Writer, _ Version) error

type ClientboundRegistryData

type ClientboundRegistryData struct {
	Registry string
	Data     []byte
}

func (*ClientboundRegistryData) Decode

func (p *ClientboundRegistryData) Decode(r io.Reader, _ Version) error

func (*ClientboundRegistryData) Encode

func (p *ClientboundRegistryData) Encode(_ io.Writer, _ Version) error

type ClientboundSelectKnownPacks

type ClientboundSelectKnownPacks struct {
	Packs []KnownPack
}

func (*ClientboundSelectKnownPacks) Decode

func (*ClientboundSelectKnownPacks) Encode

type ClientboundSetCompression

type ClientboundSetCompression struct{ Threshold int32 }

func (*ClientboundSetCompression) Decode

func (p *ClientboundSetCompression) Decode(r io.Reader, _ Version) (err error)

func (*ClientboundSetCompression) Encode

type ClientboundStatusResponse

type ClientboundStatusResponse struct{ JSONResponse string }

func (*ClientboundStatusResponse) Decode

func (p *ClientboundStatusResponse) Decode(r io.Reader, _ Version) (err error)

func (*ClientboundStatusResponse) Encode

type ClientboundUpdateTags

type ClientboundUpdateTags struct {
	Tags []RegistryTag
}

func (*ClientboundUpdateTags) Decode

func (p *ClientboundUpdateTags) Decode(r io.Reader, _ Version) error

func (*ClientboundUpdateTags) Encode

func (p *ClientboundUpdateTags) Encode(_ io.Writer, _ Version) error

type Conn

type Conn struct {
	net.Conn
	// contains filtered or unexported fields
}

func NewConn

func NewConn(conn net.Conn, version Version) *Conn

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) ReadPacket

func (c *Conn) ReadPacket() (Packet, error)

func (*Conn) SetCompression

func (c *Conn) SetCompression(threshold int)

func (*Conn) SetState

func (c *Conn) SetState(s State)

func (*Conn) State

func (c *Conn) State() State

func (*Conn) WritePacket

func (c *Conn) WritePacket(p Packet) error

type CustomPayload

type CustomPayload struct {
	Channel string
	Data    []byte
}

func (*CustomPayload) Decode

func (p *CustomPayload) Decode(r io.Reader, _ Version) (err error)

func (*CustomPayload) Encode

func (p *CustomPayload) Encode(w io.Writer, _ Version) error

type CustomPayloadData

type CustomPayloadData struct {
	Channel string
	Data    []byte
}

type Definition

type Definition struct {
	ProtocolVersion int32
	PacketNames     map[State]map[Direction]map[int32]string
	PacketIDs       map[State]map[Direction]map[string]int32
}

func GetDefinition

func GetDefinition(v Version) *Definition

type Direction

type Direction bool
const (
	DirectionServerbound Direction = true
	DirectionClientbound Direction = false
)

type KnownPack

type KnownPack struct {
	Namespace string
	ID        string
	Version   string
}

type Packet

type Packet interface {
	Encode(w io.Writer, v Version) error
	Decode(r io.Reader, v Version) error
}

func NewPacket

func NewPacket(v Version, s State, d Direction, id int32) (Packet, error)

type PacketFactory

type PacketFactory func() Packet

type PlayerPosition

type PlayerPosition struct {
	X, Y, Z             float64
	Yaw, HeadYaw, Pitch float32
	OnGround            bool
	// contains filtered or unexported fields
}

func (*PlayerPosition) Update

func (p *PlayerPosition) Update(
	x float64,
	y float64,
	z float64,
	yaw float32,
	headYaw float32,
	pitch float32,
	ground bool,
)

type RegistryTag

type RegistryTag struct {
	Registry string
	Tags     []Tag
}

type ServerboundChatMessage

type ServerboundChatMessage struct {
	Message    string
	PrivateKey *rsa.PrivateKey
	UUID       uuid.UUID
}

func (*ServerboundChatMessage) Decode

func (p *ServerboundChatMessage) Decode(r io.Reader, _ Version) (err error)

func (*ServerboundChatMessage) Encode

func (p *ServerboundChatMessage) Encode(w io.Writer, v Version) error

type ServerboundClientSettings

type ServerboundClientSettings struct {
	ClientSettings
}

func (*ServerboundClientSettings) Decode

func (*ServerboundClientSettings) Encode

type ServerboundConfigKeepAlive

type ServerboundConfigKeepAlive struct{ ID int64 }

func (*ServerboundConfigKeepAlive) Decode

func (p *ServerboundConfigKeepAlive) Decode(r io.Reader, _ Version) (err error)

func (*ServerboundConfigKeepAlive) Encode

type ServerboundConfigPong

type ServerboundConfigPong struct{ ID int32 }

func (*ServerboundConfigPong) Decode

func (p *ServerboundConfigPong) Decode(_ io.Reader, _ Version) error

func (*ServerboundConfigPong) Encode

func (p *ServerboundConfigPong) Encode(w io.Writer, _ Version) error

type ServerboundCookieResponse

type ServerboundCookieResponse struct {
	Key     string
	HasData bool
	Data    []byte
}

func (*ServerboundCookieResponse) Decode

func (*ServerboundCookieResponse) Encode

type ServerboundCustomPayload

type ServerboundCustomPayload struct{ CustomPayloadData }

func (*ServerboundCustomPayload) Decode

func (*ServerboundCustomPayload) Encode

type ServerboundFinishConfiguration

type ServerboundFinishConfiguration struct{}

func (*ServerboundFinishConfiguration) Decode

func (*ServerboundFinishConfiguration) Encode

type ServerboundHandshake

type ServerboundHandshake struct {
	ProtocolVersion int32
	ServerAddress   string
	ServerPort      uint16
	NextState       State
}

func (*ServerboundHandshake) Decode

func (p *ServerboundHandshake) Decode(r io.Reader, _ Version) (err error)

func (*ServerboundHandshake) Encode

func (p *ServerboundHandshake) Encode(w io.Writer, _ Version) error

type ServerboundKeepAlive

type ServerboundKeepAlive struct{ ID int64 }

func (*ServerboundKeepAlive) Decode

func (p *ServerboundKeepAlive) Decode(_ io.Reader, _ Version) error

func (*ServerboundKeepAlive) Encode

func (p *ServerboundKeepAlive) Encode(w io.Writer, v Version) error

type ServerboundLoginAcknowledged

type ServerboundLoginAcknowledged struct{}

func (*ServerboundLoginAcknowledged) Decode

func (*ServerboundLoginAcknowledged) Encode

type ServerboundLoginStart

type ServerboundLoginStart struct {
	Username string
	UUID     uuid.UUID
}

func (*ServerboundLoginStart) Decode

func (p *ServerboundLoginStart) Decode(r io.Reader, _ Version) (err error)

func (*ServerboundLoginStart) Encode

func (p *ServerboundLoginStart) Encode(w io.Writer, v Version) error

type ServerboundPing

type ServerboundPing struct{ Payload int64 }

func (*ServerboundPing) Decode

func (p *ServerboundPing) Decode(r io.Reader, _ Version) (err error)

func (*ServerboundPing) Encode

func (p *ServerboundPing) Encode(w io.Writer, _ Version) error

type ServerboundPlayerPosition

type ServerboundPlayerPosition struct {
	X, Y, Z  float64
	OnGround bool
}

func (*ServerboundPlayerPosition) Decode

func (*ServerboundPlayerPosition) Encode

type ServerboundSelectKnownPacks

type ServerboundSelectKnownPacks struct {
	Packs []KnownPack
}

func (*ServerboundSelectKnownPacks) Decode

func (*ServerboundSelectKnownPacks) Encode

type ServerboundStatusRequest

type ServerboundStatusRequest struct{}

func (*ServerboundStatusRequest) Decode

func (*ServerboundStatusRequest) Encode

type State

type State int
const (
	StateHandshaking State = iota
	StateStatus
	StateLogin
	StatePlay
	StateConfiguration
)

func (State) String

func (s State) String() string

type Tag

type Tag struct {
	Name    string
	Entries []int32
}

type Version

type Version int
const (
	V1_7    Version = iota
	V1_8    Version = iota
	V1_9    Version = iota
	V1_9_2  Version = iota
	V1_9_4  Version = iota
	V1_10   Version = iota
	V1_11   Version = iota
	V1_12   Version = iota
	V1_12_1 Version = iota
	V1_12_2 Version = iota
	V1_13   Version = iota
	V1_13_1 Version = iota
	V1_13_2 Version = iota
	V1_14   Version = iota
	V1_14_1 Version = iota
	V1_14_3 Version = iota
	V1_14_4 Version = iota
	V1_15   Version = iota
	V1_15_1 Version = iota
	V1_15_2 Version = iota
	V1_16   Version = iota
	V1_16_1 Version = iota
	V1_16_2 Version = iota
	V1_17   Version = iota
	V1_17_1 Version = iota
	V1_18   Version = iota
	V1_18_2 Version = iota
	V1_19   Version = iota
	V1_19_2 Version = iota
	V1_19_3 Version = iota
	V1_19_4 Version = iota
	V1_20   Version = iota
	V1_20_2 Version = iota
	V1_20_3 Version = iota
	V1_20_5 Version = iota
	V1_21_1 Version = iota
	V1_21_3 Version = iota
	V1_21_4 Version = iota
	V1_21_5 Version = iota
	V1_21_6 Version = iota
	V1_21_8 Version = iota
	V1_21_9 Version = iota
)

func VersionFromString

func VersionFromString(s string) (Version, bool)

func (Version) Protocol

func (v Version) Protocol() int32

func (Version) String

func (v Version) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL