This commit is contained in:
Tnze
2022-04-03 15:09:55 +08:00
parent e00bb53f9e
commit f4bb734c1c
2 changed files with 12 additions and 11 deletions

10
level/block/utilfuncs.go Normal file
View File

@ -0,0 +1,10 @@
package block
func IsAir(s int) bool {
switch StateList[s].(type) {
case Air, CaveAir, VoidAir:
return true
default:
return false
}
}

View File

@ -143,7 +143,7 @@ func ChunkFromSave(c *save.Chunk, secs int) *Chunk {
}
}
s := block.ToStateID[b]
if !isAir(s) {
if !block.IsAir(s) {
blockCount++
}
stateRawPalette[i] = s
@ -297,7 +297,7 @@ func (s *Section) GetBlock(i int) int {
return s.States.Get(i)
}
func (s *Section) SetBlock(i int, v int) {
if isAir(s.States.Get(i)) {
if block.IsAir(s.States.Get(i)) {
s.BlockCount--
}
if v != 0 {
@ -362,12 +362,3 @@ func (l *lightData) ReadFrom(r io.Reader) (int64, error) {
pk.Array(&l.BlockLight),
}.ReadFrom(r)
}
func isAir(s int) bool {
switch block.StateList[s].(type) {
case block.Air, block.CaveAir, block.VoidAir:
return true
default:
return false
}
}