go-mc
go-mc copied to clipboard
Clean way to set block state on local chunk coordinates?
I am trying to make procedural generation for chunks, is there a better way of setting block state than calculating section and local section coordinates? Maybe a helper function of some sort would be nice.
For now I came with following procedure:
func SetChunkBlock(c *level.Chunk, lx, ly, lz, bs int) {
sid := (ly+64)/16 + 4
if len(c.Sections) <= sid {
log.Printf("Failed to set block %d at %d %d %d because there is no section %d (%d allocated)", bs, lx, ly, lz, sid, len(c.Sections))
return
}
c.Sections[sid].SetBlock((ly%16)*16*16+lz*16+lx, bs)
}
However client ignores chunk or block is not actually placed.