+
+ float humidity;
+ bool is_jungle = false;
+ if (flags & MGV6_JUNGLES) {
+ humidity = getHumidity(p2d_center);
+ if (humidity > 0.75) {
+ is_jungle = true;
+ tree_count *= 4;
+ }
+ }
+
+ // Add jungle grass
+ if (is_jungle) {
+ u32 grass_count = 5 * humidity * tree_count;
+ for (u32 i = 0; i < grass_count; i++) {
+ s16 x = grassrandom.range(p2d_min.X, p2d_max.X);
+ s16 z = grassrandom.range(p2d_min.Y, p2d_max.Y);
+
+ s16 y = find_ground_level(v2s16(x, z)); ////////////////optimize this!
+ if (y < water_level || y < node_min.Y || y > node_max.Y)
+ continue;
+
+ u32 vi = vm->m_area.index(x, y, z);
+ // place on dirt_with_grass, since we know it is exposed to sunlight
+ if (vm->m_data[vi].getContent() == c_dirt_with_grass) {
+ vm->m_area.add_y(em, vi, 1);
+ vm->m_data[vi] = n_junglegrass;
+ }
+ }
+ }