convert between save.Chunk and level.Chunk
This commit is contained in:
@ -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] {
|
||||
|
@ -12,7 +12,7 @@ func TestColumn(t *testing.T) {
|
||||
}
|
||||
defer r.Close()
|
||||
|
||||
var c Column
|
||||
var c Chunk
|
||||
data, err := r.ReadSector(0, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@ -27,7 +27,7 @@ func TestColumn(t *testing.T) {
|
||||
|
||||
func BenchmarkColumn_Load(b *testing.B) {
|
||||
// Test how many times we load a chunk
|
||||
var c Column
|
||||
var c Chunk
|
||||
r, err := region.Open("testdata/region/r.-1.-1.mca")
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
type PlayerData struct {
|
||||
DataVersion int32
|
||||
|
||||
Dimension int32
|
||||
Dimension string
|
||||
Pos [3]float64
|
||||
Motion [3]float64
|
||||
Rotation [2]float32
|
||||
|
Reference in New Issue
Block a user