3 Copyright (C) 2010-2015 celeron55, Perttu Ahola <celeron55@gmail.com>
4 Copyright (C) 2013-2016 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
5 Copyright (C) 2014-2017 paramat
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 2.1 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #define MGV6_AVERAGE_MUD_AMOUNT 4
28 #define MGV6_DESERT_STONE_BASE -32
29 #define MGV6_ICE_BASE 0
30 #define MGV6_FREQ_HOT 0.4
31 #define MGV6_FREQ_SNOW -0.4
32 #define MGV6_FREQ_TAIGA 0.5
33 #define MGV6_FREQ_JUNGLE 0.5
35 //////////// Mapgen V6 flags
36 #define MGV6_JUNGLES 0x01
37 #define MGV6_BIOMEBLEND 0x02
38 #define MGV6_MUDFLOW 0x04
39 #define MGV6_SNOWBIOMES 0x08
40 #define MGV6_FLAT 0x10
41 #define MGV6_TREES 0x20
44 extern FlagDesc flagdesc_mapgen_v6[];
57 struct MapgenV6Params : public MapgenParams {
58 u32 spflags = MGV6_JUNGLES | MGV6_SNOWBIOMES | MGV6_TREES |
59 MGV6_BIOMEBLEND | MGV6_MUDFLOW;
60 float freq_desert = 0.45f;
61 float freq_beach = 0.15f;
62 NoiseParams np_terrain_base;
63 NoiseParams np_terrain_higher;
64 NoiseParams np_steepness;
65 NoiseParams np_height_select;
70 NoiseParams np_humidity;
72 NoiseParams np_apple_trees;
75 ~MapgenV6Params() = default;
77 void readParams(const Settings *settings);
78 void writeParams(Settings *settings) const;
82 class MapgenV6 : public Mapgen {
84 EmergeManager *m_emerge;
93 v3s16 central_area_size;
95 Noise *noise_terrain_base;
96 Noise *noise_terrain_higher;
97 Noise *noise_steepness;
98 Noise *noise_height_select;
102 Noise *noise_humidity;
103 NoiseParams *np_cave;
104 NoiseParams *np_humidity;
105 NoiseParams *np_trees;
106 NoiseParams *np_apple_trees;
112 content_t c_dirt_with_grass;
114 content_t c_water_source;
115 content_t c_lava_source;
117 content_t c_desert_stone;
118 content_t c_desert_sand;
119 content_t c_dirt_with_snow;
121 content_t c_snowblock;
125 content_t c_mossycobble;
126 content_t c_stair_cobble;
127 content_t c_stair_desert_stone;
129 MapgenV6(int mapgenid, MapgenV6Params *params, EmergeManager *emerge);
132 virtual MapgenType getType() const { return MAPGEN_V6; }
134 void makeChunk(BlockMakeData *data);
135 int getGroundLevelAtPoint(v2s16 p);
136 int getSpawnLevelAtPoint(v2s16 p);
138 float baseTerrainLevel(float terrain_base, float terrain_higher,
139 float steepness, float height_select);
140 virtual float baseTerrainLevelFromNoise(v2s16 p);
141 virtual float baseTerrainLevelFromMap(v2s16 p);
142 virtual float baseTerrainLevelFromMap(int index);
144 s16 find_stone_level(v2s16 p2d);
145 bool block_is_underground(u64 seed, v3s16 blockpos);
146 s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
148 float getHumidity(v2s16 p);
149 float getTreeAmount(v2s16 p);
150 bool getHaveAppleTree(v2s16 p);
151 float getMudAmount(v2s16 p);
152 virtual float getMudAmount(int index);
153 bool getHaveBeach(v2s16 p);
154 bool getHaveBeach(int index);
155 BiomeV6Type getBiome(v2s16 p);
156 BiomeV6Type getBiome(int index, v2s16 p);
158 u32 get_blockseed(u64 seed, v3s16 p);
160 virtual void calculateNoise();
161 int generateGround();
163 void flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos);
164 void moveMud(u32 remove_index, u32 place_index,
165 u32 above_remove_index, v2s16 pos, v3s16 em);
167 void placeTreesAndJungleGrass();
168 virtual void generateCaves(int max_stone_y);