Map content in DecodedBlock.Content() thru the index map to pull this logic out of the renderer.

This commit is contained in:
Sascha L. Teichmann 2014-09-10 08:21:51 +02:00
parent e145779ca0
commit cb5b6461a3

View File

@ -144,21 +144,26 @@ func NewDecodedBlock(data []byte, nameIndex map[string]int) (db *DecodedBlock, e
return
}
func (db *DecodedBlock) Content(x, y, z int) int {
func (db *DecodedBlock) Content(x, y, z int) (content int, found bool) {
pos := z<<8 + y<<4 + x
switch {
case db.Version >= 24:
pos <<= 1
return int(db.MapContent[pos])<<8 | int(db.MapContent[pos+1])
content = int(db.MapContent[pos])<<8 | int(db.MapContent[pos+1])
case db.Version >= 20:
if db.MapContent[pos] <= 0x80 {
return int(db.MapContent[pos])
content = int(db.MapContent[pos])
} else {
content = int(db.MapContent[pos])<<4 | int(db.MapContent[pos+0x2000])>>4
}
return int(db.MapContent[pos])<<4 | int(db.MapContent[pos+0x2000])>>4
default:
return db.IgnoreId
return
}
if content != db.AirId && content != db.IgnoreId {
content, found = db.IndexMap[content]
}
return
}
func NewPosBuf(data []byte) *PosBuf {