convert between save.Chunk and level.Chunk

This commit is contained in:
Tnze
2021-12-20 01:50:31 +08:00
parent 8eaae6a202
commit 5bc8513039
7 changed files with 143 additions and 93 deletions

View File

@ -9,8 +9,8 @@ import (
"io"
)
// Column is 16* chunk
type Column struct {
// Chunk is 16* chunk
type Chunk struct {
DataVersion int32
XPos int32 `nbt:"xPos"`
YPos int32 `nbt:"yPos"`
@ -23,19 +23,21 @@ type Column struct {
OceanFloor []int64 `nbt:"OCEAN_FLOOR"`
WorldSurface []int64 `nbt:"WORLD_SURFACE"`
}
Sections []struct {
Y byte
BlockStates struct {
Palette []BlockState `nbt:"palette"`
Data []int64 `nbt:"data"`
} `nbt:"block_states"`
Biomes struct {
Palette []string `nbt:"palette"`
Data []int64 `nbt:"data"`
} `nbt:"biomes"`
SkyLight []byte
BlockLight []byte
} `nbt:"sections"`
Sections []Section `nbt:"sections"`
}
type Section struct {
Y byte
BlockStates struct {
Palette []BlockState `nbt:"palette"`
Data []int64 `nbt:"data"`
} `nbt:"block_states"`
Biomes struct {
Palette []string `nbt:"palette"`
Data []int64 `nbt:"data"`
} `nbt:"biomes"`
SkyLight []byte
BlockLight []byte
}
type BlockState struct {
@ -44,7 +46,7 @@ type BlockState struct {
}
// Load read column data from []byte
func (c *Column) Load(data []byte) (err error) {
func (c *Chunk) Load(data []byte) (err error) {
var r io.Reader = bytes.NewReader(data[1:])
switch data[0] {