10 #include "../IniFile.h"
11 #include "../Noise/Noise.h"
12 #include "../LinearUpscale.h"
34 constexpr
cPattern(std::initializer_list<BlockInfo> a_TopBlocks)
39 for (
const auto &
Block : a_TopBlocks)
194 ComposeColumn(a_ChunkDesc, x, z, &(a_Shape[x * 256 + z * 16 * 256]));
213 cNoise patternNoise(a_Seed);
232 static int layerSizes[] =
243 int numLayers = (rnd % 2) + 1;
245 for (
int lay = 0; lay < numLayers; lay++)
247 int numBlocks = layerSizes[(
static_cast<size_t>(rnd) %
ARRAYCOUNT(layerSizes))];
250 ((numBlocks == 3) && (numLayers == 2)) ||
255 numBlocks = std::min(idx + 1, numBlocks);
257 for (
int block = 0; block < numBlocks; block++, idx--)
265 int numBlocks = (rnd % 4) + 1;
266 if ((numLayers == 2) && (numBlocks < 4))
271 numBlocks = std::min(idx + 1, numBlocks);
272 for (
int block = 0; block < numBlocks; block++, idx--)
414 bool HasHadWater =
false;
420 a_ChunkDesc.
SetHeight(a_RelX, a_RelZ, top - 1);
422 for (
int y = top; y > 0; y--)
424 if (a_ShapeColumn[y] > 0)
427 a_ChunkDesc.
SetBlockTypeMeta(a_RelX, y, a_RelZ, a_Pattern[PatternIdx].m_BlockType, a_Pattern[PatternIdx].m_BlockMeta);
471 int Top = a_ChunkDesc.
GetHeight(a_RelX, a_RelZ);
482 if (ClayFloor >= Top)
491 for (
int y = Top - 1; y >= ClayFloor; y--)
495 for (
int y = ClayFloor - 1; y > 0; y--)
506 bool HasHadWater =
false;
507 for (
int y = Top; y > 0; y--)
509 if (a_ShapeColumn[y] > 0)
512 a_ChunkDesc.
SetBlockTypeMeta(a_RelX, y, a_RelZ, Pattern[PatternIdx].m_BlockType, Pattern[PatternIdx].m_BlockMeta);
587 return std::make_unique<cCompoGenBiomal>(a_Seed);
EMCSBiome
Biome IDs The first batch corresponds to the clientside biomes, used by MineCraft.
@ E_META_STAINED_CLAY_RED
@ E_META_STAINED_CLAY_WHITE
@ E_META_STAINED_CLAY_BROWN
@ E_META_STAINED_CLAY_LIGHTGRAY
@ E_META_STAINED_CLAY_YELLOW
@ E_META_STAINED_GLASS_ORANGE
@ E_META_STAINED_CLAY_ORANGE
@ E_BLOCK_STATIONARY_WATER
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char HEIGHTTYPE
The type used by the heightmap.
unsigned char BLOCKTYPE
The datatype used by blockdata.
std::unique_ptr< cTerrainCompositionGen > CreateCompoGenBiomal(int a_Seed)
Returns a new instance of the Biomal composition generator.
static constexpr cPattern patSand
static constexpr cPattern patGrass
static constexpr cPattern patGrassLess
static constexpr cPattern patOFOrangeClay
static constexpr cPattern patStone
static constexpr cPattern patPodzol
static constexpr cPattern patOFClay
static constexpr cPattern patDirt
static constexpr cPattern patOFSand
static constexpr cPattern patGravel
static constexpr cPattern patMycelium
#define ARRAYCOUNT(X)
Evaluates to the number of elements in an array (compile-time!)
float NOISE_DATATYPE
The datatype used by all the noise generators.
HEIGHTTYPE GetHeight(int a_RelX, int a_RelZ) const
EMCSBiome GetBiome(int a_RelX, int a_RelZ) const
void SetBlockType(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType)
Byte Shape[256 *16 *16]
The datatype used to represent the entire chunk worth of shape.
void SetHeight(int a_RelX, int a_RelZ, HEIGHTTYPE a_Height)
void SetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
void FillBlocks(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
This class is used to store a column pattern initialized at runtime, so that the program doesn't need...
constexpr cPattern(std::initializer_list< BlockInfo > a_TopBlocks)
BlockInfo m_Pattern[cChunkDef::Height]
const BlockInfo * Get(void) const
cPattern::BlockInfo m_MesaPattern[2 *cChunkDef::Height]
The pattern used for mesa biomes.
const cPattern::BlockInfo * ChooseOceanFloorPattern(int a_ChunkX, int a_ChunkZ, int a_RelX, int a_RelZ)
Returns the pattern to use for an ocean floor in the specified column.
cNoise m_OceanFloorSelect
Noise used for selecting between dirt and sand on the ocean floor.
void FillColumnPattern(cChunkDesc &a_ChunkDesc, int a_RelX, int a_RelZ, const cPattern::BlockInfo *a_Pattern, const Byte *a_ShapeColumn)
Fills the specified column with the specified pattern; restarts the pattern when air is reached,...
HEIGHTTYPE m_SeaLevel
The block height at which water is generated instead of air.
cCompoGenBiomal(int a_Seed)
void initMesaPattern(int a_Seed)
Initializes the m_MesaPattern with a pattern based on the generator's seed.
virtual void InitializeCompoGen(cIniFile &a_IniFile) override
Reads parameters from the ini file, prepares generator for use.
void FillColumnMesa(cChunkDesc &a_ChunkDesc, int a_RelX, int a_RelZ, const Byte *a_ShapeColumn)
Fills the specified column with mesa pattern, based on the column height.
virtual void ComposeTerrain(cChunkDesc &a_ChunkDesc, const cChunkDesc::Shape &a_Shape) override
Generates the chunk's composition into a_ChunkDesc, using the terrain shape provided in a_Shape.
cNoise m_MesaFloor
Noise used for the floor of the clay blocks in mesa biomes.
void ComposeColumn(cChunkDesc &a_ChunkDesc, int a_RelX, int a_RelZ, const Byte *a_ShapeColumn)
Composes a single column in a_ChunkDesc.
The interface that a terrain composition generator must implement Terrain composition takes chunk coo...
int GetValueSetI(const AString &keyname, const AString &valuename, const int defValue=0) override
int IntNoise1DInt(int a_X) const
NOISE_DATATYPE CubicNoise2D(NOISE_DATATYPE a_X, NOISE_DATATYPE a_Y) const