packet

package
v0.0.0-...-889dc37 Latest Latest
Warning

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

Go to latest
Published: May 17, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const ChatMessagePacketID = 0x0f
View Source
const ClientSettingsPacketID int32 = 0x05
View Source
const HandshakePacketID int32 = 0x00
View Source
const JoinGamePacketID int32 = 0x26
View Source
const LoginDisconnectPacketID int32 = 0x00
View Source
const LoginStartPacketID int32 = 0x00
View Source
const LoginSuccessPacketID = 0x02
View Source
const MaxPacketLength = 1048576
View Source
const PingPacketID = 0x01
View Source
const PlayerPositionLookPacketID int32 = 0x36
View Source
const PluginMessagePacketID int32 = 0x19
View Source
const PongPacketID int32 = 0x01
View Source
const ServerInfoPacketID int32 = 0x00
View Source
const ServerQueryPacketID int32 = 0x00

Variables

View Source
var (
	ErrInvalidPacketLength = errors.New("packet has a malformed length")
)

Functions

This section is empty.

Types

type ChatMessagePacket

type ChatMessagePacket struct {
	Message  game.TextComponent
	Position enc.Byte
}

ChatMessagePacket is sent by the server for incoming chat messages https://wiki.vg/Protocol?oldid=16067#Chat_Message_.28clientbound.29

func (*ChatMessagePacket) Direction

func (c *ChatMessagePacket) Direction() Direction

func (*ChatMessagePacket) ID

func (c *ChatMessagePacket) ID() int32

func (*ChatMessagePacket) Read

func (c *ChatMessagePacket) Read(r io.Reader) error

func (*ChatMessagePacket) State

func (*ChatMessagePacket) String

func (c *ChatMessagePacket) String() string

func (*ChatMessagePacket) Write

func (c *ChatMessagePacket) Write(w io.Writer) error

type ClientSettingsPacket

type ClientSettingsPacket struct {
	Lang               enc.String
	ViewDistance       enc.Byte
	ChatVisibility     enc.VarInt
	EnableChatColors   enc.Bool
	DisplayedSkinParts enc.UnsignedByte
	MainHand           game.Hand
}

ClientSettingsPacket is sent by the client to inform the server of the (updated) client settings https://wiki.vg/Protocol?oldid=16067#Client_Settings

func (*ClientSettingsPacket) Direction

func (c *ClientSettingsPacket) Direction() Direction

func (*ClientSettingsPacket) ID

func (c *ClientSettingsPacket) ID() int32

func (*ClientSettingsPacket) Read

func (c *ClientSettingsPacket) Read(r io.Reader) error

func (*ClientSettingsPacket) State

func (*ClientSettingsPacket) String

func (*ClientSettingsPacket) String() string

func (*ClientSettingsPacket) Write

func (c *ClientSettingsPacket) Write(w io.Writer) error

type Direction

type Direction byte

Direction is the direction of a packet

const (
	ClientBound Direction = iota // client-bound
	ServerBound                  // server-bound
)

func (Direction) String

func (i Direction) String() string

type Encoding

type Encoding interface {
	Write(w io.Writer) error
	Read(r io.Reader) error
}

Encoding is a type that can be encoded

type HandshakePacket

type HandshakePacket struct {
	ProtoVer   enc.VarInt
	ServerAddr enc.String
	ServerPort enc.UnsignedShort
	NextState  game.ConnectionState
}

HandshakePacket is sent by the client to initiate a handshake by changing the connection state https://wiki.vg/Protocol?oldid=16067#Handshake

func (*HandshakePacket) Direction

func (h *HandshakePacket) Direction() Direction

func (*HandshakePacket) ID

func (h *HandshakePacket) ID() int32

func (*HandshakePacket) Read

func (h *HandshakePacket) Read(r io.Reader) error

func (*HandshakePacket) State

func (*HandshakePacket) String

func (*HandshakePacket) String() string

func (*HandshakePacket) Write

func (h *HandshakePacket) Write(w io.Writer) error

type Info

type Info struct {
	ID              int32
	Direction       Direction
	ConnectionState game.ConnectionState
}

Info is the info that uniquely identifies a packet

type JoinGamePacket

type JoinGamePacket struct {
	PlayerID            enc.Int
	GameMode            game.Mode
	Dimension           game.Dimension
	HashedSeed          enc.Long
	MaxPlayers          enc.UnsignedByte
	LevelType           enc.String `len:"16"`
	ViewDistance        enc.VarInt
	ReducedDebug        enc.Bool
	EnableRespawnScreen enc.Bool
}

JoinGamePacket is sent by the server to inform the client of various game & world parameters https://wiki.vg/Protocol?oldid=16067#Join_Game

func (*JoinGamePacket) Direction

func (j *JoinGamePacket) Direction() Direction

func (*JoinGamePacket) ID

func (j *JoinGamePacket) ID() int32

func (*JoinGamePacket) Read

func (j *JoinGamePacket) Read(r io.Reader) error

func (*JoinGamePacket) State

func (j *JoinGamePacket) State() game.ConnectionState

func (*JoinGamePacket) String

func (*JoinGamePacket) String() string

func (*JoinGamePacket) Write

func (j *JoinGamePacket) Write(w io.Writer) error

type LoginDisconnectPacket

type LoginDisconnectPacket struct {
	Reason game.TextComponent
}

LoginDisconnectPacket is sent by the server when the user is disconnected while they are logging in (e.g. banned) https://wiki.vg/Protocol?oldid=16067#Disconnect_.28login.29

func (*LoginDisconnectPacket) Direction

func (l *LoginDisconnectPacket) Direction() Direction

func (*LoginDisconnectPacket) ID

func (l *LoginDisconnectPacket) ID() int32

func (*LoginDisconnectPacket) Read

func (l *LoginDisconnectPacket) Read(r io.Reader) error

func (*LoginDisconnectPacket) State

func (*LoginDisconnectPacket) String

func (*LoginDisconnectPacket) String() string

func (*LoginDisconnectPacket) Write

func (l *LoginDisconnectPacket) Write(w io.Writer) error

type LoginStartPacket

type LoginStartPacket struct {
	Name enc.String
}

LoginStartPacket is sent by the client to start logging in https://wiki.vg/Protocol?oldid=16067#Login_Start

func (*LoginStartPacket) Direction

func (l *LoginStartPacket) Direction() Direction

func (*LoginStartPacket) ID

func (l *LoginStartPacket) ID() int32

func (*LoginStartPacket) Info

func (*LoginStartPacket) Info() Info

func (*LoginStartPacket) Read

func (l *LoginStartPacket) Read(r io.Reader) error

func (*LoginStartPacket) State

func (*LoginStartPacket) String

func (*LoginStartPacket) String() string

func (*LoginStartPacket) Write

func (l *LoginStartPacket) Write(w io.Writer) error

type LoginSuccessPacket

type LoginSuccessPacket struct {
	UUID     enc.UUID
	Username enc.String
}

LoginSuccessPacket is sent by the server when the login was successful https://wiki.vg/Protocol?oldid=16067#Login_Success

func (*LoginSuccessPacket) Direction

func (l *LoginSuccessPacket) Direction() Direction

func (*LoginSuccessPacket) ID

func (l *LoginSuccessPacket) ID() int32

func (*LoginSuccessPacket) Read

func (l *LoginSuccessPacket) Read(r io.Reader) error

func (*LoginSuccessPacket) State

func (*LoginSuccessPacket) String

func (*LoginSuccessPacket) String() string

func (*LoginSuccessPacket) Write

func (l *LoginSuccessPacket) Write(w io.Writer) error

type Packet

type Packet interface {
	fmt.Stringer
	Encoding
	ID() int32
	Direction() Direction
	State() game.ConnectionState
}

Packet is a packet with side-bound ID & direction that can be encoded and sent

type PingPacket

type PingPacket struct {
	Payload enc.Long
}

PingPacket is sent by the client to get a PongPacket response. https://wiki.vg/Protocol?oldid=16067#Ping

func (*PingPacket) Direction

func (p *PingPacket) Direction() Direction

func (*PingPacket) ID

func (p *PingPacket) ID() int32

func (*PingPacket) Read

func (p *PingPacket) Read(r io.Reader) error

func (*PingPacket) State

func (p *PingPacket) State() game.ConnectionState

func (*PingPacket) String

func (*PingPacket) String() string

func (*PingPacket) Write

func (p *PingPacket) Write(w io.Writer) error

type PlayerPositionLookPacket

type PlayerPositionLookPacket struct {
	X          enc.Double
	Y          enc.Double
	Z          enc.Double
	Yaw        enc.Float
	Pitch      enc.Float
	Flags      enc.Byte
	TeleportID enc.VarInt
}

PlayerPositionLookPacket is sent by the server to inform the client of its location https://wiki.vg/Protocol?oldid=16067#Player_Position_And_Look_.28clientbound.29

func (*PlayerPositionLookPacket) Direction

func (p *PlayerPositionLookPacket) Direction() Direction

func (*PlayerPositionLookPacket) ID

func (*PlayerPositionLookPacket) Read

func (*PlayerPositionLookPacket) State

func (*PlayerPositionLookPacket) String

func (*PlayerPositionLookPacket) String() string

func (*PlayerPositionLookPacket) Write

type PluginMessagePacket

type PluginMessagePacket struct {
	Channel game.Identifier
	Data    Encoding
}

PluginMessagePacket is sent by the client as part of a plugin's message channel https://wiki.vg/Protocol?oldid=16067#Plugin_Message_.28clientbound.29

func (*PluginMessagePacket) Direction

func (p *PluginMessagePacket) Direction() Direction

func (*PluginMessagePacket) ID

func (p *PluginMessagePacket) ID() int32

func (*PluginMessagePacket) Read

func (p *PluginMessagePacket) Read(r io.Reader) error

func (*PluginMessagePacket) State

func (*PluginMessagePacket) String

func (*PluginMessagePacket) String() string

func (*PluginMessagePacket) Write

func (p *PluginMessagePacket) Write(w io.Writer) error

type PongPacket

type PongPacket struct {
	Payload enc.Long
}

PongPacket is sent by the server as a response to a PingPacket. https://wiki.vg/Protocol?oldid=16067#Pong

func (*PongPacket) Direction

func (p *PongPacket) Direction() Direction

func (*PongPacket) ID

func (p *PongPacket) ID() int32

func (*PongPacket) Read

func (p *PongPacket) Read(r io.Reader) error

func (*PongPacket) State

func (p *PongPacket) State() game.ConnectionState

func (*PongPacket) String

func (*PongPacket) String() string

func (*PongPacket) Write

func (p *PongPacket) Write(w io.Writer) error

type ServerInfoPacket

type ServerInfoPacket struct {
	Response game.ServerInfo
}

ServerInfoPacket is sent by the server as a response to a ServerQueryPacket. https://wiki.vg/Protocol?oldid=16067#Response

func (*ServerInfoPacket) Direction

func (s *ServerInfoPacket) Direction() Direction

func (*ServerInfoPacket) ID

func (s *ServerInfoPacket) ID() int32

func (*ServerInfoPacket) Read

func (s *ServerInfoPacket) Read(r io.Reader) error

func (*ServerInfoPacket) State

func (*ServerInfoPacket) String

func (*ServerInfoPacket) String() string

func (*ServerInfoPacket) Write

func (s *ServerInfoPacket) Write(w io.Writer) error

type ServerQueryPacket

type ServerQueryPacket struct{}

ServerQueryPacket is sent by the client to query the Minecraft server for protocol version, message of the day and online player information. https://wiki.vg/Protocol?oldid=16067#Request

func (ServerQueryPacket) Direction

func (s ServerQueryPacket) Direction() Direction

func (ServerQueryPacket) ID

func (s ServerQueryPacket) ID() int32

func (*ServerQueryPacket) Read

func (s *ServerQueryPacket) Read(r io.Reader) error

func (ServerQueryPacket) State

func (*ServerQueryPacket) String

func (*ServerQueryPacket) String() string

func (*ServerQueryPacket) Write

func (s *ServerQueryPacket) Write(w io.Writer) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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