packet

package
v0.18.3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2022 License: Apache-2.0 Imports: 17 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 (
	MaxServerBoundMessageLength = 256
)
View Source
const UnknownDimensionID = "gate:unknown_dimension"
View Source
const VanillaMaxTabCompleteLen = 2048

Variables

View Source
var PlaceholderCommand = brigodier.CommandFunc(func(c *brigodier.CommandContext) error { return nil })
View Source
var ResetHeaderAndFooter = &HeaderAndFooter{
	Header: `{"translate":""}`,
	Footer: `{"translate":""}`,
}

Functions

This section is empty.

Types

type AvailableCommands

type AvailableCommands struct {
	RootNode *brigodier.RootCommandNode
}

func (*AvailableCommands) Decode

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

func (*AvailableCommands) Encode

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

type Chat

type Chat struct {
	Message string
	Type    MessageType
	Sender  uuid.UUID // 1.16+, and can be empty UUID, all zeros
}

func (*Chat) Decode

func (ch *Chat) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*Chat) Encode

func (ch *Chat) Encode(c *proto.PacketContext, wr io.Writer) error

type ClientSettings

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

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 DimensionData

type DimensionData struct {
	RegistryIdentifier         string   // the identifier for the dimension from the registry
	DimensionID                *int     // nil-able, the dimension ID contained in the registry (the "id" tag)
	Natural                    bool     // indicates if the dimension use natural world generation (e.g. overworld)
	AmbientLight               float32  // the light level the client sees without external lighting
	Shrunk                     bool     // indicates if the world is shrunk, aka not the full 256 blocks (e.g. nether)
	Ultrawarm                  bool     // internal dimension warmth flag
	Ceiling                    bool     // indicates if the dimension has a ceiling layer
	Skylight                   bool     // indicates if the dimension should display the sun
	PiglineSafe                bool     // indicates if piglins should naturally zombify in this dimension
	DoBedsWork                 bool     // indicates if players should be able to sleep in beds in this dimension
	DoRespawnAnchorsWork       bool     // indicates if player respawn points can be used in this dimension
	Raids                      bool     // indicates if raids can be spawned in the dimension
	LogicalHeight              int32    // the natural max height for the given dimension
	BurningBehaviourIdentifier string   // the identifier for how burning blocks work in the dimension
	FixedTime                  *int64   // nil-able
	CreateDragonFight          *bool    // nil-able
	CoordinateScale            *float64 // nil-able
	Effects                    *string  // optional; unknown purpose
	MinY                       *int     // Required since 1.17
	Height                     *int     // Required since 1.17
}

type DimensionInfo

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

type DimensionRegistry

type DimensionRegistry struct {
	Dimensions []*DimensionData
	LevelNames []string
}

DimensionRegistry is required for Minecraft 1.16+ clients/servers to communicate, it constrains the dimension types and names the client can be sent in a Respawn action (dimension change).

type Disconnect

type Disconnect struct {
	Reason *string // A reason must only be given for encoding.
}

func DisconnectWith

func DisconnectWith(reason component.Component) *Disconnect

DisconnectWith creates a Disconnect packet with guaranteed reason.

func DisconnectWithProtocol

func DisconnectWithProtocol(reason component.Component, protocol proto.Protocol) *Disconnect

DisconnectWithProtocol creates a new Disconnect packet for the given given protocol.

func (*Disconnect) Decode

func (d *Disconnect) Decode(_ *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
}

func (*EncryptionRequest) Decode

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

func (*EncryptionRequest) Encode

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

type EncryptionResponse

type EncryptionResponse struct {
	SharedSecret []byte
	VerifyToken  []byte
}

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            int16 // TODO use uint16?
	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

type HeaderAndFooter

type HeaderAndFooter struct {
	Header string
	Footer string
}

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
	DimensionRegistry    *DimensionRegistry // 1.16+
	DimensionInfo        *DimensionInfo     // 1.16+
	CurrentDimensionData *DimensionData     // 1.16.2+
	PreviousGamemode     int16              // 1.16+
	BiomeRegistry        util.NBT           // 1.16.2+
	SimulationDistance   int                // 1.18+
}

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 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 MessageType

type MessageType byte

MessageType is the position a chat message is going to be sent.

const (
	// ChatMessageType lets the chat message appear in the client's HUD.
	// These messages can be filtered out by the client's settings.
	ChatMessageType MessageType = iota
	// SystemMessageType lets the chat message appear in the client's HUD and can't be dismissed.
	SystemMessageType
	// GameInfoMessageType lets the chat message appear above the player's main HUD.
	// This text format doesn't support many component features, such as hover events.
	GameInfoMessageType
)

type PlayerListItem

type PlayerListItem struct {
	Action PlayerListItemAction
	Items  []PlayerListItemEntry
}

func (*PlayerListItem) Decode

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

func (*PlayerListItem) Encode

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

type PlayerListItemAction

type PlayerListItemAction int
const (
	AddPlayerListItemAction PlayerListItemAction = iota
	UpdateGameModePlayerListItemAction
	UpdateLatencyPlayerListItemAction
	UpdateDisplayNamePlayerListItemAction
	RemovePlayerListItemAction
)

type PlayerListItemEntry

type PlayerListItemEntry struct {
	ID          uuid.UUID
	Name        string
	Properties  []profile.Property
	GameMode    int
	Latency     int
	DisplayName component.Component // nil-able
}

type ResourcePackRequest

type ResourcePackRequest struct {
	Url      string
	Hash     string
	Required bool                // 1.17+
	Prompt   component.Component // (nil-able) 1.17+
}

func (*ResourcePackRequest) Decode

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

func (*ResourcePackRequest) Encode

type Respawn

type Respawn struct {
	Dimension            int
	PartialHashedSeed    int64
	Difficulty           int16
	Gamemode             int16
	LevelType            string         // empty by default
	ShouldKeepPlayerData bool           // 1.16+
	DimensionInfo        *DimensionInfo // 1.16-1.16.1
	PreviousGamemode     int16          // 1.16+
	CurrentDimensionData *DimensionData // 1.16.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 ServerLogin

type ServerLogin struct {
	Username string
}

func (*ServerLogin) Decode

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

func (*ServerLogin) Encode

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

type ServerLoginSuccess

type ServerLoginSuccess struct {
	UUID     uuid.UUID
	Username string
}

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 component.Component // 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 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
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