Do not render air only blocks. Nice performance speed up! :-)

This commit is contained in:
Sascha L. Teichmann 2014-10-19 17:15:33 +02:00
parent 1c530a2ce7
commit 8b42446acc
2 changed files with 9 additions and 0 deletions

View File

@ -47,6 +47,7 @@ type (
MapContent []byte
AirId int32
IgnoreId int32
AirOnly bool
IndexMap map[int32]int32
}
)
@ -136,6 +137,7 @@ func NewDecodedBlock(data []byte, nameIndex map[string]int32) (db *DecodedBlock,
airId, ignoreId := int32(-1), int32(-1)
indexMap := make(map[int32]int32)
var airOnly bool
if version >= 22 {
offset++
numMappings := int(binary.BigEndian.Uint16(data[offset:]))
@ -160,6 +162,7 @@ func NewDecodedBlock(data []byte, nameIndex map[string]int32) (db *DecodedBlock,
}
}
}
airOnly = airId != -1 && len(indexMap) == 0
}
db = &DecodedBlock{
@ -167,6 +170,7 @@ func NewDecodedBlock(data []byte, nameIndex map[string]int32) (db *DecodedBlock,
MapContent: mapContent,
AirId: airId,
IgnoreId: ignoreId,
AirOnly: airOnly,
IndexMap: indexMap}
return

View File

@ -182,6 +182,11 @@ func (r *Renderer) RenderBlock(block *Block, nameIndex map[string]int32) (err er
return
}
if db.AirOnly {
r.Rejected++
return
}
w := r.width << 4
ofs := int(bz)*w<<4 + int(bx)<<4
yB := r.yBuffer