From 13cf5425db613dc0a4323c87a4988bb18fb87aca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20R=C3=BChl?= <bahamada_basti@yahoo.de> Date: Sun, 26 Jun 2011 13:47:21 +0200 Subject: [PATCH] backported cactus, papyrus and clay --- data/heart.png | Bin 308 -> 258 bytes heart.png | Bin 258 -> 0 bytes src/mapgen.cpp | 77 ++++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 67 insertions(+), 10 deletions(-) delete mode 100644 heart.png diff --git a/data/heart.png b/data/heart.png index 6bc183e04f21cba17b52009e89bb52072d5a0afd..bea1aefd6b22e3268f88db0eb26188b1cb362f81 100644 GIT binary patch delta 210 zcmdnO)WkGFg^RH`$lZxy-8q?;6AdNm*-JcqUD<E5N{JgYIi#M~V_;yI;_2cTVsU!u z<cqwA6?k0cFV1th{z7KWMAI3{*;|Y+_CGilz&@);h^cTNJBL7nXngkN>Ul2`Ztq^h z%6Wus(MN_#k&c#Rqvci~8eNVruHah1HOt9r-kld3hS!R={qj(qEUsqCE70)axZ#&+ z%WTUEj@wMr-raG)`+lQoUE_@p;t4F7hxH!tJZjy|HDUhJ)?dnnoJL&x8GD~<EiQ3% S2xeelVDNPHb6Mw<&;$S#{#Ew? delta 260 zcmZo-+QKwJg_ot+$uoq5gM*`nBc)@ao<#jMPZ!4!i{7)BZ2g!G1==1S=iofGWYJT$ z0+BohS<REYI~Y|<IMq)CEq%(dlQG0&B}eEA39dZ{b?z-`374vTbMbrSpTqH!Po3m7 zJn@t3am;?TzJd<-JL0?k2Gz7ZwyFOo#pGAml(=rcpl^Dyu#%ObVw_d>`Xjk!|1LWA zem-?8M?rpR>U!U>`?>iZyK4WXB^#)f@@DC5c%vOB=s$ILMzZgjuFv5!1?6qocnde4 zelTf9_>tnIE#7yGPOV*6Y!ZFsYWg1Kz2Z&mKGkwdzRUY~vb)?;`X^t*BpQ}2cIEsE R9R>yl22WQ%mvv4FO#r@7ZR`L5 diff --git a/heart.png b/heart.png deleted file mode 100644 index bea1aefd6b22e3268f88db0eb26188b1cb362f81..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 258 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s77>k44ofy`glX=O&z`$AH z5n0T@z;^_M8K-LVNi#4ou$OrHy0YJ9l@d2*a!5U|$H2fa#nZ(x#NzbQ$rpJKEAY6? zU!3Q1{e{e$iKa7@v$q&u?0;}9fPGex5L4kkb`F6C(fI7k)$?8?+}^#0mGcPOqK^!f zA{{NsM$4@}G`bvLT*0-1YnGGMygM&646hY!`{kiJSzOJOSD@j;al<dumX#G8x0$BB zyW@cO{YKNe#v32R6Ie12>pkFk)ViB%!u+MJzmy9(jkxwR_CD2GT;k{u%)r3F;OXk; Jvd$@?2>{+3Tmb+8 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 -- GitLab