#water_level = 1
# Size of chunks to be generated.
#chunksize = 5
-# Map generation attributes. Currently supported: trees, caves, flat, v6_biome_blend
+# Map generation attributes. Currently supported: trees, caves, flat, v6_biome_blend, v6_jungles
#mg_flags = trees, caves, v6_biome_blend
# How large deserts and beaches are
#mgv6_freq_desert = 0.45
#mgv6_freq_beach = 0.15
# Perlin noise attributes for different map generation parameters
# Offset, scale, spread factor, seed offset, number of octaves, persistence
-#mgv6_np_terrain_base = -4, 20, (250.0, 250, 250), 82341, 5, 0.6
+#mgv6_np_terrain_base = -4, 20, (250, 250, 250), 82341, 5, 0.6
#mgv6_np_terrain_higher = 20, 16, (500, 500, 500), 85039, 5, 0.6
#mgv6_np_steepness = 0.85, 0.5, (125, 125, 125), -932, 5, 0.7
#mgv6_np_height_select = 0.5, 1, (250, 250, 250), 4213, 5, 0.69
-#mgv6_np_trees = 0, 1, (125, 125, 125), 2, 4, 0.66
#mgv6_np_mud = 4, 2, (200, 200, 200), 91013, 3, 0.55
#mgv6_np_beach = 0, 1, (250, 250, 250), 59420, 3, 0.50
#mgv6_np_biome = 0, 1, (250, 250, 250), 9130, 3, 0.50
#mgv6_np_cave = 6, 6, (250, 250, 250), 34329, 3, 0.50
+#mgv6_np_humidity = 0.5, 0.5, (500, 500, 500), 72384, 4, 0.66
+#mgv6_np_trees = 0, 1, (125, 125, 125), 2, 4, 0.66
+#mgv6_np_apple_trees = 0, 1, (100, 100, 100), 342902, 3, 0.45
+
#mgv7_np_terrain = 10, 12, (350, 350, 350), 82341, 5, 0.6
#mgv7_np_bgroup = 0.5, 0.3125, (350, 350, 350), 5923, 2, 0.6
#mgv7_np_heat = 25, 50, (500, 500, 500), 35293, 1, 0
{
std::set<std::string> s;
s.insert("sapling");
+ s.insert("junglesapling");
return s;
}
virtual float getTriggerInterval()
INodeDefManager *ndef = env->getGameDef()->ndef();
ServerMap *map = &env->getServerMap();
- actionstream<<"A sapling grows into a tree at "
- <<PP(p)<<std::endl;
+ bool is_jungle_tree = n.getContent() == ndef->getId("junglesapling");
+
+ actionstream <<"A " << (is_jungle_tree ? "jungle " : "")
+ << "sapling grows into a tree at "
+ << PP(p) << std::endl;
std::map<v3s16, MapBlock*> modified_blocks;
v3s16 tree_p = p;
ManualMapVoxelManipulator vmanip(map);
v3s16 tree_blockp = getNodeBlockPos(tree_p);
vmanip.initialEmerge(tree_blockp - v3s16(1,1,1), tree_blockp + v3s16(1,1,1));
- bool is_apple_tree = myrand()%4 == 0;
- treegen::make_tree(vmanip, tree_p, is_apple_tree, ndef, myrand());
+
+ if (is_jungle_tree) {
+ treegen::make_jungletree(vmanip, tree_p, ndef, myrand());
+ } else {
+ bool is_apple_tree = myrand() % 4 == 0;
+ treegen::make_tree(vmanip, tree_p, is_apple_tree, ndef, myrand());
+ }
+
vmanip.blitBackAll(&modified_blocks);
// update lighting
settings->setDefault("mgv6_freq_desert", "0.45");
settings->setDefault("mgv6_freq_beach", "0.15");
- settings->setDefault("mgv6_np_terrain_base", "-4, 20, (250.0, 250, 250), 82341, 5, 0.6");
+ settings->setDefault("mgv6_np_terrain_base", "-4, 20, (250, 250, 250), 82341, 5, 0.6");
settings->setDefault("mgv6_np_terrain_higher", "20, 16, (500, 500, 500), 85039, 5, 0.6");
settings->setDefault("mgv6_np_steepness", "0.85, 0.5, (125, 125, 125), -932, 5, 0.7");
settings->setDefault("mgv6_np_height_select", "0.5, 1, (250, 250, 250), 4213, 5, 0.69");
- settings->setDefault("mgv6_np_trees", "0, 1, (125, 125, 125), 2, 4, 0.66");
settings->setDefault("mgv6_np_mud", "4, 2, (200, 200, 200), 91013, 3, 0.55");
settings->setDefault("mgv6_np_beach", "0, 1, (250, 250, 250), 59420, 3, 0.50");
settings->setDefault("mgv6_np_biome", "0, 1, (250, 250, 250), 9130, 3, 0.50");
settings->setDefault("mgv6_np_cave", "6, 6, (250, 250, 250), 34329, 3, 0.50");
+ settings->setDefault("mgv6_np_humidity", "0.5, 0.5, (500, 500, 500), 72384, 4, 0.66");
+ settings->setDefault("mgv6_np_trees", "0, 1, (125, 125, 125), 2, 4, 0.66");
+ settings->setDefault("mgv6_np_apple_trees", "0, 1, (100, 100, 100), 342902, 3, 0.45");
settings->setDefault("mgv7_np_terrain", "10, 12, (350, 350, 350), 82341, 5, 0.6");
settings->setDefault("mgv7_np_bgroup", "0.5, 0.3125, (350, 350, 350), 5923, 2, 0.6");
{"trees", MG_TREES},
{"caves", MG_CAVES},
{"dungeons", MG_DUNGEONS},
- {"v6_forests", MGV6_FORESTS},
+ {"v6_jungles", MGV6_JUNGLES},
{"v6_biome_blend", MGV6_BIOME_BLEND},
{"flat", MG_FLAT},
{NULL, 0}
np_terrain_higher = settings->getNoiseParams("mgv6_np_terrain_higher");
np_steepness = settings->getNoiseParams("mgv6_np_steepness");
np_height_select = settings->getNoiseParams("mgv6_np_height_select");
- np_trees = settings->getNoiseParams("mgv6_np_trees");
np_mud = settings->getNoiseParams("mgv6_np_mud");
np_beach = settings->getNoiseParams("mgv6_np_beach");
np_biome = settings->getNoiseParams("mgv6_np_biome");
np_cave = settings->getNoiseParams("mgv6_np_cave");
+ np_humidity = settings->getNoiseParams("mgv6_np_humidity");
+ np_trees = settings->getNoiseParams("mgv6_np_trees");
+ np_apple_trees = settings->getNoiseParams("mgv6_np_apple_trees");
bool success =
np_terrain_base && np_terrain_higher && np_steepness &&
np_height_select && np_trees && np_mud &&
- np_beach && np_biome && np_cave;
+ np_beach && np_biome && np_cave &&
+ np_humidity && np_apple_trees;
return success;
}
settings->setNoiseParams("mgv6_np_terrain_higher", np_terrain_higher);
settings->setNoiseParams("mgv6_np_steepness", np_steepness);
settings->setNoiseParams("mgv6_np_height_select", np_height_select);
- settings->setNoiseParams("mgv6_np_trees", np_trees);
settings->setNoiseParams("mgv6_np_mud", np_mud);
settings->setNoiseParams("mgv6_np_beach", np_beach);
settings->setNoiseParams("mgv6_np_biome", np_biome);
settings->setNoiseParams("mgv6_np_cave", np_cave);
+ settings->setNoiseParams("mgv6_np_humidity", np_humidity);
+ settings->setNoiseParams("mgv6_np_trees", np_trees);
+ settings->setNoiseParams("mgv6_np_apple_trees", np_apple_trees);
}
#define MG_TREES 0x01
#define MG_CAVES 0x02
#define MG_DUNGEONS 0x04
-#define MGV6_FORESTS 0x08
+#define MGV6_JUNGLES 0x08
#define MGV6_BIOME_BLEND 0x10
#define MG_FLAT 0x20
{0.85, 0.5, v3f(125.0, 125.0, 125.0), -932, 5, 0.7};
NoiseParams nparams_v6_def_height_select =
{0.5, 1.0, v3f(250.0, 250.0, 250.0), 4213, 5, 0.69};
-NoiseParams nparams_v6_def_trees =
- {0.0, 1.0, v3f(125.0, 125.0, 125.0), 2, 4, 0.66};
NoiseParams nparams_v6_def_mud =
{AVERAGE_MUD_AMOUNT, 2.0, v3f(200.0, 200.0, 200.0), 91013, 3, 0.55};
NoiseParams nparams_v6_def_beach =
{0.0, 1.0, v3f(250.0, 250.0, 250.0), 9130, 3, 0.50};
NoiseParams nparams_v6_def_cave =
{6.0, 6.0, v3f(250.0, 250.0, 250.0), 34329, 3, 0.50};
+NoiseParams nparams_v6_def_humidity =
+ {0.5, 0.5, v3f(500.0, 500.0, 500.0), 72384, 4, 0.66};
+NoiseParams nparams_v6_def_trees =
+ {0.0, 1.0, v3f(125.0, 125.0, 125.0), 2, 4, 0.66};
+NoiseParams nparams_v6_def_apple_trees =
+ {0.0, 1.0, v3f(100.0, 100.0, 100.0), 342902, 3, 0.45};
///////////////////////////////////////////////////////////////////////////////
this->ystride = csize.X; //////fix this
- np_cave = params->np_cave;
+ np_cave = params->np_cave;
+ np_humidity = params->np_humidity;
+ np_trees = params->np_trees;
+ np_apple_trees = params->np_apple_trees;
noise_terrain_base = new Noise(params->np_terrain_base, seed, csize.X, csize.Y);
noise_terrain_higher = new Noise(params->np_terrain_higher, seed, csize.X, csize.Y);
noise_steepness = new Noise(params->np_steepness, seed, csize.X, csize.Y);
noise_height_select = new Noise(params->np_height_select, seed, csize.X, csize.Y);
- noise_trees = new Noise(params->np_trees, seed, csize.X, csize.Y);
noise_mud = new Noise(params->np_mud, seed, csize.X, csize.Y);
noise_beach = new Noise(params->np_beach, seed, csize.X, csize.Y);
noise_biome = new Noise(params->np_biome, seed, csize.X, csize.Y);
delete noise_terrain_higher;
delete noise_steepness;
delete noise_height_select;
- delete noise_trees;
delete noise_mud;
delete noise_beach;
delete noise_biome;
//////////////////////// Noise functions
-float MapgenV6::getTreeAmount(v2s16 p) {
- int index = (p.Y - node_min.Z) * ystride + (p.X - node_min.X);
- return getTreeAmount(index);
-}
-
-
float MapgenV6::getMudAmount(v2s16 p) {
int index = (p.Y - node_min.Z) * ystride + (p.X - node_min.X);
return getMudAmount(index);
}
-float MapgenV6::getTreeAmount(int index)
+float MapgenV6::getHumidity(v2s16 p)
+{
+ /*double noise = noise2d_perlin(
+ 0.5+(float)p.X/500, 0.5+(float)p.Y/500,
+ seed+72384, 4, 0.66);
+ noise = (noise + 1.0)/2.0;*/
+
+ float noise = NoisePerlin2D(np_humidity, p.X, p.Y, seed);
+
+ if (noise < 0.0)
+ noise = 0.0;
+ if (noise > 1.0)
+ noise = 1.0;
+ return noise;
+}
+
+
+float MapgenV6::getTreeAmount(v2s16 p)
{
/*double noise = noise2d_perlin(
0.5+(float)p.X/125, 0.5+(float)p.Y/125,
seed+2, 4, 0.66);*/
- float noise = noise_trees->result[index];
+ float noise = NoisePerlin2D(np_trees, p.X, p.Y, seed);
float zeroval = -0.39;
if (noise < zeroval)
return 0;
}
+bool MapgenV6::getHaveAppleTree(v2s16 p)
+{
+ /*is_apple_tree = noise2d_perlin(
+ 0.5+(float)p.X/100, 0.5+(float)p.Z/100,
+ data->seed+342902, 3, 0.45) > 0.2;*/
+
+ float noise = NoisePerlin2D(np_apple_trees, p.X, p.Y, seed);
+
+ return noise > 0.2;
+}
+
+
float MapgenV6::getMudAmount(int index)
{
if (flags & MG_FLAT)
x + 0.5 * noise_height_select->np->spread.X,
z + 0.5 * noise_height_select->np->spread.Z);
}
-
- if (flags & MG_TREES) {
- noise_trees->perlinMap2D(
- x + 0.5 * noise_trees->np->spread.X,
- z + 0.5 * noise_trees->np->spread.Z);
- }
if (!(flags & MG_FLAT)) {
noise_mud->perlinMap2D(
void MapgenV6::placeTrees() {
+ //TimeTaker t("placeTrees");
+
// Divide area into parts
s16 div = 8;
s16 sidelen = central_area_size.X / div;
node_min.X + sidelen + sidelen * x0 - 1,
node_min.Z + sidelen + sidelen * z0 - 1
);
- // Amount of trees
- u32 tree_count = area * getTreeAmount(p2d_center); /////////////optimize this!
+
+ // Amount of trees, jungle area
+ u32 tree_count = area * getTreeAmount(p2d_center);
+ bool is_jungle = (flags & MGV6_JUNGLES) && (getHumidity(p2d_center) > 0.75);
+ if (is_jungle)
+ tree_count *= 4;
+
// Put trees in random places on part of division
for (u32 i = 0; i < tree_count; i++) {
s16 x = myrand_range(p2d_min.X, p2d_max.X);
continue;
}
p.Y++;
+
// Make a tree
- treegen::make_tree(*vm, p, false, ndef, myrand());
+ if (is_jungle) {
+ treegen::make_jungletree(*vm, p, ndef, myrand());
+ } else {
+ bool is_apple_tree = (myrand_range(0, 3) == 0) &&
+ getHaveAppleTree(v2s16(x, z));
+ treegen::make_tree(*vm, p, is_apple_tree, ndef, myrand());
+ }
}
}
+ //printf("placeTrees: %dms\n", t.stop());
}
extern NoiseParams nparams_v6_def_terrain_higher;
extern NoiseParams nparams_v6_def_steepness;
extern NoiseParams nparams_v6_def_height_select;
-extern NoiseParams nparams_v6_def_trees;
extern NoiseParams nparams_v6_def_mud;
extern NoiseParams nparams_v6_def_beach;
extern NoiseParams nparams_v6_def_biome;
extern NoiseParams nparams_v6_def_cave;
+extern NoiseParams nparams_v6_def_humidity;
+extern NoiseParams nparams_v6_def_trees;
+extern NoiseParams nparams_v6_def_apple_trees;
struct MapgenV6Params : public MapgenParams {
float freq_desert;
NoiseParams *np_terrain_higher;
NoiseParams *np_steepness;
NoiseParams *np_height_select;
- NoiseParams *np_trees;
NoiseParams *np_mud;
NoiseParams *np_beach;
NoiseParams *np_biome;
NoiseParams *np_cave;
-
+ NoiseParams *np_humidity;
+ NoiseParams *np_trees;
+ NoiseParams *np_apple_trees;
+
MapgenV6Params() {
freq_desert = 0.45;
freq_beach = 0.15;
np_terrain_higher = &nparams_v6_def_terrain_higher;
np_steepness = &nparams_v6_def_steepness;
np_height_select = &nparams_v6_def_height_select;
- np_trees = &nparams_v6_def_trees;
np_mud = &nparams_v6_def_mud;
np_beach = &nparams_v6_def_beach;
np_biome = &nparams_v6_def_biome;
np_cave = &nparams_v6_def_cave;
+ np_humidity = &nparams_v6_def_humidity;
+ np_trees = &nparams_v6_def_trees;
+ np_apple_trees = &nparams_v6_def_apple_trees;
+
}
bool readParams(Settings *settings);
Noise *noise_terrain_higher;
Noise *noise_steepness;
Noise *noise_height_select;
- Noise *noise_trees;
Noise *noise_mud;
Noise *noise_beach;
Noise *noise_biome;
NoiseParams *np_cave;
+ NoiseParams *np_humidity;
+ NoiseParams *np_trees;
+ NoiseParams *np_apple_trees;
float freq_desert;
float freq_beach;
bool block_is_underground(u64 seed, v3s16 blockpos);
s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
+ float getHumidity(v2s16 p);
float getTreeAmount(v2s16 p);
- float getTreeAmount(int index);
+ bool getHaveAppleTree(v2s16 p);
float getMudAmount(v2s16 p);
float getMudAmount(int index);
bool getHaveBeach(v2s16 p);
void make_jungletree(VoxelManipulator &vmanip, v3s16 p0,
INodeDefManager *ndef, int seed)
{
- MapNode treenode(ndef->getId("mapgen_jungletree"));
- MapNode leavesnode(ndef->getId("mapgen_leaves"));
+ content_t c_tree = ndef->getId("mapgen_jungletree");
+ content_t c_leaves = ndef->getId("mapgen_jungleleaves");
+ if (c_tree == CONTENT_IGNORE)
+ c_tree = ndef->getId("mapgen_tree");
+ if (c_leaves == CONTENT_IGNORE)
+ c_leaves = ndef->getId("mapgen_leaves");
+
+ MapNode treenode(c_tree);
+ MapNode leavesnode(c_leaves);
PseudoRandom pr(seed);
for(s16 x=-1; x<=1; x++)