World.cpp 482 B

12345678910111213141516171819
  1. #include "common/world/World.h"
  2. World::World()
  3. {
  4. }
  5. void World::setBlock(u32 x, u32 y, u32 z, const Block& block)
  6. {
  7. u32 cx = (x >> Chunk::CHUNK_BIT_SIZE) & BITMASK;
  8. u32 cz = (z >> Chunk::CHUNK_BIT_SIZE) & BITMASK;
  9. chunks[cx][cz].setBlock(x, y, z, block);
  10. }
  11. const Block& World::getBlock(u32 x, u32 y, u32 z) const
  12. {
  13. u32 cx = (x >> Chunk::CHUNK_BIT_SIZE) & BITMASK;
  14. u32 cz = (z >> Chunk::CHUNK_BIT_SIZE) & BITMASK;
  15. return chunks[cx][cz].getBlock(x, y, z);
  16. }