packet

package
v0.0.0-...-d63482c Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NodeTypeRoot     byte = 0x00
	NodeTypeLiteral  byte = 0x01
	NodeTypeArgument byte = 0x02

	FlagNodeType       byte = 0x03
	FlagExecutable     byte = 0x04
	FlagIsRedirect     byte = 0x08
	FlagHasSuggestions byte = 0x10
)
View Source
const (
	StatusHandshakeIntent   = HandshakeIntent(states.StatusState)
	LoginHandshakeIntent    = HandshakeIntent(states.LoginState)
	TransferHandshakeIntent = HandshakeIntent(3)
)
View Source
const VanillaMaxTabCompleteLen = 2048

Variables

View Source
var PlaceholderCommand = brigodier.CommandFunc(func(c *brigodier.CommandContext) error { return nil })

Functions

This section is empty.

Types

type AvailableCommands

type AvailableCommands struct {
	RootNode *brigodier.RootCommandNode
}

func (*AvailableCommands) Decode

func (a *AvailableCommands) Decode(c *proto.PacketContext, rd io.Reader) error

func (*AvailableCommands) Encode

func (a *AvailableCommands) Encode(c *proto.PacketContext, wr io.Writer) (err error)

type BundleDelimiter

type BundleDelimiter struct{}

func (*BundleDelimiter) Decode

func (*BundleDelimiter) Encode

type ChatCompletionAction

type ChatCompletionAction int
const (
	AddChatCompletionAction ChatCompletionAction = iota
	RemoveChatCompletionAction
	SetChatCompletionAction
)

type ClientSettings

type ClientSettings struct {
	Locale               string // may be empty
	ViewDistance         byte
	ChatVisibility       int
	ChatColors           bool
	Difficulty           byte // 1.7 Protocol
	SkinParts            byte
	MainHand             int
	TextFilteringEnabled bool // 1.17+
	ClientListingAllowed bool // 1.18+, overwrites server-list "anonymous" mode
	ParticleStatus       int  // Added in 1.21.2
}

func (*ClientSettings) Decode

func (s *ClientSettings) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*ClientSettings) Encode

func (s *ClientSettings) Encode(c *proto.PacketContext, wr io.Writer) error

type CustomReportDetails

type CustomReportDetails struct {
	Details map[string]string
}

func (*CustomReportDetails) Decode

func (p *CustomReportDetails) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*CustomReportDetails) Encode

type DeathPosition

type DeathPosition struct {
	Key   string
	Value int64
}

func (*DeathPosition) String

func (d *DeathPosition) String() string

type DimensionInfo

type DimensionInfo struct {
	RegistryIdentifier string
	LevelName          *string // nil-able
	Flat               bool
	DebugType          bool
}

func (*DimensionInfo) Validate

func (d *DimensionInfo) Validate(p proto.Protocol) error

Validate checks if the dimension info is valid for the given protocol version.

type Disconnect

type Disconnect struct {
	Reason *chat.ComponentHolder // nil-able
}

func NewDisconnect

func NewDisconnect(reason component.Component, protocol proto.Protocol, stat states.State) *Disconnect

NewDisconnect creates a new Disconnect packet.

func (*Disconnect) Decode

func (d *Disconnect) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*Disconnect) Encode

func (d *Disconnect) Encode(c *proto.PacketContext, wr io.Writer) error

type EncryptionRequest

type EncryptionRequest struct {
	ServerID            string
	PublicKey           []byte
	VerifyToken         []byte
	DisableAuthenticate bool
}

func (*EncryptionRequest) Decode

func (e *EncryptionRequest) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*EncryptionRequest) Encode

func (e *EncryptionRequest) Encode(c *proto.PacketContext, wr io.Writer) error

type EncryptionResponse

type EncryptionResponse struct {
	SharedSecret []byte
	VerifyToken  []byte
	Salt         *int64 // 1.19+
}

func (*EncryptionResponse) Decode

func (e *EncryptionResponse) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*EncryptionResponse) Encode

type Handshake

type Handshake struct {
	ProtocolVersion int
	ServerAddress   string
	Port            int
	NextStatus      int
}

https://wiki.vg/Protocol#Handshaking

func (*Handshake) Decode

func (h *Handshake) Decode(_ *proto.PacketContext, rd io.Reader) (err error)

func (*Handshake) Encode

func (h *Handshake) Encode(_ *proto.PacketContext, wr io.Writer) error

func (*Handshake) Intent

func (h *Handshake) Intent() HandshakeIntent

type HandshakeIntent

type HandshakeIntent int

HandshakeIntent represents the client intent in the Handshake state.

type HeaderAndFooter

type HeaderAndFooter struct {
	Header chat.ComponentHolder
	Footer chat.ComponentHolder
}

func (*HeaderAndFooter) Decode

func (h *HeaderAndFooter) Decode(c *proto.PacketContext, rd io.Reader) (err error)

we never read this packet

func (*HeaderAndFooter) Encode

func (h *HeaderAndFooter) Encode(c *proto.PacketContext, wr io.Writer) error

type JoinGame

type JoinGame struct {
	EntityID             int
	Gamemode             int16
	Dimension            int
	PartialHashedSeed    int64 // 1.15+
	Difficulty           int16
	Hardcore             bool
	MaxPlayers           int
	LevelType            *string // nil-able: removed in 1.16+
	ViewDistance         int     // 1.14+
	ReducedDebugInfo     bool
	ShowRespawnScreen    bool
	DoLimitedCrafting    bool                   // 1.20.2+
	LevelNames           []string               // a set of strings, 1.16+
	Registry             util.CompoundBinaryTag // 1.16+
	DimensionInfo        *DimensionInfo         // 1.16+
	CurrentDimensionData util.CompoundBinaryTag // 1.16.2+
	PreviousGamemode     int16                  // 1.16+
	SimulationDistance   int                    // 1.18+
	LastDeathPosition    *DeathPosition         // 1.19+
	PortalCooldown       int                    // 1.20+
	SeaLevel             int                    // 1.21.2+
	EnforcesSecureChat   bool                   // 1.20.5+
}

func (*JoinGame) Decode

func (j *JoinGame) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*JoinGame) Encode

func (j *JoinGame) Encode(c *proto.PacketContext, wr io.Writer) error

type KeepAlive

type KeepAlive struct {
	RandomID int64
}

func (*KeepAlive) Decode

func (k *KeepAlive) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*KeepAlive) Encode

func (k *KeepAlive) Encode(c *proto.PacketContext, wr io.Writer) error

type LoginAcknowledged

type LoginAcknowledged struct{}

func (*LoginAcknowledged) Decode

func (l *LoginAcknowledged) Decode(_ *proto.PacketContext, rd io.Reader) (err error)

func (*LoginAcknowledged) Encode

func (l *LoginAcknowledged) Encode(_ *proto.PacketContext, wr io.Writer) error

type LoginPluginMessage

type LoginPluginMessage struct {
	ID      int
	Channel string
	Data    []byte
}

func (*LoginPluginMessage) Decode

func (l *LoginPluginMessage) Decode(_ *proto.PacketContext, rd io.Reader) (err error)

func (*LoginPluginMessage) Encode

type LoginPluginResponse

type LoginPluginResponse struct {
	ID      int
	Success bool
	Data    []byte
}

func (*LoginPluginResponse) Decode

func (l *LoginPluginResponse) Decode(_ *proto.PacketContext, rd io.Reader) (err error)

func (*LoginPluginResponse) Encode

func (l *LoginPluginResponse) Encode(_ *proto.PacketContext, wr io.Writer) (err error)

type PingIdentify

type PingIdentify struct {
	ID int
}

func (*PingIdentify) Decode

func (p *PingIdentify) Decode(c *proto.PacketContext, rd io.Reader) error

func (*PingIdentify) Encode

func (p *PingIdentify) Encode(c *proto.PacketContext, wr io.Writer) error

type PlayerChatCompletion

type PlayerChatCompletion struct {
	Completions []string
	Action      ChatCompletionAction
}

func (*PlayerChatCompletion) Decode

func (p *PlayerChatCompletion) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*PlayerChatCompletion) Encode

type RemoveResourcePack

type RemoveResourcePack struct {
	ID uuid.UUID
}

func (*RemoveResourcePack) Decode

func (*RemoveResourcePack) Encode

type ResourcePackRequest

type ResourcePackRequest struct {
	ID       uuid.UUID // 1.20.3+
	URL      string
	Hash     string
	Required bool                  // 1.17+
	Prompt   *chat.ComponentHolder // (nil-able) 1.17+
}

func (*ResourcePackRequest) Decode

func (r *ResourcePackRequest) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*ResourcePackRequest) Encode

type ResourcePackResponse

type ResourcePackResponse struct {
	ID     uuid.UUID // 1.20.3+
	Hash   string
	Status ResponseStatus
}

func (*ResourcePackResponse) Decode

func (r *ResourcePackResponse) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*ResourcePackResponse) Encode

type Respawn

type Respawn struct {
	Dimension            int
	PartialHashedSeed    int64
	Difficulty           int16
	Gamemode             int16
	LevelType            string                 // empty by default
	DataToKeep           byte                   // 1.16+
	DimensionInfo        *DimensionInfo         // 1.16-1.16.1
	PreviousGamemode     int16                  // 1.16+
	CurrentDimensionData util.CompoundBinaryTag // 1.16.2+
	LastDeathPosition    *DeathPosition         // 1.19+
	PortalCooldown       int                    // 1.20+
	SeaLevel             int                    // 1.21.2+
}

func (*Respawn) Decode

func (r *Respawn) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*Respawn) Encode

func (r *Respawn) Encode(c *proto.PacketContext, wr io.Writer) (err error)

type ResponseStatus

type ResponseStatus int
const (
	SuccessfulResourcePackResponseStatus ResponseStatus = iota
	DeclinedResourcePackResponseStatus
	FailedDownloadResourcePackResponseStatus
	AcceptedResourcePackResponseStatus
	DownloadedResourcePackResponseStatus
	InvalidURLResourcePackResponseStatus
	FailedToReloadResourcePackResponseStatus
	DiscardedResourcePackResponseStatus
)

func (ResponseStatus) Intermediate

func (s ResponseStatus) Intermediate() bool

Intermediate returns true if the resource pack status is intermediate, indicating that the player has either accepted the resource pack and is currently downloading it or has successfully downloaded it.

type ServerData

type ServerData struct {
	Description        *chat.ComponentHolder // nil-able
	Favicon            favicon.Favicon       // may be empty
	SecureChatEnforced bool                  // Added in 1.19.1 - Removed in 1.20.5
}

func (*ServerData) Decode

func (s *ServerData) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*ServerData) Encode

func (s *ServerData) Encode(c *proto.PacketContext, wr io.Writer) error
type ServerLink struct {
	ID          int
	DisplayName chat.ComponentHolder
	URL         string
}

func (*ServerLink) Decode

func (p *ServerLink) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*ServerLink) Encode

func (p *ServerLink) Encode(c *proto.PacketContext, wr io.Writer) error
type ServerLinks struct {
	ServerLinks []*ServerLink
}

func (*ServerLinks) Decode

func (p *ServerLinks) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*ServerLinks) Encode

func (p *ServerLinks) Encode(c *proto.PacketContext, wr io.Writer) error

type ServerLogin

type ServerLogin struct {
	Username  string
	PlayerKey crypto.IdentifiedKey // 1.19.3
	HolderID  uuid.UUID            // Used for key revision 2
}

func (*ServerLogin) Decode

func (s *ServerLogin) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*ServerLogin) Encode

func (s *ServerLogin) Encode(c *proto.PacketContext, wr io.Writer) error

type ServerLoginSuccess

type ServerLoginSuccess struct {
	UUID       uuid.UUID
	Username   string
	Properties []profile.Property // 1.19+
}

func (*ServerLoginSuccess) Decode

func (s *ServerLoginSuccess) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*ServerLoginSuccess) Encode

func (s *ServerLoginSuccess) Encode(c *proto.PacketContext, wr io.Writer) (err error)

type SetCompression

type SetCompression struct {
	Threshold int
}

func (*SetCompression) Decode

func (s *SetCompression) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*SetCompression) Encode

func (s *SetCompression) Encode(c *proto.PacketContext, wr io.Writer) error

type StatusPing

type StatusPing struct {
	RandomID int64
}

func (*StatusPing) Decode

func (s *StatusPing) Decode(_ *proto.PacketContext, rd io.Reader) (err error)

func (*StatusPing) Encode

func (s *StatusPing) Encode(_ *proto.PacketContext, wr io.Writer) error

type StatusRequest

type StatusRequest struct{}

func (StatusRequest) Decode

func (StatusRequest) Encode

type StatusResponse

type StatusResponse struct {
	Status string
}

func (*StatusResponse) Decode

func (s *StatusResponse) Decode(_ *proto.PacketContext, rd io.Reader) (err error)

func (*StatusResponse) Encode

func (s *StatusResponse) Encode(_ *proto.PacketContext, wr io.Writer) error

type TabCompleteOffer

type TabCompleteOffer struct {
	Text    string
	Tooltip *chat.ComponentHolder // nil-able
}

type TabCompleteRequest

type TabCompleteRequest struct {
	Command       string
	TransactionID int
	AssumeCommand bool
	HasPosition   bool
	Position      int64
}

func (*TabCompleteRequest) Decode

func (t *TabCompleteRequest) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*TabCompleteRequest) Encode

type TabCompleteResponse

type TabCompleteResponse struct {
	TransactionID int
	Start         int
	Length        int
	Offers        []TabCompleteOffer
}

func (*TabCompleteResponse) Decode

func (t *TabCompleteResponse) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*TabCompleteResponse) Encode

type Transfer

type Transfer struct {
	Host string
	Port int
}

func (*Transfer) Addr

func (t *Transfer) Addr() (net.Addr, error)

Addr formats the host and port into a net.Addr. If the host is empty, the second return value is false.

func (*Transfer) Decode

func (t *Transfer) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*Transfer) Encode

func (t *Transfer) Encode(c *proto.PacketContext, wr io.Writer) error

type WireNode

type WireNode struct {
	IDx        int
	Flags      byte
	Children   []int
	RedirectTo int
	Args       brigodier.NodeBuilder // nil-able
	Built      brigodier.CommandNode
	Validated  bool
}

Directories

Path Synopsis
tablist
Package title contains title packets.
Package title contains title packets.

Jump to

Keyboard shortcuts

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