packet

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxServerBoundMessageLength = 256
)

Variables

View Source
var ErrEncodeOnly = errors.New("packet is only to be encoded")

Signifies that a packet is only meant to be encoded, no decoding.

Functions

This section is empty.

Types

type Chat

type Chat struct {
	Message string
	Type    MessagePosition
	Sender  uuid.UUID // 1.16+, and can 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
}

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
	AmbientLight       float32
	Shrunk, Natural, Ultrawarm, Ceiling, Skylight, PiglineSafe,
	DoBedsWork, DoRespawnAnchorsWork, Raids bool
	LogicalHeight              int32
	BurningBehaviourIdentifier string
	FixedTime                  *int64 // nil-able
	CreateDragonFight          *bool  // nil-able
}

func DecodeCompoundTagDimensionData

func DecodeCompoundTagDimensionData(toRead util.NBT) (*DimensionData, error)

func FromGameData

func FromGameData(toParse util.NBT) (mappings []*DimensionData, err error)

FromGameData decodes a CompoundTag storing a dimension registry.

func (*DimensionData) EncodeCompoundTag

func (d *DimensionData) EncodeCompoundTag() util.NBT

Encodes the Dimension data as nbt CompoundTag

type DimensionInfo

type DimensionInfo struct {
	RegistryId string
	LevelName  string
	Flat       bool
	DebugType  bool
}

type DimensionRegistry

type DimensionRegistry struct {
	Dimensions []*DimensionData
	LevelNames sets.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).

func (*DimensionRegistry) ToNBT

func (r *DimensionRegistry) ToNBT() util.NBT

ToNBT the stored Dimension registry as CompoundTag containing identifier:type mappings.

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

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(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
	VerifiedToken []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
	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 JoinGame

type JoinGame struct {
	EntityId          int
	Gamemode          int16
	Dimension         int
	PartialHashedSeed int64 // 1.15+
	Difficulty        int16
	MaxPlayers        int16
	LevelType         *string // nil-able: removed in 1.16+
	ViewDistance      int     // 1.14+
	ReducedDebugInfo  bool
	ShowRespawnScreen bool
	DimensionRegistry *DimensionRegistry // 1.16+
	DimensionInfo     *DimensionInfo     // 1.16+
	PreviousGamemode  int16              // 1.16+
}

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, r 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(c *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(c *proto.PacketContext, rd io.Reader) (err error)

func (*LoginPluginResponse) Encode

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

type MessagePosition

type MessagePosition byte

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

const (
	// The chat message will appear in the client's HUD.
	// These messages can be filtered out by the client.
	ChatMessage MessagePosition = iota
	// The chat message will appear in the client's HUD and can't be dismissed.
	SystemMessage
	// The chat message will appear above the player's main HUD.
	// This text format doesn't support many component features, such as hover events.
	ActionBarMessage
)

type ResourcePackRequest added in v0.0.2

type ResourcePackRequest struct {
	Url  string
	Hash string
}

func (*ResourcePackRequest) Decode added in v0.0.2

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

func (*ResourcePackRequest) Encode added in v0.0.2

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+
	PreviousGamemode     int16          // 1.16+
}

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 Title

type Title struct {
	Action                TitleAction
	Component             *string // nil-able
	FadeIn, Stay, FadeOut int
}

func NewHideTitle

func NewHideTitle(protocol proto.Protocol) *Title

func NewResetTitle

func NewResetTitle(protocol proto.Protocol) *Title

func (*Title) Decode

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

func (*Title) Encode

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

type TitleAction

type TitleAction int
const (
	SetTitle     TitleAction = 0
	SetSubtitle  TitleAction = 1
	SetActionBar TitleAction = 2
	SetTimes     TitleAction = 3
	Hide         TitleAction = 4
	Reset        TitleAction = 5

	// 1.11+ shifted the action enum by 1 to handle the action bar
	SetTimesOld TitleAction = 2
	HideOld     TitleAction = 3
	ResetOld    TitleAction = 4
)

Title packet actions

func HideTitleAction

func HideTitleAction(protocol proto.Protocol) TitleAction

func ResetTitleAction

func ResetTitleAction(protocol proto.Protocol) TitleAction

func TimesTitleAction

func TimesTitleAction(protocol proto.Protocol) TitleAction

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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