Skip to content

Commit

Permalink
steven, protocol, resource: update to 15w36c
Browse files Browse the repository at this point in the history
  • Loading branch information
Thinkofname committed Sep 5, 2015
1 parent 12fe7e5 commit 951d5ed
Show file tree
Hide file tree
Showing 7 changed files with 3,555 additions and 3,543 deletions.
23 changes: 14 additions & 9 deletions chunk.go
Expand Up @@ -17,7 +17,6 @@ package steven
import (
"bytes"
"encoding/binary"
"fmt"
"math"
"sort"
"sync"
Expand Down Expand Up @@ -573,24 +572,30 @@ func loadChunk(x, z int, data *bytes.Reader, mask int32, sky, isNew bool) {
}
cs := c.Sections[i]

count, _ := protocol.ReadVarInt(data)
bitSize, err := data.ReadByte()
if err != nil {
panic(err)
}

blockMap := map[int]int{}
for i := 0; i < int(count); i++ {
bID, _ := protocol.ReadVarInt(data)
blockMap[i] = int(bID)
if bitSize <= 8 {
count, _ := protocol.ReadVarInt(data)
for i := 0; i < int(count); i++ {
bID, _ := protocol.ReadVarInt(data)
blockMap[i] = int(bID)
}
}

bitSize, _ := protocol.ReadVarInt(data)
length, _ := protocol.ReadVarInt(data)
bits := make([]uint64, length)
len, _ := protocol.ReadVarInt(data)
bits := make([]uint64, len)
binary.Read(data, binary.BigEndian, &bits)

m := bit.NewMapFromRaw(bits, int(bitSize))
for i := 0; i < 4096; i++ {
val := m.Get(i)
bID, ok := blockMap[val]
if !ok {
panic(fmt.Sprintf("Missing block %d", val))
bID = val
}
block := GetBlockByCombinedID(uint16(bID))
pos := Position{X: i & 0xF, Z: (i >> 4) & 0xF, Y: i >> 8}
Expand Down

0 comments on commit 951d5ed

Please sign in to comment.