Documentation ¶
Overview ¶
Package protocol contains utilities for interacting with Minecraft's network protocol.
Index ¶
- Constants
- func ReadBool(r io.ByteReader) (bool, error)
- func ReadFloat32(r io.Reader) (float32, error)
- func ReadFloat64(r io.Reader) (float64, error)
- func ReadString(r Reader) (string, error)
- func ReadUint16(r io.Reader) (uint16, error)
- func ReadUint32(r io.Reader) (uint32, error)
- func ReadUint64(r io.Reader) (uint64, error)
- func ReadVarInt(r io.ByteReader) (int32, error)
- func VarIntSize(v int32) int
- func WriteBool(w io.ByteWriter, v bool) error
- func WriteByteArray(w Writer, b []byte) error
- func WriteChat(w Writer, v *chat.Msg) error
- func WriteFloat32(w io.Writer, v float32) error
- func WriteFloat64(w io.Writer, v float64) error
- func WriteString(w Writer, s string) error
- func WriteUint16(w io.Writer, v uint16) error
- func WriteUint32(w io.Writer, v uint32) error
- func WriteUint64(w io.Writer, v uint64) error
- func WriteVarInt(w io.ByteWriter, v int32) error
- type Reader
- type State
- type Writer
Constants ¶
View Source
const (
// VarIntMaxBytes is the maximum number of bytes required to represent a single VarInt.
VarIntMaxBytes = 5
)
Variables ¶
This section is empty.
Functions ¶
func ReadString ¶
func ReadVarInt ¶
func ReadVarInt(r io.ByteReader) (int32, error)
ReadVarInt reads a single VarInt from an io.ByteReader.
func VarIntSize ¶
VarIntSize returns the number of bytes required to write the given value as a VarInt.
func WriteByteArray ¶
func WriteString ¶
func WriteVarInt ¶
func WriteVarInt(w io.ByteWriter, v int32) error
WriteVarInt writes a single VarInt to io.ByteWriter.
Types ¶
type Reader ¶
type Reader interface { io.Reader io.ByteReader }
Reader combines all interfaces needed to be able to read any datatype in the Minecraft protocol.
type State ¶
type State uint8
State represents the state of the protocol.
const ( // StateHandshake is the initial state. StateHandshake State = iota // StateStatus is used when a client wants to request information to display in the server list menu. StateStatus // StateLogin is used when the client wants to authenticate. StateLogin // StatePlay is used after successful authentication and a player instance has been created. StatePlay )
type Writer ¶
type Writer interface { io.Writer io.ByteWriter io.StringWriter }
Writer combines all interfaces needed to be able to write any datatype in the Minecraft protocol.
Click to show internal directories.
Click to hide internal directories.