|
@@ -6,6 +6,8 @@
|
|
|
#include "FastNoiseWrapper.h"
|
|
|
#include "NoBlock.h"
|
|
|
#include "TreeTemplate.h"
|
|
|
+#include "Chunk.h"
|
|
|
+#include "Constants.h"
|
|
|
|
|
|
GrasslandBiom::GrasslandBiom()
|
|
|
: BiomGenerator()
|
|
@@ -42,11 +44,18 @@ GrasslandBiom::~GrasslandBiom()
|
|
|
}
|
|
|
|
|
|
Framework::Either<Block*, int> GrasslandBiom::generateAboveSurfaceBlock(
|
|
|
- int x, int y, int z, int surfaceHeight)
|
|
|
+ int x, int y, int z, int surfaceHeight, Chunk* partialGeneratedChunk)
|
|
|
{
|
|
|
- if (z > surfaceHeight)
|
|
|
- return BlockTypeEnum::AIR;
|
|
|
- return BlockTypeEnum::GRASS;
|
|
|
+ int cx = x % CHUNK_SIZE;
|
|
|
+ int cy = y % CHUNK_SIZE;
|
|
|
+ if (cx < 0) cx += CHUNK_SIZE;
|
|
|
+ if (cy < 0) cy += CHUNK_SIZE;
|
|
|
+ auto below = partialGeneratedChunk->zBlockAt(
|
|
|
+ Framework::Vec3<int>(cx, cy, z - 1));
|
|
|
+ if ((below.isA() && below.getA()->zBlockType()->getId() == BlockTypeEnum::DIRT)
|
|
|
+ || (below.isB() && below.getB() == BlockTypeEnum::DIRT))
|
|
|
+ return BlockTypeEnum::GRASS;
|
|
|
+ return BlockTypeEnum::AIR;
|
|
|
}
|
|
|
|
|
|
Framework::Either<Block*, int> GrasslandBiom::generateSurfaceBlock(
|