diff --git a/tilemapper/blockdecoder.go b/tilemapper/blockdecoder.go index 5c7b6fd..cb4dcf2 100644 --- a/tilemapper/blockdecoder.go +++ b/tilemapper/blockdecoder.go @@ -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 {