MCPcopy Create free account
hub / github.com/ZeppelinMC/Zeppelin / Open

Function Open

server/world/level/level.go:138–158  ·  view source on GitHub ↗

TODO fix EOF error worldPath is the base path of the world

(worldPath string)

Source from the content-addressed store, hash-verified

136// TODO fix EOF error
137// worldPath is the base path of the world
138func Open(worldPath string) (Level, error) {
139 var level Level
140 file, err := os.Open(worldPath + "/level.dat")
141 if err != nil {
142 return level, err
143 }
144 rd, err := gzip.NewReader(file)
145 if err != nil {
146 return level, err
147 }
148
149 var buf, _ = io.ReadAll(rd)
150
151 rd.Close()
152 file.Close()
153
154 _, err = nbt.Unmarshal(buf, &level)
155 level.basePath = worldPath
156
157 return level, err
158}
159
160func Create(l Level) error {
161 file, err := os.Create(l.basePath + "/level.dat")

Callers 1

NewWorldFunction · 0.92

Calls 3

UnmarshalFunction · 0.92
ReadAllMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected