Documentation ¶
Index ¶
- Constants
- Variables
- type AvailableCommands
- type ChatBuilder
- func (b *ChatBuilder) AsPlayer(sender uuid.UUID) *ChatBuilder
- func (b *ChatBuilder) AsServer() *ChatBuilder
- func (b *ChatBuilder) Component(c component.Component) *ChatBuilder
- func (b *ChatBuilder) Message(msg string) *ChatBuilder
- func (b *ChatBuilder) SignedChatMessage(msg *crypto.SignedChatMessage) *ChatBuilder
- func (b *ChatBuilder) SignedCommandMessage(cmd *crypto.SignedChatCommand) *ChatBuilder
- func (b *ChatBuilder) Time(timestamp time.Time) *ChatBuilder
- func (b *ChatBuilder) ToClient() proto.Packet
- func (b *ChatBuilder) ToServer() proto.Packet
- func (b *ChatBuilder) Type(t MessageType) *ChatBuilder
- type ChatCompletionAction
- type ClientSettings
- type DeathPosition
- type DimensionData
- type DimensionInfo
- type DimensionRegistry
- type Disconnect
- type EncryptionRequest
- type EncryptionResponse
- type Handshake
- type HeaderAndFooter
- type JoinGame
- type KeepAlive
- type LegacyChat
- type LoginPluginMessage
- type LoginPluginResponse
- type MessageType
- type PlayerChat
- type PlayerChatCompletion
- type PlayerChatPreview
- type PlayerCommand
- type PlayerListItem
- type PlayerListItemAction
- type PlayerListItemEntry
- type ResourcePackRequest
- type ResourcePackResponse
- type ResourcePackResponseStatus
- type Respawn
- type ServerChatPreview
- type ServerData
- type ServerLogin
- type ServerLoginSuccess
- type ServerPlayerChat
- type SetCompression
- type StatusPing
- type StatusRequest
- type StatusResponse
- type SystemChat
- type TabCompleteOffer
- type TabCompleteRequest
- type TabCompleteResponse
- type WireNode
Constants ¶
const ( NodeTypeRoot byte = 0x00 NodeTypeLiteral byte = 0x01 NodeTypeArgument byte = 0x02 FlagNodeType byte = 0x03 FlagExecutable byte = 0x04 FlagIsRedirect byte = 0x08 FlagHasSuggestions byte = 0x10 )
const MaxPreviousMessageCount = 5
const (
MaxServerBoundMessageLength = 256
)
const UnknownDimensionID = "gate:unknown_dimension"
const VanillaMaxTabCompleteLen = 2048
Variables ¶
var PlaceholderCommand = brigodier.CommandFunc(func(c *brigodier.CommandContext) error { return nil })
Header: `{"translate":""}`,
Footer: `{"translate":""}`,
}Functions ¶
This section is empty.
Types ¶
type AvailableCommands ¶ added in v0.12.0
type AvailableCommands struct {
RootNode *brigodier.RootCommandNode
}
func (*AvailableCommands) Decode ¶ added in v0.12.0
func (a *AvailableCommands) Decode(c *proto.PacketContext, rd io.Reader) error
func (*AvailableCommands) Encode ¶ added in v0.12.0
func (a *AvailableCommands) Encode(c *proto.PacketContext, wr io.Writer) (err error)
type ChatBuilder ¶ added in v0.19.0
type ChatBuilder struct {
// contains filtered or unexported fields
}
func NewChatBuilder ¶ added in v0.19.0
func NewChatBuilder(version proto.Protocol) *ChatBuilder
func (*ChatBuilder) AsPlayer ¶ added in v0.19.0
func (b *ChatBuilder) AsPlayer(sender uuid.UUID) *ChatBuilder
func (*ChatBuilder) AsServer ¶ added in v0.19.0
func (b *ChatBuilder) AsServer() *ChatBuilder
func (*ChatBuilder) Component ¶ added in v0.19.0
func (b *ChatBuilder) Component(c component.Component) *ChatBuilder
func (*ChatBuilder) Message ¶ added in v0.19.0
func (b *ChatBuilder) Message(msg string) *ChatBuilder
func (*ChatBuilder) SignedChatMessage ¶ added in v0.19.0
func (b *ChatBuilder) SignedChatMessage(msg *crypto.SignedChatMessage) *ChatBuilder
func (*ChatBuilder) SignedCommandMessage ¶ added in v0.19.0
func (b *ChatBuilder) SignedCommandMessage(cmd *crypto.SignedChatCommand) *ChatBuilder
func (*ChatBuilder) Time ¶ added in v0.19.1
func (b *ChatBuilder) Time(timestamp time.Time) *ChatBuilder
func (*ChatBuilder) ToClient ¶ added in v0.19.0
func (b *ChatBuilder) ToClient() proto.Packet
ToClient creates a packet which can be sent to the client; using the provided information in the builder.
func (*ChatBuilder) ToServer ¶ added in v0.19.0
func (b *ChatBuilder) ToServer() proto.Packet
ToServer creates a packet which can be sent to the server; using the provided information in the builder.
func (*ChatBuilder) Type ¶ added in v0.19.0
func (b *ChatBuilder) Type(t MessageType) *ChatBuilder
type ChatCompletionAction ¶ added in v0.19.1
type ChatCompletionAction int
const ( AddChatCompletionAction ChatCompletionAction = iota RemoveChatCompletionAction AlterChatCompletionAction )
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 DeathPosition ¶ added in v0.19.0
func (*DeathPosition) String ¶ added in v0.19.0
func (d *DeathPosition) String() string
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 // Controls the block light needed to prevent monster spawns. MonsterSpawnBlockLightLimit *int // nil-able: Required and added by 1.19 // An int provider which is evaluated to find a value to compare the current // overall brightness with to determine if a monster should be allowed to spawn. MonsterSpawnLightLevel *int // nil-able: Required and added by 1.19 }
type DimensionInfo ¶
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 ¶
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 ¶
func (*EncryptionResponse) Decode ¶
func (e *EncryptionResponse) Decode(c *proto.PacketContext, rd io.Reader) (err error)
func (*EncryptionResponse) Encode ¶
func (e *EncryptionResponse) Encode(c *proto.PacketContext, wr io.Writer) error
type HeaderAndFooter ¶
type HeaderAndFooter struct {}
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+ LastDeadPosition *DeathPosition // 1.19+ ChatTypeRegistry util.NBT // placeholder, 1.19+ // compound binary tag }
type LegacyChat ¶ added in v0.19.0
type LegacyChat struct { Message string Type MessageType Sender uuid.UUID // 1.16+, and can be empty UUID, all zeros }
func (*LegacyChat) Decode ¶ added in v0.19.0
func (ch *LegacyChat) Decode(c *proto.PacketContext, rd io.Reader) (err error)
func (*LegacyChat) Encode ¶ added in v0.19.0
func (ch *LegacyChat) Encode(c *proto.PacketContext, wr io.Writer) error
type LoginPluginMessage ¶
func (*LoginPluginMessage) Decode ¶
func (l *LoginPluginMessage) Decode(_ *proto.PacketContext, rd io.Reader) (err error)
func (*LoginPluginMessage) Encode ¶
func (l *LoginPluginMessage) Encode(_ *proto.PacketContext, wr io.Writer) error
type LoginPluginResponse ¶
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 ¶ added in v0.13.0
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 PlayerChat ¶ added in v0.19.0
type PlayerChat struct { Message string SignedPreview bool Unsigned bool Expiry time.Time // may be zero if no salt or signature specified Signature []byte Salt []byte PreviousMessages []*crypto.SignaturePair LastMessage *crypto.SignaturePair }
func (*PlayerChat) Decode ¶ added in v0.19.0
func (p *PlayerChat) Decode(c *proto.PacketContext, rd io.Reader) (err error)
func (*PlayerChat) Encode ¶ added in v0.19.0
func (p *PlayerChat) Encode(c *proto.PacketContext, wr io.Writer) error
func (*PlayerChat) SignedContainer ¶ added in v0.19.0
func (p *PlayerChat) SignedContainer(signer crypto.IdentifiedKey, sender uuid.UUID, mustSign bool) (*crypto.SignedChatMessage, error)
type PlayerChatCompletion ¶ added in v0.19.1
type PlayerChatCompletion struct { Completions []string Action ChatCompletionAction }
func (*PlayerChatCompletion) Decode ¶ added in v0.19.1
func (p *PlayerChatCompletion) Decode(c *proto.PacketContext, rd io.Reader) (err error)
func (*PlayerChatCompletion) Encode ¶ added in v0.19.1
func (p *PlayerChatCompletion) Encode(c *proto.PacketContext, wr io.Writer) error
type PlayerChatPreview ¶ added in v0.19.0
func (*PlayerChatPreview) Decode ¶ added in v0.19.0
func (p *PlayerChatPreview) Decode(c *proto.PacketContext, rd io.Reader) (err error)
func (*PlayerChatPreview) Encode ¶ added in v0.19.0
func (p *PlayerChatPreview) Encode(c *proto.PacketContext, wr io.Writer) error
type PlayerCommand ¶ added in v0.19.0
type PlayerCommand struct { Unsigned bool Command string Timestamp time.Time Salt int64 SignedPreview bool // Good god. Please no. Arguments map[string][]byte PreviousMessages []*crypto.SignaturePair LastMessage *crypto.SignaturePair }
func NewPlayerCommand ¶ added in v0.19.0
func NewPlayerCommand(command string, arguments []string, timestamp time.Time) *PlayerCommand
NewPlayerCommand returns a new PlayerCommand packet based on a command and list of arguments.
func (*PlayerCommand) Decode ¶ added in v0.19.0
func (p *PlayerCommand) Decode(c *proto.PacketContext, rd io.Reader) (err error)
func (*PlayerCommand) Encode ¶ added in v0.19.0
func (p *PlayerCommand) Encode(c *proto.PacketContext, wr io.Writer) error
func (*PlayerCommand) SignedContainer ¶ added in v0.19.0
func (p *PlayerCommand) SignedContainer( signer crypto.IdentifiedKey, sender uuid.UUID, mustSign bool, ) (*crypto.SignedChatCommand, error)
type PlayerListItem ¶
type PlayerListItem struct { Action PlayerListItemAction Items []PlayerListItemEntry PlayerKey crypto.IdentifiedKey // 1.19+ }
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 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 ¶
func (r *ResourcePackRequest) Encode(c *proto.PacketContext, wr io.Writer) error
type ResourcePackResponse ¶ added in v0.19.0
type ResourcePackResponse struct { Hash string Status ResourcePackResponseStatus }
func (*ResourcePackResponse) Decode ¶ added in v0.19.0
func (r *ResourcePackResponse) Decode(c *proto.PacketContext, rd io.Reader) (err error)
func (*ResourcePackResponse) Encode ¶ added in v0.19.0
func (r *ResourcePackResponse) Encode(c *proto.PacketContext, wr io.Writer) error
type ResourcePackResponseStatus ¶ added in v0.19.0
type ResourcePackResponseStatus int
const ( SuccessfulResourcePackResponseStatus ResourcePackResponseStatus = iota DeclinedResourcePackResponseStatus FailedDownloadResourcePackResponseStatus AcceptedResourcePackResponseStatus )
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+ LastDeathPosition *DeathPosition // 1.19+ }
type ServerChatPreview ¶ added in v0.19.0
func (*ServerChatPreview) Decode ¶ added in v0.19.0
func (p *ServerChatPreview) Decode(c *proto.PacketContext, rd io.Reader) (err error)
func (*ServerChatPreview) Encode ¶ added in v0.19.0
func (p *ServerChatPreview) Encode(c *proto.PacketContext, wr io.Writer) error
type ServerData ¶ added in v0.19.0
type ServerData struct { Description component.Component // nil-able Favicon favicon.Favicon // may be empty PreviewsChat bool SecureChatEnforced bool // Added in 1.19.1 }
func (*ServerData) Decode ¶ added in v0.19.0
func (s *ServerData) Decode(c *proto.PacketContext, rd io.Reader) (err error)
func (*ServerData) Encode ¶ added in v0.19.0
func (s *ServerData) Encode(c *proto.PacketContext, wr io.Writer) error
type ServerLogin ¶
type ServerLogin struct { Username string PlayerKey crypto.IdentifiedKey // 1.19+ 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 ServerPlayerChat ¶ added in v0.19.0
type ServerPlayerChat struct { Component component.Component UnsignedComponent component.Component // nil-able Type int Sender uuid.UUID SenderName component.Component TeamName component.Component // nil-able Expiry time.Time }
func (*ServerPlayerChat) Decode ¶ added in v0.19.0
func (s *ServerPlayerChat) Decode(c *proto.PacketContext, rd io.Reader) (err error)
func (*ServerPlayerChat) Encode ¶ added in v0.19.0
func (s *ServerPlayerChat) Encode(c *proto.PacketContext, wr io.Writer) 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) Decode(_ *proto.PacketContext, _ io.Reader) error
func (StatusRequest) Encode ¶
func (StatusRequest) Encode(_ *proto.PacketContext, _ io.Writer) error
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 SystemChat ¶ added in v0.19.0
type SystemChat struct { Component component.Component Type MessageType }
func (*SystemChat) Decode ¶ added in v0.19.0
func (p *SystemChat) Decode(c *proto.PacketContext, rd io.Reader) (err error)
func (*SystemChat) Encode ¶ added in v0.19.0
func (p *SystemChat) Encode(c *proto.PacketContext, wr io.Writer) error
type TabCompleteOffer ¶ added in v0.12.0
type TabCompleteRequest ¶ added in v0.12.0
type TabCompleteRequest struct { Command string TransactionID int AssumeCommand bool HasPosition bool Position int64 }
func (*TabCompleteRequest) Decode ¶ added in v0.12.0
func (t *TabCompleteRequest) Decode(c *proto.PacketContext, rd io.Reader) (err error)
func (*TabCompleteRequest) Encode ¶ added in v0.12.0
func (t *TabCompleteRequest) Encode(c *proto.PacketContext, wr io.Writer) error
type TabCompleteResponse ¶ added in v0.12.0
type TabCompleteResponse struct { TransactionID int Start int Length int Offers []TabCompleteOffer }
func (*TabCompleteResponse) Decode ¶ added in v0.12.0
func (t *TabCompleteResponse) Decode(c *proto.PacketContext, rd io.Reader) (err error)
func (*TabCompleteResponse) Encode ¶ added in v0.12.0
func (t *TabCompleteResponse) Encode(c *proto.PacketContext, wr io.Writer) error