FeatherMC/src/world/Chunk.h

44 lines
775 B
C
Raw Normal View History

2020-08-13 04:15:51 +01:00
#pragma once
#include "Types.h"
#include "nbt/NBT.h"
#include "PalettedContainer.h"
#include "block/state/BlockState.h"
#include <cstdint>
namespace Feather
{
// 16x16x16 sections of a chunk
class ChunkSection
{
public:
// 4 bits per block
// 16^3 = 4096 blocks total
// 4096 * 4 = 16384 bits = 256x int64
// 16 blocks per int64
static constexpr int NUM_LONGS = 256;
int64_t blockStates[NUM_LONGS];
};
// Chunk: 16x256x16 world chunk
class Chunk
{
static constexpr int NUM_SECTIONS = 16;
// Each chunk is made of up 16 ChunkSections
ChunkSection Sections[NUM_SECTIONS];
ChunkPos pos;
2020-08-13 04:54:13 +01:00
// TODO: save heightmaps here
2020-08-13 04:15:51 +01:00
// UNSERIALIZED
2020-08-13 04:54:13 +01:00
//const NBT::CompoundTag* heightmaps;
2020-08-13 04:15:51 +01:00
public:
Chunk(ChunkPos& pos, NBT::CompoundTag& tag);
};
};