Minecraft Bedrock Edition server software written in Go

image

Dragonfly

Dragonfly is a heavily asynchronous server software for Minecraft Bedrock Edition written in Go. It was written with scalability and simplicity in mind and aims to make the process of setting up a server and modifying it easy. Unlike other Minecraft server software, Dragonfly is generally used as a library to extend.

Discord Banner 2

Getting started

Running Dragonfly requires at least Go 1.16. After starting the server through one of the methods below, ctrl+c may be used to shut down the server. Also check out the wiki for more detailed info.

Installation as library

go mod init github.com/
   
    /
    
     
go get github.com/df-mc/dragonfly

    
   

SetupLibrary

Installation of the latest commit

git clone https://github.com/df-mc/dragonfly
cd dragonfly
go run main.go

SetupClone

Developer info

Go Reference

Dragonfly features a well-documented codebase with an easy-to-use API. Documentation may be found here and in the subpackages found by clicking Directories.

Publishing your project on GitHub? Consider adding the #df-mc topic to your repository to improve visibility of your project.

Contributing

Contributions are very welcome! Issues, pull requests and feature requests are highly appreciated. Opening a pull request? Consider joining our Discord server to discuss your changes! Also have a read through the CONTRIBUTING.md for more info.

Owner
Dragonfly
Writing Go server software for Minecraft Bedrock Edition
Dragonfly
Comments
  • Ghost Block Appears

    Ghost Block Appears

    OS: MacOS Big Sur

    dragonfly: 614691ae18ddbcf96a6ed41171a6c7758c7561a9

    go: go version go1.17.5 darwin/amd64

    Hard to Express, There is a video and a demo code patch for the latest master commit

    At the end of video, I rejoin the server and then ghost block disappears. I express that to avoid misunderstood the action.

    Video: https://streamable.com/xkrzpq

    Sorry for my bad English.

    diff --git a/main.go b/main.go
    index 1ea18b4..ed9ba85 100644
    --- a/main.go
    +++ b/main.go
    @@ -3,7 +3,13 @@ package main
     import (
     	"fmt"
     	"github.com/df-mc/dragonfly/server"
    +	"github.com/df-mc/dragonfly/server/block/cube"
    +	"github.com/df-mc/dragonfly/server/event"
    +	"github.com/df-mc/dragonfly/server/player"
     	"github.com/df-mc/dragonfly/server/player/chat"
    +	"github.com/df-mc/dragonfly/server/world"
    +	"github.com/df-mc/dragonfly/server/world/particle"
    +	"github.com/go-gl/mathgl/mgl64"
     	"github.com/pelletier/go-toml"
     	"github.com/sirupsen/logrus"
     	"io/ioutil"
    @@ -29,8 +35,10 @@ func main() {
     	}
     
     	for {
    -		if _, err := srv.Accept(); err != nil {
    +		if p, err := srv.Accept(); err != nil {
     			return
    +		} else {
    +			p.Handle(&Handler{player: p})
     		}
     	}
     }
    @@ -57,3 +65,20 @@ func readConfig() (server.Config, error) {
     	}
     	return c, nil
     }
    +
    +type Handler struct {
    +	player.NopHandler
    +	player *player.Player
    +}
    +
    +func (h Handler) HandleMove(ctx *event.Context, newPos mgl64.Vec3, _ float64, _ float64) {
    +	blockPos := newPos.Add(mgl64.Vec3{0, -1, 0})
    +	h.player.SendPopup(fmt.Sprintf("You are standing on %T", h.player.World().Block(cube.PosFromVec3(blockPos))))
    +	h.player.World().AddParticle(blockPos, particle.BlockForceField{})
    +}
    +
    +func (h Handler) HandleBlockPlace(ctx *event.Context, pos cube.Pos, b world.Block) {
    +	ctx.After(func(c bool) {
    +		h.player.World().BreakBlock(pos)
    +	})
    +}
    
    
  • Standard for Dragonfly  module

    Standard for Dragonfly module

    Introduction

    Reusing someone else's code is good programming practice.

    It will be great if the Dragonfly developers, who do not want to add their changes to the Dragonfly code (for various reasons), will create their add-ons according to some standard. For example using the "plugin" package.

    My suggestion

    When I want to write a separate module for Dragonfly, I make a separate package with init functions. Then, in main.go, I import the modules I need using the "stub"

    What's you mind about it? Wait for comments

  • Implement AdventureSettings & PlayerSkin packet & Sandstone

    Implement AdventureSettings & PlayerSkin packet & Sandstone

    Changes:

    • Handle the AdventureSettings packet
    • Flying related functions
    • Added player scaling
    • Added updating player skin
    • Handle the PlayerSkin packet (So other players see when you change your skin ingame)
    • Implemented Sandstone
  • Implement projectiles

    Implement projectiles

    There's no projectile on DF for the moment and.. for servers like mine where pvp is based on splashing potions we're kind of stuck and can't really release my server.

  • Introduce new form API

    Introduce new form API

    This new form API is much easiler to use and simpler than old one

    Examples

    Menu

    f := form.NewMenu("Choose an item").
    	WithBody("You can choose an item").
    	Button(form.NewButton("Diamond Sword", "textures/items/diamond_sword.png"), func(s form.Submitter) {
    		s.(*player.Player).Message("You selected diamond sword")
    	}).
    	Button(form.NewButton("Egg", "textures/items/egg.png"), func(s form.Submitter) {
    		s.(*player.Player).Message("You selected egg")
    	}).
    	OnClose(func(s form.Submitter) {
    		s.(*player.Player).Message("Why don't choose")
    	})
    p.SendForm(f)
    

    1

    Modal

    f := form.NewModal().
    	WithBody("Are you sure?").
    	WithButton1(form.YesButton(), nil).
    	WithButton2(form.NoButton(), func(s form.Submitter) {
    		s.(*player.Player).Message(":(")
    	})
    p.SendForm(f)
    

    2

    Custom

    f := form.NewCustom("Feedback").
    	WithElements(
    		form.NewInput("Reason", "", "reason"),
    		form.NewToggle("???", false),
    	).OnSubmit(func(p form.Submitter, reason string, satisfied bool) {})
    p.SendForm(f)
    

    3

  • Area cloud effect does not behave like vanilla

    Area cloud effect does not behave like vanilla

    Eg: In this implementation the cloud lasts only about 15 seconds, when in fact it should last about 30 seconds.

    I have described some of these behaviors in: https://github.com/pmmp/PocketMine-MP/pull/5276#issuecomment-1236198936

  • Commands are resent after the player leaves

    Commands are resent after the player leaves

    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0xa153d1]
    
    goroutine 95 [running]:
    velvet/session.(*Session).HasFlag(...)
            /root/velvet/session/session.go:91
    velvet/commands.checkPerms(...)
            /root/velvet/commands/command.go:62
    velvet/commands.checkAdmin(...)
            /root/velvet/commands/command.go:52
    velvet/commands.Transfer.Allow(...)
            /root/velvet/commands/transfer.go:34
    github.com/df-mc/dragonfly/server/cmd.Command.Runnables({{0xc000c4c018, 0x1, 0x1}, {0xc75362, 0x8}, {0xc8b109, 0x26}, {0xc0005f5540, 0x39}, {0x0, ...}}, ...)
            /root/go/pkg/mod/github.com/df-mc/[email protected]/server/cmd/command.go:205 +0xe4
    github.com/df-mc/dragonfly/server/session.(*Session).resendCommands(0xc000a87a00, 0xc0022ef470)
            /root/go/pkg/mod/github.com/df-mc/[email protected]/server/session/command.go:130 +0x198
    github.com/df-mc/dragonfly/server/session.(*Session).sendCommands(0xc0005f6000, 0xc0003bc4e0)
            /root/go/pkg/mod/github.com/df-mc/[email protected]/server/session/session.go:337 +0x179
    created by github.com/df-mc/dragonfly/server/session.(*Session).handlePackets
            /root/go/pkg/mod/github.com/df-mc/[email protected]/server/session/session.go:275 +0x165
    exit status 2
    
  • Rejoining a server crashes the client

    Rejoining a server crashes the client

    Whenever I join my df server, and then disconnect and rejoin my client will crash after a few seconds. This does not seem to happen if I first restart the server before rejoining.

    mc: v1.18.0.2 windows 10 edition df version: commit 355b5b4aa373a4f853d967d675f91bef438ee57c

  • add command.Allow() function

    add command.Allow() function

    As mentioned in the documentation of the function, this function essentially checks if the source can use at least one of the Runnables of the command. An important use for this is for example checking whether or not a command should be included in a /help command (if you implement a custom version of this) Another use could be for example if you have a commandSpy feature and you want to exclude commands that the player does not have access to.

    Currently there is already a way to check this that does essentially the same by checking if len(command.Params(source)) == 0 but I do not think that is very intuitive in my opinion.

  • Some items are sometimes incorrect in the inventory

    Some items are sometimes incorrect in the inventory

    Sometimes, some of the items displayed in the (creative) inventory are incorrect. In such cases, honeycombs are displayed as a bottle of honey, warped fungus on a sticks are displayed as chains. (Potentially more of such items.)

    This was reproduced both by me and @DaPigGuy. It seems to fix itself automatically when leaving and joining again. Maybe something wrong with the item runtime IDs. I am not sure what could be the cause of this. Item runtime IDs are consistent for as long as the server is running (and technically even afterwards). Multiple players can experience and not experience the bug simultaneously.

  • Keep Inventory

    Keep Inventory

    I would like to control dropContent in Player#kill() when a player dies. I think it is appropriate to add the flag to HandleDeath() like:

    func (h *MyHandler) HandleDeath(drop *bool, src world.DamageSource) {}
    
  • Implement UpdateQuery

    Implement UpdateQuery

    Not sure how exactly to explain this but, a way to modify the query count of players on the server would be useful, for the people using hubs so they can display count of the full network, as people are less likely to join if it says ‘0/1’

  • implement frosted ice and frost walker

    implement frosted ice and frost walker

    This PR implements frosted ice and frost walker as defined by the linked pages.

    Some features of frost walker are currently impossible to implement:

    • Foxes can pick up boots with frost walker, but foxes do not exist in Dragonfly
    • Frost walker prevents damage from campfires and magma blocks when stepped on, but neither exist in Dragonfly

    Currently, the main function contains code that spawns players with boots enchanted with frost walker one and two, and a bucket of water, for testing purposes.

  • Add back single command target

    Add back single command target

    Many commands require a single target such as things like ban, setrank, mute, etc. Having to treat every command as multiple targets is very inconvenient, this was discussed before and I said I would add it but got busy

  • Implement curse of binding

    Implement curse of binding

    This PR implements the curse of binding enchantment.

    • Items that implement the item.Armour interface can be enchanted with the curse of binding
    • Items with the curse of binding equipped in the armour inventory cannot be removed by inventory interaction
    • Items with the curse of binding cannot have the enchantment removed through the use of a grindstone
    • The cost has been set at 0 because this enchantment is not obtainable through an enchanting table
    • Players in creative mode bypass the curse of binding
mcstatusgo is a pure Go Minecraft service status checker for Java edition Minecraft servers

mcstatusgo is a pure Go Minecraft service status checker for Java edition Minecraft servers. mcstatusgo supports requesting information through the status and query protocols.

Aug 12, 2022
Minecraft server made in go, faster and better!

ElytraGo Minecraft server made in go, faster and better! Project is in early stage, but I'm trying continuously update it with new lines of code :)) L

Dec 9, 2022
Minecraft server implementation using Golang

Deepslate Deepslate is a Minecraft server implementation in Go. Deepslate if WIP and currently not available for installation Goals First implementati

Nov 19, 2021
Tetra3D is a 3D software renderer written in Go and Ebiten and made for games.
Tetra3D is a 3D software renderer written in Go and Ebiten and made for games.

Tetra3D Tetra3D Docs Support If you want to support development, feel free to check out my itch.io / Steam / Patreon. I also have a Discord server her

Dec 20, 2022
Go Minecraft Client
Go Minecraft Client

Steven Not actively maintained anymore A work in progress Minecraft client in Go. Don't expect it to go anywhere, just doing this for fun. Images Buil

Dec 23, 2022
⛏ 🐹 Minecraft Protocol implementation in Go
⛏ 🐹 Minecraft Protocol implementation in Go

illustration by @talentlessguy Install Go 1.16.x is required to use this library go get github.com/BRA1L0R/go-mcproto Opening a connection client := m

Sep 20, 2022
Quick and dirty Minecraft player head to SVG converter

Head SVG Quick and dirty Minecraft player head to SVG converter. Can be used to generate player head icons. Usage usage: Head SVG [-h|--help] -n|--nam

May 29, 2022
a framework in golang for game server or app server
a framework in golang for game server or app server

einx a framework in golang for game server or app server. a example server for einx (https://github.com/Cyinx/game_server_einx) Features User-Friendly

Dec 8, 2022
A lightweight and efficient messaging gateway server for distributed game servers, written in Go.

Overview channeld is an open source, light-weight and efficient messaging gateway server designed for distributed game servers (typically MMO) and oth

Aug 8, 2022
Online multiplayer board game server written in Go, using WebSockets.

BfH Server The Battle for Hermannia is a board game created as a gift by the father of hermannm, a developer of this project. This digital edition of

Nov 7, 2022
A Game Server Skeleton in golang.
A Game Server Skeleton in golang.

A game server skeleton implemented with golang. 注意(NOTICE) 欢迎加入QQ群: 459420581 (Gopher成都,讨论一切与go有关的话题) gonet/2 gonet1已停止维护(I no longer maintain this, p

Dec 26, 2022
Scalable Distributed Game Server Engine with Hot Swapping in Golang
Scalable Distributed Game Server Engine with Hot Swapping in Golang

GoWorld Scalable Distributed Game Server Engine with Hot Reload in Golang Features Architecture Introduction Get GoWorld Manage GoWorld Servers Demos

Dec 25, 2022
A game server framework in Go (golang)

Leaf A pragmatic game server framework in Go (golang). Features Extremely easy to use Reliable Multicore support Modularity Community QQ 群:376389675 D

Jan 2, 2023
Lightweight, facility, high performance golang based game server framework
Lightweight, facility, high performance golang based game server framework

Nano Nano is an easy to use, fast, lightweight game server networking library for Go. It provides a core network architecture and a series of tools an

Jan 1, 2023
Scalable game server framework with clustering support and client libraries for iOS, Android, Unity and others through the C SDK.

pitaya Pitaya is an simple, fast and lightweight game server framework with clustering support and client libraries for iOS, Android, Unity and others

Jan 2, 2023
Dedicated Game Server Hosting and Scaling for Multiplayer Games on Kubernetes
Dedicated Game Server Hosting and Scaling for Multiplayer Games on Kubernetes

Agones is a library for hosting, running and scaling dedicated game servers on Kubernetes. Agones, is derived from the Greek word agōn which roughly t

Jan 6, 2023
A game server side framework with both web API and realtime communication.

HAYABUSA Framework Hayabusa is a server side framework for Japan-like social games. Easy to understand and use for beginners Powerful controller, flex

May 21, 2022
game server by golang

使用golang开发的框架 How to use ? 参考 main.go Features kernel使用channel 和 goroutine 模拟的Actor模式 使用channel 模拟的消息队列 kernel.Context内部实现了一个链表,用于发起call的时候,由于自身channe

Dec 27, 2022
This is a "simple" game server. Main functionalities are matching and establishing a connection between players
This is a

Game Server This is a "simple" game server. Main functionalities are matching and establishing a connection between players How to Run? run the server

Aug 28, 2022