重构 BiomesState, fix typo
This commit is contained in:
@ -34,16 +34,15 @@ type Chunk struct {
|
||||
|
||||
type Section struct {
|
||||
Y int8
|
||||
BlockStates struct {
|
||||
Palette []BlockState `nbt:"palette"`
|
||||
Data []uint64 `nbt:"data"`
|
||||
} `nbt:"block_states"`
|
||||
Biomes struct {
|
||||
Palette []string `nbt:"palette"`
|
||||
Data []uint64 `nbt:"data"`
|
||||
} `nbt:"biomes"`
|
||||
SkyLight []byte
|
||||
BlockLight []byte
|
||||
BlockStates PaletteContainer[BlockState] `nbt:"block_states"`
|
||||
Biomes PaletteContainer[BiomeState] `nbt:"biomes"`
|
||||
SkyLight []byte
|
||||
BlockLight []byte
|
||||
}
|
||||
|
||||
type PaletteContainer[T any] struct {
|
||||
Palette []T `nbt:"palette"`
|
||||
Data []uint64 `nbt:"data"`
|
||||
}
|
||||
|
||||
type BlockState struct {
|
||||
@ -51,6 +50,8 @@ type BlockState struct {
|
||||
Properties nbt.RawMessage
|
||||
}
|
||||
|
||||
type BiomeState string
|
||||
|
||||
// Load read column data from []byte
|
||||
func (c *Chunk) Load(data []byte) (err error) {
|
||||
var r io.Reader = bytes.NewReader(data[1:])
|
||||
@ -70,7 +71,7 @@ func (c *Chunk) Load(data []byte) (err error) {
|
||||
}
|
||||
|
||||
d := nbt.NewDecoder(r)
|
||||
//d.DisallowUnknownFields()
|
||||
// d.DisallowUnknownFields()
|
||||
_, err = d.Decode(c)
|
||||
return
|
||||
}
|
||||
@ -87,6 +88,8 @@ func (c *Chunk) Data(compressingType byte) ([]byte, error) {
|
||||
w = gzip.NewWriter(&buff)
|
||||
case 2:
|
||||
w = zlib.NewWriter(&buff)
|
||||
case 3:
|
||||
w = &buff
|
||||
}
|
||||
err := nbt.NewEncoder(w).Encode(c, "")
|
||||
return buff.Bytes(), err
|
||||
|
Reference in New Issue
Block a user