aboutsummaryrefslogtreecommitdiff
path: root/src/content_abm.cpp
diff options
context:
space:
mode:
authorWeblate <42@minetest.ru>2013-03-30 19:49:52 +0100
committerWeblate <42@minetest.ru>2013-03-30 19:49:52 +0100
commita0566270d9fa075afa36a7e3e68c690b1b23ba90 (patch)
tree6bc88127ee67b7bf4d6a2d6f9d0a9e5f997d1dd1 /src/content_abm.cpp
parent0d83bdc3aa9f1077836aacb833ac4ad9bbb9a4f4 (diff)
parent1aa50b13622c1e264044839ecdf0152670dae6ce (diff)
downloadminetest-a0566270d9fa075afa36a7e3e68c690b1b23ba90.tar.gz
minetest-a0566270d9fa075afa36a7e3e68c690b1b23ba90.tar.bz2
minetest-a0566270d9fa075afa36a7e3e68c690b1b23ba90.zip
Merge remote branch 'origin/master'
Diffstat (limited to 'src/content_abm.cpp')
-rw-r--r--src/content_abm.cpp56
1 files changed, 38 insertions, 18 deletions
diff --git a/src/content_abm.cpp b/src/content_abm.cpp
index 03fc82ed4..ccd9ca19c 100644
--- a/src/content_abm.cpp
+++ b/src/content_abm.cpp
@@ -94,11 +94,22 @@ public:
class MakeTreesFromSaplingsABM : public ActiveBlockModifier
{
private:
+ content_t c_junglesapling;
+ content_t c_dirt;
+ content_t c_dirt_with_grass;
+
public:
+ MakeTreesFromSaplingsABM(ServerEnvironment *env, INodeDefManager *nodemgr) {
+ c_junglesapling = nodemgr->getId("junglesapling");
+ c_dirt = nodemgr->getId("mapgen_dirt");
+ c_dirt_with_grass = nodemgr->getId("mapgen_dirt_with_grass");
+ }
+
virtual std::set<std::string> getTriggerContents()
{
std::set<std::string> s;
s.insert("sapling");
+ s.insert("junglesapling");
return s;
}
virtual float getTriggerInterval()
@@ -111,37 +122,46 @@ public:
INodeDefManager *ndef = env->getGameDef()->ndef();
ServerMap *map = &env->getServerMap();
- actionstream<<"A sapling grows into a tree at "
- <<PP(p)<<std::endl;
+ MapNode n_below = map->getNodeNoEx(p - v3s16(0, 1, 0));
+ if (n_below.getContent() != c_dirt &&
+ n_below.getContent() != c_dirt_with_grass)
+ return;
+
+ bool is_jungle_tree = n.getContent() == c_junglesapling;
+
+ actionstream <<"A " << (is_jungle_tree ? "jungle " : "")
+ << "sapling grows into a tree at "
+ << PP(p) << std::endl;
- core::map<v3s16, MapBlock*> modified_blocks;
+ std::map<v3s16, MapBlock*> modified_blocks;
v3s16 tree_p = p;
ManualMapVoxelManipulator vmanip(map);
v3s16 tree_blockp = getNodeBlockPos(tree_p);
vmanip.initialEmerge(tree_blockp - v3s16(1,1,1), tree_blockp + v3s16(1,1,1));
- bool is_apple_tree = myrand()%4 == 0;
- treegen::make_tree(vmanip, tree_p, is_apple_tree, ndef, myrand());
+
+ if (is_jungle_tree) {
+ treegen::make_jungletree(vmanip, tree_p, ndef, myrand());
+ } else {
+ bool is_apple_tree = myrand() % 4 == 0;
+ treegen::make_tree(vmanip, tree_p, is_apple_tree, ndef, myrand());
+ }
+
vmanip.blitBackAll(&modified_blocks);
// update lighting
- core::map<v3s16, MapBlock*> lighting_modified_blocks;
- for(core::map<v3s16, MapBlock*>::Iterator
- i = modified_blocks.getIterator();
- i.atEnd() == false; i++)
- {
- lighting_modified_blocks.insert(i.getNode()->getKey(), i.getNode()->getValue());
- }
+ std::map<v3s16, MapBlock*> lighting_modified_blocks;
+ lighting_modified_blocks.insert(modified_blocks.begin(), modified_blocks.end());
map->updateLighting(lighting_modified_blocks, modified_blocks);
// Send a MEET_OTHER event
MapEditEvent event;
event.type = MEET_OTHER;
- for(core::map<v3s16, MapBlock*>::Iterator
- i = modified_blocks.getIterator();
- i.atEnd() == false; i++)
+// event.modified_blocks.insert(modified_blocks.begin(), modified_blocks.end());
+ for(std::map<v3s16, MapBlock*>::iterator
+ i = modified_blocks.begin();
+ i != modified_blocks.end(); ++i)
{
- v3s16 p = i.getNode()->getKey();
- event.modified_blocks.insert(p, true);
+ event.modified_blocks.insert(i->first);
}
map->dispatchEvent(&event);
}
@@ -182,7 +202,7 @@ void add_legacy_abms(ServerEnvironment *env, INodeDefManager *nodedef)
{
env->addActiveBlockModifier(new GrowGrassABM());
env->addActiveBlockModifier(new RemoveGrassABM());
- env->addActiveBlockModifier(new MakeTreesFromSaplingsABM());
+ env->addActiveBlockModifier(new MakeTreesFromSaplingsABM(env, nodedef));
if (g_settings->getBool("liquid_finite"))
env->addActiveBlockModifier(new LiquidFlowABM(env, nodedef));
}