FeatherMC/src/world/Chunk.h

45 lines
875 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
2020-08-13 15:54:57 +01:00
struct ChunkSection
2020-08-13 04:15:51 +01:00
{
2020-08-13 15:54:57 +01:00
static constexpr size_t MaximumLongCount = (16 * 16 * 16) * 14 / 64;
2020-08-13 04:15:51 +01:00
2020-08-13 15:54:57 +01:00
std::array<uint64_t, MaximumLongCount> blockStates;
2020-08-13 04:54:48 +01:00
// TODO: this should eventually be Palette<BlockState>
// Palette of local indexs to indexs in the global palette
IDMapper<int> localPalette;
2020-08-13 15:54:57 +01:00
uint8_t bitsPerBlock;
2020-08-13 04:15:51 +01:00
};
// Chunk: 16x256x16 world chunk
class Chunk
{
2020-08-13 04:54:48 +01:00
public:
2020-08-13 04:15:51 +01:00
static constexpr int NUM_SECTIONS = 16;
// Each chunk is made of up 16 ChunkSections
2020-08-13 04:54:48 +01:00
ChunkSection sections[NUM_SECTIONS];
2020-08-13 04:15:51 +01:00
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
Chunk(ChunkPos& pos, NBT::CompoundTag& tag);
};
};