re-enable cactus farming

This commit is contained in:
darkrose 2015-11-07 15:13:34 +10:00
parent df09ff870e
commit 6bef605fb0
3 changed files with 23 additions and 1 deletions

View File

@ -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)

View File

@ -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);
}

View File

@ -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