minecomm

package module
v0.0.0-...-f0cfbad Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

minecomm

A library used for communication using the Minecraft TCP Protocol

To Do List

  • Datatypes setup (VarInt, VarLong etc)
  • Packet structure setup
  • Packet sending and receiving
  • Packet handling

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Boolean

type Boolean bool

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient() *Client

func (*Client) Connect

func (mc *Client) Connect(ip string, port uint16, player entities.Player, protocolVersion int32) error

Connect to a server addr format must be "ip:port"

func (*Client) GetAddr

func (mc *Client) GetAddr() string

func (*Client) IsCompressionEnabled

func (mc *Client) IsCompressionEnabled() bool

func (*Client) ReceivePacket

func (mc *Client) ReceivePacket() (*packets.MinecraftPacket, error)

ReceivePacket receives and deserializes a packet from the con, uncompressing it if necessary

func (*Client) ReceiveRawPacket

func (mc *Client) ReceiveRawPacket() (*packets.MinecraftRawPacket, error)

ReceiveRawPacket reads a raw packet from the con but doesn't deserialize neither uncompress it

func (*Client) WritePacket

func (mc *Client) WritePacket(packet SerializablePacket) error

WritePacket calls SerializeData and then calls WriteRawPacket

func (*Client) WriteRawPacket

func (mc *Client) WriteRawPacket(rawPacket *packets.MinecraftRawPacket) error

WriteRawPacket takes a rawpacket as input and serializes it in the con

type Double

type Double float64

type Float

type Float float32

type Identifier

type Identifier string //max length: 32767

type Int

type Int int32

type JSONTextComponent

type JSONTextComponent string

type Long

type Long int64

type SerializablePacket

type SerializablePacket interface {
	// SerializeData takes an interface pointer as input and serializes all the fields in the
	// data buffer. It can and will return an error in case of invalid data
	SerializeData(inter interface{}) error

	SerializeCompressed(writer io.Writer, compressionThreshold int) error
	SerializeUncompressed(writer io.Writer) error
}

SerializablePacket defines the standard methods that a struct should have in order to be serializable by the library

You can actually create your own methods as long as they respect this standard

type Short

type Short int16

type String

type String string

type TextComponent

type TextComponent string

type UnsignedByte

type UnsignedByte uint8

type UnsignedShort

type UnsignedShort uint16

type VarInt

type VarInt int32

VarInt is a variable-length integer encoding used by Minecraft

Jump to

Keyboard shortcuts

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