aboutsummaryrefslogtreecommitdiff
path: root/src/content_abm.cpp
diff options
context:
space:
mode:
authorWeblate <42@minetest.ru>2013-06-01 13:18:52 +0200
committerWeblate <42@minetest.ru>2013-06-01 13:18:52 +0200
commit1dfc2e02b3c358af4bb20bb3cb60ac7bd3ed1124 (patch)
tree54660f353f3342f89b6259ea6a5dfedfa20dc16f /src/content_abm.cpp
parentec039a3d123120f9918812b13f5971e94546b9af (diff)
parent64627817fcca52f20948c24b60ce192b218f6ce2 (diff)
downloadminetest-1dfc2e02b3c358af4bb20bb3cb60ac7bd3ed1124.tar.gz
minetest-1dfc2e02b3c358af4bb20bb3cb60ac7bd3ed1124.tar.bz2
minetest-1dfc2e02b3c358af4bb20bb3cb60ac7bd3ed1124.zip
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src/content_abm.cpp')
-rw-r--r--src/content_abm.cpp56
1 files changed, 46 insertions, 10 deletions
diff --git a/src/content_abm.cpp b/src/content_abm.cpp
index e20201dcf..3704fe83d 100644
--- a/src/content_abm.cpp
+++ b/src/content_abm.cpp
@@ -99,14 +99,10 @@ 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");
+ c_junglesapling = nodemgr->getId("junglesapling");
}
virtual std::set<std::string> getTriggerContents()
@@ -127,8 +123,7 @@ public:
ServerMap *map = &env->getServerMap();
MapNode n_below = map->getNodeNoEx(p - v3s16(0, 1, 0));
- if (n_below.getContent() != c_dirt &&
- n_below.getContent() != c_dirt_with_grass)
+ if (!((ItemGroupList) ndef->get(n_below).groups)["soil"])
return;
bool is_jungle_tree = n.getContent() == c_junglesapling;
@@ -196,17 +191,58 @@ public:
virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n)
{
ServerMap *map = &env->getServerMap();
- if (map->transforming_liquid_size() < 500)
- map->transforming_liquid_add(p);
+ if (map->transforming_liquid_size() > 500)
+ return;
+ map->transforming_liquid_add(p);
//if ((*map).m_transforming_liquid.size() < 500) (*map).m_transforming_liquid.push_back(p);
}
};
+class LiquidDropABM : public ActiveBlockModifier
+{
+private:
+ std::set<std::string> contents;
+
+public:
+ LiquidDropABM(ServerEnvironment *env, INodeDefManager *nodemgr)
+ {
+ std::set<content_t> liquids;
+ nodemgr->getIds("group:liquid", liquids);
+ for(std::set<content_t>::const_iterator k = liquids.begin(); k != liquids.end(); k++)
+ contents.insert(nodemgr->get(*k).liquid_alternative_source);
+ }
+ virtual std::set<std::string> getTriggerContents()
+ { return contents; }
+ virtual std::set<std::string> getRequiredNeighbors()
+ {
+ std::set<std::string> neighbors;
+ neighbors.insert("mapgen_air");
+ return neighbors;
+ }
+ virtual float getTriggerInterval()
+ { return 20.0; }
+ virtual u32 getTriggerChance()
+ { return 10; }
+ virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n)
+ {
+ ServerMap *map = &env->getServerMap();
+ if (map->transforming_liquid_size() > 500)
+ return;
+ //todo: look around except top
+ MapNode n_below = map->getNodeNoEx(p - v3s16(0, 1, 0));
+ if (n_below.getContent() != CONTENT_AIR)
+ return;
+ map->transforming_liquid_add(p);
+ }
+};
+
void add_legacy_abms(ServerEnvironment *env, INodeDefManager *nodedef)
{
env->addActiveBlockModifier(new GrowGrassABM());
env->addActiveBlockModifier(new RemoveGrassABM());
env->addActiveBlockModifier(new MakeTreesFromSaplingsABM(env, nodedef));
- if (g_settings->getBool("liquid_finite"))
+ if (g_settings->getBool("liquid_finite")) {
env->addActiveBlockModifier(new LiquidFlowABM(env, nodedef));
+ env->addActiveBlockModifier(new LiquidDropABM(env, nodedef));
+ }
}