Minecraft Bedrock Edition server software written in Go

Overview

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.

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)
    +	})
    +}
    
    
    bug 
    opened by Mohamed587100 19
  • 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

    opened by ghost 12
  • 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
    opened by Suremeo 8
  • 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.

    feature 
    opened by RestartFU 7
  • 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
    
    bug 
    opened by Prim69 6
  • 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

    bug 
    opened by AndreasHGK 6
  • 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.

    hacktoberfest-accepted 
    opened by AndreasHGK 6
  • 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.

    bug 
    opened by Sandertv 6
  • 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) {}
    
    opened by UramnOIL 5
  • Support for the default flame particle

    Support for the default flame particle

    The current flame particle is actually a colored flame, the difference can be seen here. image The top particle is particle.Flame, while the bottom particle is an orange particle.ColouredFlame

    image image

    opened by Prim69 5
  • panic: runtime error: invalid memory address or nil pointer dereference

    panic: runtime error: invalid memory address or nil pointer dereference

    panic: runtime error: invalid memory address or nil pointer dereference
    [signal 0xc0000005 code=0x0 addr=0x18 pc=0xa32e69]
    
    goroutine 51 [running]:
    github.com/df-mc/dragonfly/server/internal/nbtconv.writeItemStack(0xc0005b8d20?, {0x2eba, {0x0, 0x0}, 0xe, {0x0, 0x0}, {0x0, 0x0, 0x0}, ...})
            C:/Users/Administrator/go/pkg/mod/github.com/df-mc/[email protected]/server/internal/nbtconv/write.go:42 +0xc9
    github.com/df-mc/dragonfly/server/internal/nbtconv.WriteItem({0x2eba, {0x0, 0x0}, 0xe, {0x0, 0x0}, {0x0, 0x0, 0x0}, 0x0, ...}, ...)
            C:/Users/Administrator/go/pkg/mod/github.com/df-mc/[email protected]/server/internal/nbtconv/write.go:21 +0x186
    github.com/df-mc/dragonfly/server/entity.NewItem({0x2eba, {0x0, 0x0}, 0xe, {0x0, 0x0}, {0x0, 0x0, 0x0}, 0x0, ...}, ...)
            C:/Users/Administrator/go/pkg/mod/github.com/df-mc/[email protected]/server/entity/item.go:31 +0x205
    github.com/df-mc/dragonfly/server/entity.(*Item).merge(0xc004276a80, 0x3fd0000000000000?, 0xc0042778c0, {0xc03bfcd35a163f4c, 0xc04db525abf09db7, 0xc03d9948e8b7b631})
            C:/Users/Administrator/go/pkg/mod/github.com/df-mc/[email protected]/server/entity/item.go:134 +0x43c
    github.com/df-mc/dragonfly/server/entity.(*Item).checkNearby(0xc004276a80, 0xbfd1830aea36d0b0?, {0xc03bfcd35a163f4c, 0xc04db525abf09db7, 0xc03d9948e8b7b631})
            C:/Users/Administrator/go/pkg/mod/github.com/df-mc/[email protected]/server/entity/item.go:114 +0xdbc
    github.com/df-mc/dragonfly/server/entity.(*Item).Tick(0xc004276a80, 0xc00010a140, 0x283f)
            C:/Users/Administrator/go/pkg/mod/github.com/df-mc/[email protected]/server/entity/item.go:91 +0x285
    github.com/df-mc/dragonfly/server/world.ticker.tickEntities({0xc00010a140?}, 0xc00533b2a0?)
            C:/Users/Administrator/go/pkg/mod/github.com/df-mc/[email protected]/server/world/tick.go:279 +0x68d
    github.com/df-mc/dragonfly/server/world.ticker.tick({0xc0068a1f90?})
            C:/Users/Administrator/go/pkg/mod/github.com/df-mc/[email protected]/server/world/tick.go:71 +0x20e
    github.com/df-mc/dragonfly/server/world.ticker.tickLoop({0x0?})
            C:/Users/Administrator/go/pkg/mod/github.com/df-mc/[email protected]/server/world/tick.go:26 +0xa5
    created by github.com/df-mc/dragonfly/server/world.Config.New
            C:/Users/Administrator/go/pkg/mod/github.com/df-mc/[email protected]/server/world/conf.go:84 +0x56e
    exit status 2
    
    bug 
    opened by RestartFU 5
  • 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

    improvement 
    opened by Blackjack200 4
  • pass a pointer in HandleFoodLoss to modify param

    pass a pointer in HandleFoodLoss to modify param "to"

    Tests

    diff --git a/main.go b/main.go
    index b1905144..35072aed 100644
    --- a/main.go
    +++ b/main.go
    @@ -3,8 +3,6 @@ package main
     import (
     	"fmt"
     	"github.com/df-mc/dragonfly/server"
    -	"github.com/df-mc/dragonfly/server/event"
    -	"github.com/df-mc/dragonfly/server/player"
     	"github.com/df-mc/dragonfly/server/player/chat"
     	"github.com/pelletier/go-toml"
     	"github.com/sirupsen/logrus"
    @@ -12,11 +10,6 @@ import (
     )
     
     func main() {
    -	aa := a{}
    -	to := 1
    -	logrus.Infof("1 main: to:%v", to)
    -	aa.HandleFoodLoss(event.C(), 20, &to)
    -	logrus.Infof("2 main: to:%v", to)
     	log := logrus.New()
     	log.Formatter = &logrus.TextFormatter{ForceColors: true}
     	log.Level = logrus.DebugLevel
    @@ -36,16 +29,6 @@ func main() {
     	}
     }
     
    -type a struct {
    -	player.NopHandler
    -}
    -
    -func (a) HandleFoodLoss(_ *event.Context, from int, to *int) {
    -	logrus.Infof("1 HandleFoodLoss: from:%v to:%v", from, *to)
    -	*to = 0
    -	logrus.Infof("2 HandleFoodLoss: from:%v to:%v", from, *to)
    -}
    -
     // readConfig reads the configuration from the config.toml file, or creates the
     // file if it does not yet exist.
     func readConfig(log server.Logger) (server.Config, error) {
    
    

    Excepted Result

    INFO[0000] 1 main: to:1
    INFO[0000] 1 HandleFoodLoss: from:20 to:1
    INFO[0000] 2 HandleFoodLoss: from:20 to:0
    INFO[0000] 2 main: to:0
    

    Actual Result

    (no difference)

    INFO[0000] 1 main: to:1
    INFO[0000] 1 HandleFoodLoss: from:20 to:1
    INFO[0000] 2 HandleFoodLoss: from:20 to:0
    INFO[0000] 2 main: to:0
    
    improvement 
    opened by Blackjack200 0
  • Make the item.Stack argument in HandleItemPickup a pointer

    Make the item.Stack argument in HandleItemPickup a pointer

    This can be useful for when you use your own items, with custom functionalities and want to have items drop on death and be picked up as they were before death. In my case, if the stack isn't replaced by my own custom soup implementation on pickup, then the soup is "broken", it would be a vanilla soup.

    improvement 
    opened by RestartFU 0
Owner
Dragonfly
Writing Go server software for Minecraft Bedrock Edition
Dragonfly
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.

Milad Noorzaie 2 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

Michał Kowal 33 Nov 30, 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

virusbear 1 Nov 19, 2021
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

Matthew Collins 290 Nov 19, 2022
⛏ 🐹 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

Pietro Tamilia 31 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

PotatoMaster101 1 May 29, 2022
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

SolarLune 279 Nov 27, 2022
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

Cyinx 415 Nov 19, 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

Sang Tian 9 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

null 10 Nov 7, 2022
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

xtaci 1.2k Nov 26, 2022
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

Nan Lin 2.2k Dec 1, 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

Name5566 4.6k Nov 24, 2022
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

Lonng 2.2k Nov 28, 2022
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

TFG Co 1.6k Nov 28, 2022
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

GoogleForGames 4.9k Nov 28, 2022
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

はやぶさクラウド 17 May 21, 2022
game server by golang

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

liangmanlin 16 Oct 11, 2022
This is a "simple" game server. Main functionalities are matching and establishing a connection between players

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

eco 8 Aug 28, 2022