Skip to content

A Minecraft protocol library for clients and servers

Notifications You must be signed in to change notification settings

aimjel/mine-net

Repository files navigation

Minecraft Protocol Library for Go

Efficient Minecraft protocol integration in Go. Send, receive, and manipulate packets with its built-in connection class. TCP listener manages status and login states, complete with full encryption and compression support.

Installation

go get github.com/aimjel/minecraft

Simple server with PLAY ready connections

package main

import (
	"fmt"
	"github.com/aimjel/minecraft"
	"github.com/aimjel/minecraft/packet"
)

func main() {
	lc := minecraft.ListenConfig{
		OnlineMode:           true,//enables server encryption
		CompressionThreshold: 0, //compresses everything!
		Status:               minecraft.NewStatus(minecraft.Version{Protocol: 763}, 10, "someone had todo it"),
	}

	l, err := lc.Listen("localhost:25565")
	if err != nil {
		panic(err)
	}

	for {
		c, err := l.Accept()
		if err != nil {
			fmt.Printf("main thread|server: %v", err)
			return
		}

		if err := c.SendPacket(&packet.JoinGame{
			DimensionNames: []string{"minecraft:overworld"},
			DimensionName:  "minecraft:overworld",
		}); err != nil {
			c.Close(err)
		}

		if err := c.SendPacket(&packet.PlayerPositionLook{}); err != nil {
			c.Close(err)
		}
	}
}

About

A Minecraft protocol library for clients and servers

Topics

Resources

Stars

Watchers

Forks

Languages