diff --git a/src/environment.cpp b/src/environment.cpp index 135e41e..a2b2df6 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -1322,8 +1322,10 @@ void ServerEnvironment::step(float dtime) }else if (content_features(testnode).draw_type == CDT_MELONLIKE) { if (content_features(testnode).param2_type == CPT_PLANTGROWTH) plantgrowth_plant(this,test_p); + }else if (testnode.getContent() == CONTENT_CACTUS) { + plantgrowth_cactus(this,test_p); }else if (testnode.getContent() == CONTENT_FERTILIZER) { - plantgrowth_fertilizer(this,test_p); + plantgrowth_fertilizer(this,test_p); }else if (testnode.getContent() == CONTENT_AIR) { int chance = 5; if (water_found == 1) diff --git a/src/plantgrowth.cpp b/src/plantgrowth.cpp index 1b75b41..8ed1f6b 100644 --- a/src/plantgrowth.cpp +++ b/src/plantgrowth.cpp @@ -558,3 +558,22 @@ void plantgrowth_grass(ServerEnvironment *env, v3s16 p0) if (add) env->getMap().addNodeWithEvent(p0,n); } + +void plantgrowth_cactus(ServerEnvironment *env, v3s16 p0) +{ + int height = 1; + for (;; height++) { + MapNode nn = env->getMap().getNodeNoEx(p0+v3s16(0,height,0)); + if (nn.getContent() == CONTENT_AIR) { + break; + }else if (nn.getContent() != CONTENT_CACTUS || nn.envticks < 5) { + return; + } + } + + if (height > 4 || myrand_range(0,3) != 0) + return; + + MapNode n(CONTENT_CACTUS); + env->getMap().addNodeWithEvent(p0+v3s16(0,height,0),n); +} diff --git a/src/plantgrowth.h b/src/plantgrowth.h index 8c77994..3bb289f 100644 --- a/src/plantgrowth.h +++ b/src/plantgrowth.h @@ -32,5 +32,6 @@ void plantgrowth_fertilizer(ServerEnvironment *env, v3s16 p0); void plantgrowth_seed(ServerEnvironment *env, v3s16 p0); void plantgrowth_plant(ServerEnvironment *env, v3s16 p0, s16 height=0); void plantgrowth_grass(ServerEnvironment *env, v3s16 p0); +void plantgrowth_cactus(ServerEnvironment *env, v3s16 p0); #endif