1234567891011121314151617181920 |
- #include "common/world/Chunk.h"
- #include "common/block/BlockRegistry.h"
- Chunk::Chunk() {
- for(u32 y = 0; y < HEIGHT; y++) {
- for(u32 x = 0; x < CHUNK_PARTION_SIZE; x++) {
- for(u32 z = 0; z < CHUNK_PARTION_SIZE; z++) {
- blocks[y][x][z] = 0;
- }
- }
- }
- }
- const Block& Chunk::getBlock(u32 x, u32 y, u32 z) const {
- return BlockRegistry::getBlock(blocks[y & BITMASK_HEIGHT][x & CHUNK_PARTION_SIZE][z & CHUNK_PARTION_SIZE]);
- }
- void Chunk::setBlock(u32 x, u32 y, u32 z, const Block& block) {
- blocks[y & BITMASK_HEIGHT][x & CHUNK_PARTION_SIZE][z & CHUNK_PARTION_SIZE] = block.getId();
- }
|