protocol

package
Version: v0.0.0-...-821fc04 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

package protocol describes the basic types needed to work with the Minecraft protocol this server is being developed for protocol version 498 (mc version 1.14.4)

Index

Constants

View Source
const (
	Handshaking = iota
	Login
	Play
	Status
)
View Source
const (
	Version_1_14_4 = 498
)

Variables

View Source
var DefaultParseMap = ParseMap{
	Handshaking: {
		0x00: ParseHandshake,
	},
	Login: {
		0x00: ParseLoginStart,
		0x01: ParseEncryptionResponse,
	},
	Play: {
		0x05: ParseClientSettings,
	},
}

DefaultParseMap maps the state and packet id to the parser for each serverbound packet

View Source
var (
	ErrWrongPacketType = errors.New("received wrong packet type")
)

Functions

This section is empty.

Types

type Packet

type Packet interface {
	// ID returns the Packet ID. Since some packets can be both serverbound and clientbound with different IDs
	// it needs a sBound boolean to know which ID to return. If true, returns the serverbound ID.
	ID(sBound bool) codec.VarInt
	// Decode fills the packet fields by reading from the reader r
	Decode(r io.Reader) error
	// Encode writes packet data to writer w
	Encode(w io.Writer) error
}

Packet describes a Minecraft packet.

func ParseClientSettings

func ParseClientSettings(b []byte) (Packet, error)

func ParseEncryptionResponse

func ParseEncryptionResponse(b []byte) (Packet, error)

func ParseHandshake

func ParseHandshake(b []byte) (Packet, error)

func ParseLoginStart

func ParseLoginStart(b []byte) (Packet, error)

type PacketParser

type PacketParser func([]byte) (Packet, error)

PacketParser is a function that takes in packet data and returns a specific type of packet based on the id, conforming to the Packet interface

type ParseMap

type ParseMap map[State]map[codec.VarInt]PacketParser

NOTE: might implement using reflection.

type State

type State int

State represents the various connection states

Directories

Path Synopsis
From https://play.golang.org/p/LTbId4b6M2 also many thanks to github.com/Tnze/go-mc
From https://play.golang.org/p/LTbId4b6M2 also many thanks to github.com/Tnze/go-mc
Package codec implements the various minecraft protocol types
Package codec implements the various minecraft protocol types
Package packet implements the various packets of the minecraft protocol Reference: https://wiki.vg/index.php?title=Protocol&oldid=15289
Package packet implements the various packets of the minecraft protocol Reference: https://wiki.vg/index.php?title=Protocol&oldid=15289

Jump to

Keyboard shortcuts

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