place blocks
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
"encoding/gob"
|
||||
"io"
|
||||
"log"
|
||||
|
||||
"edgaru089.ml/go/gl01/internal/util/itype"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -40,6 +42,27 @@ func (c *Chunk) SetBlock(x, y, z int, id, aux int) {
|
||||
c.Id[x][y][z] = uint16(id)
|
||||
c.Aux[x][y][z] = uint16(aux)
|
||||
c.renderChanged = true
|
||||
|
||||
switch x {
|
||||
case 0:
|
||||
if cb, ok := c.world.Chunks[itype.Vec2i{c.X - 1, c.Z}]; ok {
|
||||
cb.InvalidateRender()
|
||||
}
|
||||
case ChunkSizeX - 1:
|
||||
if cb, ok := c.world.Chunks[itype.Vec2i{c.X + 1, c.Z}]; ok {
|
||||
cb.InvalidateRender()
|
||||
}
|
||||
}
|
||||
switch z {
|
||||
case 0:
|
||||
if cb, ok := c.world.Chunks[itype.Vec2i{c.X, c.Z - 1}]; ok {
|
||||
cb.InvalidateRender()
|
||||
}
|
||||
case ChunkSizeZ - 1:
|
||||
if cb, ok := c.world.Chunks[itype.Vec2i{c.X, c.Z + 1}]; ok {
|
||||
cb.InvalidateRender()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// InvalidateRender should be called if a block inside the chunk has changed
|
||||
|
||||
Reference in New Issue
Block a user