From 24f80a7dbc85ac1e8c88274a013ff470df013189 Mon Sep 17 00:00:00 2001 From: oqammx86 <84847714+oq-x@users.noreply.github.com> Date: Wed, 27 Sep 2023 18:23:24 +0300 Subject: [PATCH] Fix seed field --- server/commands/commands.go | 4 +++- server/world/generator.go | 5 +++++ server/world/world.go | 17 +++++++++++------ 3 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 server/world/generator.go diff --git a/server/commands/commands.go b/server/commands/commands.go index 7e21b9d..699ee59 100644 --- a/server/commands/commands.go +++ b/server/commands/commands.go @@ -2,6 +2,7 @@ package commands import ( "fmt" + "strings" pk "github.com/aimjel/minecraft/packet" "github.com/dynamitemc/dynamite/server/player" @@ -28,7 +29,8 @@ func (ctx *CommandContext) Incomplete() { } func (ctx *CommandContext) Error(msg string) { - ctx.Reply(fmt.Sprintf("§c%s\n§7%s§r§c§o<--[HERE]", msg, ctx.FullCommand)) + sp := strings.Split(ctx.FullCommand, " ") + ctx.Reply(fmt.Sprintf("§c%s\n§7%s§c§n%s§c§o<--[HERE]", msg, strings.Join(sp[:len(sp)-1], " "), sp[len(sp)-1])) } const ( diff --git a/server/world/generator.go b/server/world/generator.go new file mode 100644 index 0000000..c471847 --- /dev/null +++ b/server/world/generator.go @@ -0,0 +1,5 @@ +package world + +func GenerateWorldData() worldData { + return worldData{} +} diff --git a/server/world/world.go b/server/world/world.go index 658dccd..59cef24 100644 --- a/server/world/world.go +++ b/server/world/world.go @@ -9,13 +9,18 @@ import ( "github.com/aimjel/minecraft/nbt" ) -type World struct { - nbt struct { - Data struct { - Seed int64 `nbt:"seed"` - DataVersion int32 +type worldData struct { + Data struct { + WorldGenSettings struct { + Seed int64 `nbt:"seed"` } + DataVersion int32 + GameRules map[string]string } +} + +type World struct { + nbt worldData entityIdCounter atomic.Value @@ -51,7 +56,7 @@ func OpenWorld(name string) (*World, error) { } func (w *World) Seed() int64 { - return w.nbt.Data.Seed + return w.nbt.Data.WorldGenSettings.Seed } func (w *World) DefaultDimension() *Dimension {