1 local Chunk = Dragonblocks.create_class()
4 local size_squared = math.pow(size, 2)
6 function Chunk:constructor()
10 Client.graphics:create_chunk_meshes(self)
14 function Chunk:get_pos_hash(pos)
15 local x, y, z = pos.x, pos.y, pos.z
16 if x > 15 or y > 15 or z > 15 or x < 0 or y < 0 or z < 0 then return end
17 return x + size * y + size_squared * z
20 function Chunk:add_block(pos, def)
21 local block = WorldSystem.Block(def, pos)
22 self.blocks[self:get_pos_hash(pos)] = block
25 function Chunk:remove_block(pos)
26 self.blocks[self:get_pos_hash(pos)] = nil
29 function Chunk:get_block(pos)
30 return self.blocks[self:get_pos_hash(pos)]