protocol

package
v0.0.0-...-9debb76 Latest Latest
Warning

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

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

Documentation

Overview

Package protocol contains utilities for interacting with Minecraft's network protocol.

Index

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 ReadBool

func ReadBool(r io.ByteReader) (bool, error)

func ReadFloat32

func ReadFloat32(r io.Reader) (float32, error)

func ReadFloat64

func ReadFloat64(r io.Reader) (float64, error)

func ReadString

func ReadString(r Reader) (string, error)

func ReadUint16

func ReadUint16(r io.Reader) (uint16, error)

func ReadUint32

func ReadUint32(r io.Reader) (uint32, error)

func ReadUint64

func ReadUint64(r io.Reader) (uint64, error)

func ReadVarInt

func ReadVarInt(r io.ByteReader) (int32, error)

ReadVarInt reads a single VarInt from an io.ByteReader.

func VarIntSize

func VarIntSize(v int32) int

VarIntSize returns the number of bytes required to write the given value as a VarInt.

func WriteBool

func WriteBool(w io.ByteWriter, v bool) error

func WriteByteArray

func WriteByteArray(w Writer, b []byte) error

func WriteChat

func WriteChat(w Writer, v *chat.Msg) error

func WriteFloat32

func WriteFloat32(w io.Writer, v float32) error

func WriteFloat64

func WriteFloat64(w io.Writer, v float64) error

func WriteString

func WriteString(w Writer, s string) error

func WriteUint16

func WriteUint16(w io.Writer, v uint16) error

func WriteUint32

func WriteUint32(w io.Writer, v uint32) error

func WriteUint64

func WriteUint64(w io.Writer, v uint64) error

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.

Jump to

Keyboard shortcuts

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