@@ -25,149 +25,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
25
25
#include " content_sao.h"
26
26
#include " settings.h"
27
27
#include " mapblock.h" // For getNodeBlockPos
28
- #include " treegen.h" // For treegen::make_tree
29
28
#include " main.h" // for g_settings
30
29
#include " map.h"
31
30
#include " scripting_game.h"
32
31
#include " log.h"
33
32
34
33
#define PP (x ) " (" <<(x).X<<" ," <<(x).Y<<" ," <<(x).Z<<" )"
35
34
36
- class GrowGrassABM : public ActiveBlockModifier
37
- {
38
- private:
39
- public:
40
- virtual std::set<std::string> getTriggerContents ()
41
- {
42
- std::set<std::string> s;
43
- s.insert (" mapgen_dirt" );
44
- return s;
45
- }
46
- virtual float getTriggerInterval ()
47
- { return 2.0 ; }
48
- virtual u32 getTriggerChance ()
49
- { return 200 ; }
50
- virtual void trigger (ServerEnvironment *env, v3s16 p, MapNode n)
51
- {
52
- INodeDefManager *ndef = env->getGameDef ()->ndef ();
53
- ServerMap *map = &env->getServerMap ();
54
-
55
- MapNode n_top = map->getNodeNoEx (p+v3s16 (0 ,1 ,0 ));
56
- content_t c_snow = ndef->getId (" snow" );
57
- if (ndef->get (n_top).light_propagates &&
58
- !ndef->get (n_top).isLiquid () &&
59
- n_top.getLightBlend (env->getDayNightRatio (), ndef) >= 13 )
60
- {
61
- if (c_snow != CONTENT_IGNORE && n_top.getContent () == c_snow)
62
- n.setContent (ndef->getId (" dirt_with_snow" ));
63
- else
64
- n.setContent (ndef->getId (" mapgen_dirt_with_grass" ));
65
- map->addNodeWithEvent (p, n);
66
- }
67
- }
68
- };
69
-
70
- class RemoveGrassABM : public ActiveBlockModifier
71
- {
72
- private:
73
- public:
74
- virtual std::set<std::string> getTriggerContents ()
75
- {
76
- std::set<std::string> s;
77
- s.insert (" mapgen_dirt_with_grass" );
78
- return s;
79
- }
80
- virtual float getTriggerInterval ()
81
- { return 2.0 ; }
82
- virtual u32 getTriggerChance ()
83
- { return 20 ; }
84
- virtual void trigger (ServerEnvironment *env, v3s16 p, MapNode n)
85
- {
86
- INodeDefManager *ndef = env->getGameDef ()->ndef ();
87
- ServerMap *map = &env->getServerMap ();
88
-
89
- MapNode n_top = map->getNodeNoEx (p+v3s16 (0 ,1 ,0 ));
90
- if ((!ndef->get (n_top).light_propagates &&
91
- n_top.getContent () != CONTENT_IGNORE) ||
92
- ndef->get (n_top).isLiquid ())
93
- {
94
- n.setContent (ndef->getId (" mapgen_dirt" ));
95
- map->addNodeWithEvent (p, n);
96
- }
97
- }
98
- };
99
-
100
- class MakeTreesFromSaplingsABM : public ActiveBlockModifier
101
- {
102
- private:
103
- content_t c_junglesapling;
104
-
105
- public:
106
- MakeTreesFromSaplingsABM (ServerEnvironment *env, INodeDefManager *nodemgr) {
107
- c_junglesapling = nodemgr->getId (" junglesapling" );
108
- }
109
-
110
- virtual std::set<std::string> getTriggerContents ()
111
- {
112
- std::set<std::string> s;
113
- s.insert (" sapling" );
114
- s.insert (" junglesapling" );
115
- return s;
116
- }
117
- virtual float getTriggerInterval ()
118
- { return 10.0 ; }
119
- virtual u32 getTriggerChance ()
120
- { return 50 ; }
121
- virtual void trigger (ServerEnvironment *env, v3s16 p, MapNode n,
122
- u32 active_object_count, u32 active_object_count_wider)
123
- {
124
- INodeDefManager *ndef = env->getGameDef ()->ndef ();
125
- ServerMap *map = &env->getServerMap ();
126
-
127
- MapNode n_below = map->getNodeNoEx (p - v3s16 (0 , 1 , 0 ));
128
- if (!((ItemGroupList) ndef->get (n_below).groups )[" soil" ])
129
- return ;
130
-
131
- bool is_jungle_tree = n.getContent () == c_junglesapling;
132
-
133
- actionstream <<" A " << (is_jungle_tree ? " jungle " : " " )
134
- << " sapling grows into a tree at "
135
- << PP (p) << std::endl;
136
-
137
- std::map<v3s16, MapBlock*> modified_blocks;
138
- v3s16 tree_p = p;
139
- ManualMapVoxelManipulator vmanip (map);
140
- v3s16 tree_blockp = getNodeBlockPos (tree_p);
141
- vmanip.initialEmerge (tree_blockp - v3s16 (1 ,1 ,1 ), tree_blockp + v3s16 (1 ,1 ,1 ));
142
-
143
- if (is_jungle_tree) {
144
- treegen::make_jungletree (vmanip, tree_p, ndef, myrand ());
145
- } else {
146
- bool is_apple_tree = myrand () % 4 == 0 ;
147
- treegen::make_tree (vmanip, tree_p, is_apple_tree, ndef, myrand ());
148
- }
149
-
150
- vmanip.blitBackAll (&modified_blocks);
151
-
152
- // update lighting
153
- std::map<v3s16, MapBlock*> lighting_modified_blocks;
154
- lighting_modified_blocks.insert (modified_blocks.begin (), modified_blocks.end ());
155
- map->updateLighting (lighting_modified_blocks, modified_blocks);
156
-
157
- // Send a MEET_OTHER event
158
- MapEditEvent event;
159
- event.type = MEET_OTHER;
160
- // event.modified_blocks.insert(modified_blocks.begin(), modified_blocks.end());
161
- for (std::map<v3s16, MapBlock*>::iterator
162
- i = modified_blocks.begin ();
163
- i != modified_blocks.end (); ++i)
164
- {
165
- event.modified_blocks .insert (i->first );
166
- }
167
- map->dispatchEvent (&event);
168
- }
169
- };
170
-
171
35
class LiquidFlowABM : public ActiveBlockModifier {
172
36
private:
173
37
std::set<std::string> contents;
@@ -370,9 +234,6 @@ class LiquidMeltAround : public LiquidMeltHot {
370
234
*/
371
235
372
236
void add_legacy_abms (ServerEnvironment *env, INodeDefManager *nodedef) {
373
- env->addActiveBlockModifier (new GrowGrassABM ());
374
- env->addActiveBlockModifier (new RemoveGrassABM ());
375
- env->addActiveBlockModifier (new MakeTreesFromSaplingsABM (env, nodedef));
376
237
if (g_settings->getBool (" liquid_finite" )) {
377
238
env->addActiveBlockModifier (new LiquidFlowABM (env, nodedef));
378
239
env->addActiveBlockModifier (new LiquidDropABM (env, nodedef));
0 commit comments