decode Biomes data

This commit is contained in:
Tnze
2019-12-14 22:30:12 +08:00
parent 55c7e2163b
commit 4384646214
2 changed files with 22 additions and 11 deletions

View File

@ -442,14 +442,14 @@ func handleChunkDataPacket(c *Client, p pk.Packet) error {
FullChunk pk.Boolean
PrimaryBitMask pk.VarInt
Heightmaps struct{}
Biomes = biomesData{fullChunk: (*bool)(&FullChunk)}
Data chunkData
BlockEntities blockEntities
)
// TODO: Biomes data in this packet
if err := p.Scan(&X, &Z, &FullChunk, &PrimaryBitMask, pk.NBT{V: &Heightmaps}, &Data, &BlockEntities); err != nil {
if err := p.Scan(&X, &Z, &FullChunk, &PrimaryBitMask, pk.NBT{V: &Heightmaps}, &Biomes, &Data, &BlockEntities); err != nil {
return err
}
chunk, err := world.DecodeChunkColumn(bool(FullChunk), int32(PrimaryBitMask), Data)
chunk, err := world.DecodeChunkColumn(int32(PrimaryBitMask), Data)
if err != nil {
return fmt.Errorf("decode chunk column fail: %v", err)
}
@ -459,6 +459,24 @@ func handleChunkDataPacket(c *Client, p pk.Packet) error {
return err
}
type biomesData struct {
fullChunk *bool
data [1024]int32
}
func (b *biomesData) Decode(r pk.DecodeReader) error {
if b.fullChunk == nil || *b.fullChunk {
return nil
}
for i := range b.data {
err := (*pk.Int)(&b.data[i]).Decode(r)
if err != nil {
return err
}
}
return nil
}
type chunkData []byte
type blockEntities []blockEntitie
type blockEntitie struct {