diff options
author | Sebastian Rühl <bahamada_basti@yahoo.de> | 2011-06-26 13:47:21 +0200 |
---|---|---|
committer | Sebastian Rühl <bahamada_basti@yahoo.de> | 2011-06-26 13:47:21 +0200 |
commit | 13cf5425db613dc0a4323c87a4988bb18fb87aca (patch) | |
tree | cde1e5f47f191beb4a9cefcd87872aef53b5fcec | |
parent | fb6ac9a1a6b68e87665a9e1692295230ebcef8db (diff) | |
download | minetest-13cf5425db613dc0a4323c87a4988bb18fb87aca.tar.gz minetest-13cf5425db613dc0a4323c87a4988bb18fb87aca.tar.bz2 minetest-13cf5425db613dc0a4323c87a4988bb18fb87aca.zip |
backported cactus, papyrus and clay
-rw-r--r-- | data/heart.png | bin | 308 -> 258 bytes | |||
-rw-r--r-- | heart.png | bin | 258 -> 0 bytes | |||
-rw-r--r-- | src/mapgen.cpp | 77 |
3 files changed, 67 insertions, 10 deletions
diff --git a/data/heart.png b/data/heart.png Binary files differindex 6bc183e04..bea1aefd6 100644 --- a/data/heart.png +++ b/data/heart.png diff --git a/heart.png b/heart.png Binary files differdeleted file mode 100644 index bea1aefd6..000000000 --- a/heart.png +++ /dev/null diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 801dd72b1..71696a349 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -151,6 +151,34 @@ static void make_tree(VoxelManipulator &vmanip, v3s16 p0) } } +void make_papyrus(VoxelManipulator &vmanip, v3s16 p0) +{ + MapNode papyrusnode(CONTENT_PAPYRUS); + + s16 trunk_h = myrand_range(2, 3); + v3s16 p1 = p0; + for(s16 ii=0; ii<trunk_h; ii++) + { + if(vmanip.m_area.contains(p1)) + vmanip.m_data[vmanip.m_area.index(p1)] = papyrusnode; + p1.Y++; + } +} + +void make_cactus(VoxelManipulator &vmanip, v3s16 p0) +{ + MapNode cactusnode(CONTENT_CACTUS); + + s16 trunk_h = 3; + v3s16 p1 = p0; + for(s16 ii=0; ii<trunk_h; ii++) + { + if(vmanip.m_area.contains(p1)) + vmanip.m_data[vmanip.m_area.index(p1)] = cactusnode; + p1.Y++; + } +} + #if 0 static void make_randomstone(VoxelManipulator &vmanip, v3s16 p0) { @@ -1752,6 +1780,15 @@ void make_block(BlockMakeData *data) u32 current_depth = 0; bool air_detected = false; bool water_detected = false; + bool have_clay = false; + + // Determine whether to have clay in the sand here + double claynoise = noise2d_perlin( + 0.5+(float)p2d.X/500, 0.5+(float)p2d.Y/500, + data->seed+4321, 6, 0.95); + + have_clay = have_sand && (claynoise > 1.25); + // Use fast index incrementing s16 start_y = node_max.Y+2; v3s16 em = vmanip.m_area.getExtent(); @@ -1778,7 +1815,10 @@ void make_block(BlockMakeData *data) { if(have_sand) { - vmanip.m_data[i] = MapNode(CONTENT_SAND); + if (have_clay) + vmanip.m_data[i] = MapNode(CONTENT_CLAY); + else + vmanip.m_data[i] = MapNode(CONTENT_SAND); } #if 1 else if(current_depth==0 && !water_detected @@ -1823,7 +1863,7 @@ void make_block(BlockMakeData *data) //s16 y = find_ground_level(data->vmanip, v2s16(x,z)); s16 y = find_ground_level_from_noise(data->seed, v2s16(x,z), 4); // Don't make a tree under water level - if(y < WATER_LEVEL) + if(y < WATER_LEVEL - 1) continue; // Make sure tree fits (only trees whose starting point is // at this block are added) @@ -1847,19 +1887,36 @@ void make_block(BlockMakeData *data) // If not found, handle next one if(found == false) continue; - /* - Trees grow only on mud and grass - */ + { u32 i = data->vmanip->m_area.index(p); MapNode *n = &data->vmanip->m_data[i]; - if(n->d != CONTENT_MUD && n->d != CONTENT_GRASS) + + if(n->d != CONTENT_MUD && n->d != CONTENT_GRASS && n->d != CONTENT_SAND) + continue; + + // Papyrus grows only on mud and in water + if(n->d == CONTENT_MUD && y == WATER_LEVEL - 1) + { + p.Y++; + make_papyrus(vmanip, p); + } + // Don't make a tree under water level + if(y < WATER_LEVEL) continue; + // Trees grow only on mud and grass + if(n->d == CONTENT_MUD || n->d == CONTENT_GRASS) + { + p.Y++; + make_tree(vmanip, p); + } + // Cactii grow only on sand + else if(n->d == CONTENT_SAND) + { + p.Y++; + make_cactus(vmanip, p); + } } - // Tree will be placed one higher - p.Y++; - // Make a tree - make_tree(vmanip, p); } #if 0 |