MinecraftLightServer

package module
v0.0.0-...-2c82e26 Latest Latest
Warning

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

Go to latest
Published: May 25, 2021 License: MIT Imports: 11 Imported by: 0

README

MinecraftLightServer

This is a Proof of Concept of a simple Minecraft server written in Go, that has a simple multiplayer world.

Version

This server actually supports only Minecraft 1.16.5 clients.

Purpose

This is a very simple server, which can help those who are making one to better understand how the basic things that compose it interact with each other.

Thanks

This project was inspired by:

  • ESP32 Minecraft Server, a very simple Minecraft server written in C for the ESP32 development board.
  • Go-mc, a Minecraft library written in Go.
  • wiki vg, a website that has the documentation for every Minecraft package.

Everything has been adapted and rewritten to make code easy to understand.

Screenshots

MinecraftLightServer chunk MinecraftLightServer chat MinecraftLightServer player moved

Changelog

  • There can be only one username online at the same time
  • Concurrent handling of clients
  • Concurrent handling of client packets
  • Support for player running
  • Detection of a disconnected player is immediate
Changes for the future
  • Support for chunk generation
  • Support for mobs
  • Game changes saving
  • Support for more client packets
  • Plugins

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Angle

type Angle Byte

Angle is a rotation angle in steps of 1/256 of a full turn (360°).

func (*Angle) ReadFrom

func (a *Angle) ReadFrom(r io.Reader) (int64, error)

ReadFrom decodes an Angle.

func (Angle) WriteTo

func (a Angle) WriteTo(w io.Writer) (int64, error)

WriteTo encodes an Angle.

type Boolean

type Boolean bool

Boolean type (true = 0x01, false = 0x00).

func (*Boolean) ReadFrom

func (b *Boolean) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom decodes a Boolean.

func (Boolean) WriteTo

func (b Boolean) WriteTo(w io.Writer) (int64, error)

WriteTo encodes a Boolean.

type Byte

type Byte int8

Byte is signed 8-bit integer, two's complement.

func (*Byte) ReadFrom

func (b *Byte) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom decodes a Byte.

func (Byte) WriteTo

func (b Byte) WriteTo(w io.Writer) (n int64, err error)

WriteTo encodes a Byte.

type Double

type Double float64

A Double is a double-precision 64-bit IEEE 754 floating point number.

func (*Double) ReadFrom

func (d *Double) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom decodes a Double.

func (Double) WriteTo

func (d Double) WriteTo(w io.Writer) (n int64, err error)

WriteTo encodes a Double.

type Float

type Float float32

A Float is a single-precision 32-bit IEEE 754 floating point number.

func (*Float) ReadFrom

func (f *Float) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom decodes a Float.

func (Float) WriteTo

func (f Float) WriteTo(w io.Writer) (n int64, err error)

WriteTo encodes a Float.

type Int

type Int int32

Int is signed 32-bit integer, two's complement.

func (*Int) ReadFrom

func (i *Int) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom decodes an Int.

func (Int) WriteTo

func (i Int) WriteTo(w io.Writer) (int64, error)

WriteTo encodes an Int.

type Long

type Long int64

Long is signed 64-bit integer, two's complement.

func (*Long) ReadFrom

func (l *Long) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom decodes a Long.

func (Long) WriteTo

func (l Long) WriteTo(w io.Writer) (int64, error)

WriteTo encodes a Long.

type Packet

type Packet struct {
	ID int32
	// contains filtered or unexported fields
}

Packet defines a Minecraft network data package +--------+-----------+------+ | Length | Packet ID | Data | +--------+-----------+------+

func NewPacket

func NewPacket(packetID int32, data ...io.WriterTo) *Packet

NewPacket creates a new packet using input data.

func (*Packet) Pack

func (pk *Packet) Pack(w io.Writer) error

Pack prepares a packet and write it to w writer interface.

func (*Packet) Read

func (pk *Packet) Read(p []byte) (n int, err error)

Read implements io.Reader interface for Packet.

func (*Packet) Unpack

func (pk *Packet) Unpack(r io.Reader) error

Unpack reads a packet from r reader interface.

func (*Packet) Write

func (pk *Packet) Write(p []byte) (n int, err error)

Write implements io.Writer interface for Packet.

type Player

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

Player is a single player that is currently in the server.

type Server

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

Server is a running Minecraft server.

func NewServer

func NewServer(portNumber ...string) *Server

NewServer creates a new Server using default port. portNumber is an optional argument and you have to leave it empty to use default port (25565).

func (*Server) Close

func (s *Server) Close() error

Close stops the server and close its components.

func (*Server) SetPort

func (s *Server) SetPort(portNumber string) error

SetPort changes port of the Minecraft server. Use it when server is running.

func (*Server) Start

func (s *Server) Start() error

Start starts the server using the current port.

type Short

type Short int16

Short is signed 16-bit integer, two's complement.

func (*Short) ReadFrom

func (s *Short) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom decodes a Short.

func (Short) WriteTo

func (s Short) WriteTo(w io.Writer) (int64, error)

WriteTo encodes a Short.

type String

type String string

String is a sequence of Unicode values.

func (*String) ReadFrom

func (s *String) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom decodes a String.

func (String) WriteTo

func (s String) WriteTo(w io.Writer) (n int64, err error)

WriteTo encodes a String.

type UUID

type UUID uuid.UUID

UUID is an unsigned 128-bit integer.

func (*UUID) ReadFrom

func (u *UUID) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom decodes an UUID.

func (UUID) WriteTo

func (u UUID) WriteTo(w io.Writer) (n int64, err error)

WriteTo encodes an UUID.

type UnsignedByte

type UnsignedByte uint8

UnsignedByte is unsigned 8-bit integer.

func (*UnsignedByte) ReadFrom

func (u *UnsignedByte) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom decodes an UnsignedByte.

func (UnsignedByte) WriteTo

func (u UnsignedByte) WriteTo(w io.Writer) (n int64, err error)

WriteTo encodes an UnsignedByte.

type UnsignedShort

type UnsignedShort uint16

UnsignedShort is unsigned 16-bit integer.

func (*UnsignedShort) ReadFrom

func (us *UnsignedShort) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom decodes an UnsignedShort.

func (UnsignedShort) WriteTo

func (us UnsignedShort) WriteTo(w io.Writer) (int64, error)

WriteTo encodes an UnsignedShort.

type VarInt

type VarInt int32

VarInt is variable-length data encoding a two's complement signed 32-bit integer.

func (*VarInt) ReadFrom

func (v *VarInt) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom decodes a VarInt.

func (VarInt) WriteTo

func (v VarInt) WriteTo(w io.Writer) (n int64, err error)

WriteTo encodes a VarInt.

type VarLong

type VarLong int64

VarLong is variable-length data encoding a two's complement signed 64-bit integer.

func (*VarLong) ReadFrom

func (v *VarLong) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom decodes a VarLong.

func (VarLong) WriteTo

func (v VarLong) WriteTo(w io.Writer) (n int64, err error)

WriteTo encodes a VarLong.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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