Skip to content

Commit f9fe92a

Browse files
committed
Begin rewrite of player module
1 parent a29bd9c commit f9fe92a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+2801
-5941
lines changed

commands/debug.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import (
66
"github.com/zeppelinmc/zeppelin/protocol/text"
77
"github.com/zeppelinmc/zeppelin/server"
88
"github.com/zeppelinmc/zeppelin/server/command"
9-
"github.com/zeppelinmc/zeppelin/server/session"
9+
"github.com/zeppelinmc/zeppelin/server/player/state"
10+
11+
//"github.com/zeppelinmc/zeppelin/server/session"
1012
"github.com/zeppelinmc/zeppelin/util"
1113
)
1214

@@ -15,7 +17,7 @@ var debug = command.Command{
1517
Aliases: []string{"f3"},
1618
Namespace: "zeppelin",
1719
Callback: func(ccc command.CommandCallContext) {
18-
s, ok := ccc.Executor.(session.Session)
20+
s, ok := ccc.Executor.(interface{ Player() *state.PlayerEntity })
1921
if !ok {
2022
ccc.Executor.SystemMessage(text.TextComponent{
2123
Text: "This command should be used by a player.",
@@ -50,23 +52,21 @@ var debug = command.Command{
5052
}
5153
onBlock, _ := c.Block(xb&0x0f, yb-1, zb&0x0f)
5254
sky, _ := c.SkyLightLevel(xb&0x0f, yb, zb&0x0f)
53-
block, _ := c.BlockLightLevel(xb&0x0f, yb, zb&0x0f)
54-
55-
name, props := onBlock.Encode()
5655

5756
ccc.Executor.SystemMessage(text.Unmarshalf(
58-
ccc.Executor.Config().ChatFormatter.Rune(),
59-
"XYZ: %.03f / %.05f / %.03f\nBlock: %d %d %d [%d %d %d]\nChunk: %d %d %d [%d %d in r.%d.%d.mca]\nStanding on: %s [%v]\nFacing: (%.01f / %.01f)\nClient Light: %d (%d sky, %d block)\n\nYou are using: %s",
57+
'&', //ccc.Executor.Config().ChatFormatter.Rune(),
58+
"XYZ: %.03f / %.05f / %.03f\nBlock: %d %d %d [%d %d %d]\nChunk: %d %d %d [%d %d in r.%d.%d.mca]\nStanding on: %s [%v]\nFacing: (%.01f / %.01f)\nClient Light: %d (%d sky, 0 block)\n\nYou are using: %s",
6059
x, y, z,
6160
xb, yb, zb,
6261
xb&0xf, yb&0xf, zb&0xf,
6362
chunkX, chunkY, chunkZ,
6463
chunkX&31, chunkZ&31,
6564
rx, rz,
66-
name, props,
65+
onBlock.Name, onBlock.Properties,
6766
util.NormalizeYaw(yaw), pitch,
68-
sky+block, sky, block,
69-
s.ClientName(),
67+
sky, sky,
68+
"idk",
69+
//s.ClientName(),
7070
))
7171
},
7272
}

commands/tick.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package commands
22

33
import (
4-
"fmt"
54
"time"
65

76
"github.com/zeppelinmc/zeppelin/protocol/text"
@@ -19,12 +18,10 @@ var tick = command.Command{
1918
switch command {
2019
case "info":
2120
freq := tickManager.Frequency()
22-
ccc.Executor.SystemMessage(text.TextComponent{
23-
Text: fmt.Sprintf(
24-
"Server Tickers: %d\nTicking Frequency: %.02ftps (expected ticks per second)",
25-
num, 1/(float64(freq)/float64(time.Second)),
26-
),
27-
})
21+
ccc.Executor.SystemMessage(text.Sprintf(
22+
"Server Tickers: %d\nTicking Frequency: %.02ftps (expected ticks per second)",
23+
num, 1/(float64(freq)/float64(time.Second)),
24+
))
2825
case "freeze":
2926
tickManager.Freeze()
3027
ccc.Executor.SystemMessage(text.Sprintf("Froze %d tickers", num))

commands/time.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
package commands
22

33
import (
4-
"strconv"
5-
6-
"github.com/zeppelinmc/zeppelin/protocol/text"
7-
"github.com/zeppelinmc/zeppelin/server"
84
"github.com/zeppelinmc/zeppelin/server/command"
95
)
106

117
var timecmd = command.Command{
128
Node: command.NewLiteral("time" /*command.NewCommand("add", command.NewTimeArgument("time", 0)), command.NewCommand("set", command.NewTimeArgument("time", 0))*/),
139
Callback: func(ccc command.CommandCallContext) {
14-
command := ccc.Arguments.At(0)
10+
/*command := ccc.Arguments.At(0)
1511
w := ccc.Server.(*server.Server).World
1612
1713
switch command {
@@ -25,6 +21,6 @@ var timecmd = command.Command{
2521
2622
a, _ := w.Time()
2723
ccc.Executor.UpdateTime(a, int64(time))
28-
}
24+
}*/
2925
},
3026
}

go.mod

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ require (
1515

1616
require github.com/oq-x/unsafe2 v0.0.0-20240901191313-2b7bec1d9e3b
1717

18-
require github.com/grailbio/base v0.0.11 // indirect
18+
require (
19+
github.com/aimjel/mine-net v0.0.0-20241231185445-f0751c927ecb // indirect
20+
github.com/grailbio/base v0.0.11 // indirect
21+
)
1922

2023
require (
2124
github.com/4kills/go-zlib v1.2.0

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8
2020
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
2121
github.com/StackExchange/wmi v0.0.0-20170410192909-ea383cf3ba6e/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
2222
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
23+
github.com/aimjel/mine-net v0.0.0-20241231184943-192b6fd6bfdc h1:Fl6/rTVRsK3yRvLIe59RgElHb/fpVVo8fOm1SYvAfS8=
24+
github.com/aimjel/mine-net v0.0.0-20241231184943-192b6fd6bfdc/go.mod h1:2p/uMjMBAOvMK8NvNnTsXS7s00IYvbS3Ji3YM2ApzxA=
25+
github.com/aimjel/mine-net v0.0.0-20241231185445-f0751c927ecb h1:DzjkzmO1C8qXdEUSWU0I4hHEi0tuaFNrKeLeRZ8ntZo=
26+
github.com/aimjel/mine-net v0.0.0-20241231185445-f0751c927ecb/go.mod h1:2p/uMjMBAOvMK8NvNnTsXS7s00IYvbS3Ji3YM2ApzxA=
2327
github.com/aimjel/minecraft v0.0.0-20240907220502-e1fe5798908b h1:P5dA2C10r7BqzbhXqjjx07+LBV1tcsioFJrogWBOOBY=
2428
github.com/aimjel/minecraft v0.0.0-20240907220502-e1fe5798908b/go.mod h1:jb47g4nDw3J8JdA4WxQpDx25NoIZiyNCjFOtM1b3Urk=
2529
github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=

main.go

Lines changed: 7 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ package main
22

33
import (
44
_ "embed"
5-
"fmt"
5+
properties2 "github.com/zeppelinmc/zeppelin/properties"
66
"math/rand"
7-
"net/http"
87
"os"
98
"runtime"
109
"runtime/debug"
@@ -14,11 +13,9 @@ import (
1413
"time"
1514

1615
"github.com/zeppelinmc/zeppelin/commands"
17-
"github.com/zeppelinmc/zeppelin/protocol/properties"
1816
"github.com/zeppelinmc/zeppelin/server"
1917
"github.com/zeppelinmc/zeppelin/server/command"
2018
"github.com/zeppelinmc/zeppelin/server/world"
21-
"github.com/zeppelinmc/zeppelin/server/world/chunk/section"
2219
"github.com/zeppelinmc/zeppelin/util"
2320
"github.com/zeppelinmc/zeppelin/util/console"
2421
"github.com/zeppelinmc/zeppelin/util/log"
@@ -29,9 +26,6 @@ var timeStart = time.Now()
2926

3027
func main() {
3128
log.Infolnf("Zeppelin 1.21 Minecraft server with %s on platform %s-%s", runtime.Version(), runtime.GOOS, runtime.GOARCH)
32-
if !loadStates() {
33-
return
34-
}
3529

3630
max, ok := console.GetFlag("xmem")
3731
if ok {
@@ -100,63 +94,22 @@ func main() {
10094
srv.Start(timeStart)
10195
}
10296

103-
func loadConfig() properties.ServerProperties {
97+
func loadConfig() properties2.ServerProperties {
10498
file, err := os.ReadFile("server.properties")
10599
if err != nil {
106100
file, err := os.Create("server.properties")
107101
if err == nil {
108-
properties.Marshal(file, properties.Default)
102+
properties2.Marshal(file, properties2.Default)
109103
file.Close()
110104
}
111-
return properties.Default
105+
return properties2.Default
112106
}
113-
var cfg properties.ServerProperties
107+
var cfg properties2.ServerProperties
114108

115-
err = properties.Unmarshal(string(file), &cfg)
109+
err = properties2.Unmarshal(string(file), &cfg)
116110
if err != nil {
117-
cfg = properties.Default
111+
cfg = properties2.Default
118112
}
119113

120114
return cfg
121115
}
122-
123-
func loadStates() (ok bool) {
124-
os.Mkdir("resources", 0755)
125-
f, err := os.OpenFile("./resources/blocks", os.O_CREATE|os.O_RDWR, 0755)
126-
if err != nil {
127-
log.ErrorlnClean("Error opening block states file: ", err)
128-
return false
129-
}
130-
131-
if err := section.ImportStates(f); err == nil {
132-
return true
133-
}
134-
135-
log.Info("Downloading block states file")
136-
137-
res, err := http.Get(statesfilei)
138-
if err != nil {
139-
fmt.Println("... error")
140-
log.ErrorlnClean("Error downloading block states file: ", err)
141-
return false
142-
}
143-
if _, err := f.ReadFrom(res.Body); err != nil {
144-
fmt.Println("... error")
145-
log.ErrorlnClean("Error downloading block states file: ", err)
146-
return false
147-
}
148-
149-
f.Seek(0, 0)
150-
151-
fmt.Println("... done")
152-
153-
if err := section.ImportStates(f); err != nil {
154-
log.ErrorlnClean("An error occured while loading block states file: ", err)
155-
156-
return false
157-
}
158-
159-
return true
160-
}
161-
162-
var statesfilei = "https://github.com/ZeppelinMC/resources/raw/main/blocks"
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type ServerProperties struct {
2828

2929
EnforceSecureProfile bool `properties:"enforce-secure-profile"`
3030
EnforceWhitelist bool `properties:"enforce-whitelist"`
31-
EntityBroadcastRangePrecentage int `properties:"entity-broadcast-range-precentage"`
31+
EntityBroadcastRangePrecentage int `properties:"state-broadcast-range-precentage"`
3232
ForceGamemode bool `properties:"force-gamemode"`
3333
FunctionPermissionLevel int `properties:"function-permission-level"`
3434
Gamemode string `properties:"gamemode"`
@@ -66,9 +66,7 @@ type ServerProperties struct {
6666

6767
SimulationDistance int `properties:"simulation-distance"`
6868

69-
SpawnAnimals bool `properties:"spawn-animals"`
7069
SpawnMonsters bool `properties:"spawn-monsters"`
71-
SpawnNPCs bool `properties:"spawn-npcs"`
7270
SpawnProtection int `properties:"spawn-protection"`
7371

7472
ViewDistance int32 `properties:"view-distance"`
@@ -102,9 +100,7 @@ var Default = ServerProperties{
102100
RegionFileCompression: "deflate",
103101
ServerPort: 25565,
104102
SimulationDistance: 10,
105-
SpawnAnimals: true,
106103
SpawnMonsters: true,
107-
SpawnNPCs: true,
108104
SpawnProtection: 16,
109105
ViewDistance: 10,
110106
}

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
![zeppelinbanner (1)](https://github.com/user-attachments/assets/21605ec4-1253-460e-84c3-d984df14f212)
22
# Zeppelin
33

4-
Highly optimized server implementation written in [Go](https://go.dev) for Minecraft 1.21.1
4+
Highly optimized server implementation written in [Go](https://go.dev) for Minecraft 1.21.3
55

66
[Discord Server](https://discord.gg/T8qEtDWPak)
77

0 commit comments

Comments
 (0)