mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-05 17:44:52 +01:00
Use biome data
This commit is contained in:
parent
143b9f6c78
commit
9b1d92387d
5 changed files with 20 additions and 4 deletions
|
@ -97,7 +97,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
for (size_t x = 0; x < World::Chunk::SIZE; x++) {
|
||||
for (size_t z = 0; z < World::Chunk::SIZE; z++)
|
||||
image[Z*World::Chunk::SIZE+z][X*World::Chunk::SIZE+x] = htonl(layer.blocks[x][z].getColor(0));
|
||||
image[Z*World::Chunk::SIZE+z][X*World::Chunk::SIZE+x] = htonl(layer.blocks[x][z].getColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
namespace MinedMap {
|
||||
namespace World {
|
||||
|
||||
uint32_t Block::getColor(uint8_t biome) const {
|
||||
uint32_t Block::getColor() const {
|
||||
const World::BlockType &t = World::BLOCK_TYPES[id];
|
||||
|
||||
if (!t.opaque)
|
||||
|
|
|
@ -41,9 +41,11 @@ struct Block {
|
|||
uint8_t blockLight;
|
||||
uint8_t skyLight;
|
||||
|
||||
Block() : id(0), data(0), height(0), blockLight(0), skyLight(0) {}
|
||||
uint8_t biome;
|
||||
|
||||
uint32_t getColor(uint8_t biome) const;
|
||||
Block() : id(0), data(0), height(0), blockLight(0), skyLight(0), biome(0) {}
|
||||
|
||||
uint32_t getColor() const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -105,6 +105,13 @@ void Chunk::analyzeChunk() {
|
|||
sections = assertValue(level->get<NBT::ListTag<NBT::CompoundTag>>("Sections"));
|
||||
maxY = (assertValue(sections->back()->get<NBT::ByteTag>("Y"))->getValue() + 1) * SIZE;
|
||||
|
||||
|
||||
std::shared_ptr<const NBT::ByteArrayTag> biomeTag = assertValue(level->get<NBT::ByteArrayTag>("Biomes"));
|
||||
if (biomeTag->getLength() != SIZE*SIZE)
|
||||
throw std::invalid_argument("corrupt biome data");
|
||||
|
||||
biomes = biomeTag->getValue();
|
||||
|
||||
blockIDs.reset(new uint8_t[maxY * SIZE * SIZE]);
|
||||
blockData.reset(new uint8_t[maxY * SIZE * SIZE / 2]);
|
||||
blockSkyLight.reset(new uint8_t[maxY * SIZE * SIZE / 2]);
|
||||
|
@ -170,6 +177,8 @@ Chunk::Blocks Chunk::getTopLayer() const {
|
|||
|
||||
b.height = h;
|
||||
|
||||
b.biome = getBiomeAt(x, z);
|
||||
|
||||
done++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ private:
|
|||
std::unique_ptr<uint8_t[]> blockData;
|
||||
std::unique_ptr<uint8_t[]> blockSkyLight;
|
||||
std::unique_ptr<uint8_t[]> blockBlockLight;
|
||||
const uint8_t *biomes;
|
||||
|
||||
|
||||
size_t getIndex(size_t x, size_t y, size_t z) const {
|
||||
|
@ -101,6 +102,10 @@ private:
|
|||
return getHalf(blockSkyLight.get(), x, y, z);
|
||||
}
|
||||
|
||||
uint8_t getBiomeAt(size_t x, size_t z) const {
|
||||
return biomes[z*SIZE + x];
|
||||
}
|
||||
|
||||
|
||||
void inflateChunk(Buffer buffer);
|
||||
void parseChunk();
|
||||
|
|
Loading…
Add table
Reference in a new issue