Actually fill in the NewNameGetter names to allow map generator operation and crafting
[oweals/minetest.git] / src / content_mapnode.cpp
1 /*
2 Minetest-c55
3 Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "content_mapnode.h"
21
22 #include "irrlichttypes.h"
23 #include "mapnode.h"
24 #include "content_nodemeta.h"
25 #include "nodedef.h"
26 #include "utility.h"
27 #include "nameidmapping.h"
28 #include <map>
29
30 /*
31         Legacy node definitions
32 */
33
34 #define WATER_ALPHA 160
35
36 #define WATER_VISC 1
37 #define LAVA_VISC 7
38
39 void setConstantMaterialProperties(MaterialProperties &mprop, float time)
40 {
41         mprop.diggability = DIGGABLE_CONSTANT;
42         mprop.constant_time = time;
43 }
44
45 void setStoneLikeMaterialProperties(MaterialProperties &mprop, float toughness)
46 {
47         mprop.diggability = DIGGABLE_NORMAL;
48         mprop.weight = 5.0 * toughness;
49         mprop.crackiness = 1.0;
50         mprop.crumbliness = -0.1;
51         mprop.cuttability = -0.2;
52 }
53
54 void setDirtLikeMaterialProperties(MaterialProperties &mprop, float toughness)
55 {
56         mprop.diggability = DIGGABLE_NORMAL;
57         mprop.weight = toughness * 1.2;
58         mprop.crackiness = 0;
59         mprop.crumbliness = 1.2;
60         mprop.cuttability = -0.4;
61 }
62
63 void setGravelLikeMaterialProperties(MaterialProperties &mprop, float toughness)
64 {
65         mprop.diggability = DIGGABLE_NORMAL;
66         mprop.weight = toughness * 2.0;
67         mprop.crackiness = 0.2;
68         mprop.crumbliness = 1.5;
69         mprop.cuttability = -1.0;
70 }
71
72 void setWoodLikeMaterialProperties(MaterialProperties &mprop, float toughness)
73 {
74         mprop.diggability = DIGGABLE_NORMAL;
75         mprop.weight = toughness * 1.0;
76         mprop.crackiness = 0.75;
77         mprop.crumbliness = -1.0;
78         mprop.cuttability = 1.5;
79 }
80
81 void setLeavesLikeMaterialProperties(MaterialProperties &mprop, float toughness)
82 {
83         mprop.diggability = DIGGABLE_NORMAL;
84         mprop.weight = -0.5 * toughness;
85         mprop.crackiness = 0;
86         mprop.crumbliness = 0;
87         mprop.cuttability = 2.0;
88 }
89
90 void setGlassLikeMaterialProperties(MaterialProperties &mprop, float toughness)
91 {
92         mprop.diggability = DIGGABLE_NORMAL;
93         mprop.weight = 0.1 * toughness;
94         mprop.crackiness = 2.0;
95         mprop.crumbliness = -1.0;
96         mprop.cuttability = -1.0;
97 }
98
99 /*
100         Legacy node content type IDs
101         Ranges:
102         0x000...0x07f (0...127): param2 is fully usable
103         126 and 127 are reserved (CONTENT_AIR and CONTENT_IGNORE).
104         0x800...0xfff (2048...4095): higher 4 bytes of param2 are not usable
105 */
106 #define CONTENT_STONE 0
107 #define CONTENT_WATER 2
108 #define CONTENT_TORCH 3
109 #define CONTENT_WATERSOURCE 9
110 #define CONTENT_SIGN_WALL 14
111 #define CONTENT_CHEST 15
112 #define CONTENT_FURNACE 16
113 #define CONTENT_LOCKABLE_CHEST 17
114 #define CONTENT_FENCE 21
115 #define CONTENT_RAIL 30
116 #define CONTENT_LADDER 31
117 #define CONTENT_LAVA 32
118 #define CONTENT_LAVASOURCE 33
119 #define CONTENT_GRASS 0x800 //1
120 #define CONTENT_TREE 0x801 //4
121 #define CONTENT_LEAVES 0x802 //5
122 #define CONTENT_GRASS_FOOTSTEPS 0x803 //6
123 #define CONTENT_MESE 0x804 //7
124 #define CONTENT_MUD 0x805 //8
125 #define CONTENT_CLOUD 0x806 //10
126 #define CONTENT_COALSTONE 0x807 //11
127 #define CONTENT_WOOD 0x808 //12
128 #define CONTENT_SAND 0x809 //13
129 #define CONTENT_COBBLE 0x80a //18
130 #define CONTENT_STEEL 0x80b //19
131 #define CONTENT_GLASS 0x80c //20
132 #define CONTENT_MOSSYCOBBLE 0x80d //22
133 #define CONTENT_GRAVEL 0x80e //23
134 #define CONTENT_SANDSTONE 0x80f //24
135 #define CONTENT_CACTUS 0x810 //25
136 #define CONTENT_BRICK 0x811 //26
137 #define CONTENT_CLAY 0x812 //27
138 #define CONTENT_PAPYRUS 0x813 //28
139 #define CONTENT_BOOKSHELF 0x814 //29
140 #define CONTENT_JUNGLETREE 0x815
141 #define CONTENT_JUNGLEGRASS 0x816
142 #define CONTENT_NC 0x817
143 #define CONTENT_NC_RB 0x818
144 #define CONTENT_APPLE 0x819
145 #define CONTENT_SAPLING 0x820
146
147 /*
148         A conversion table for backwards compatibility.
149         Maps <=v19 content types to current ones.
150         Should never be touched.
151 */
152 content_t trans_table_19[21][2] = {
153         {CONTENT_GRASS, 1},
154         {CONTENT_TREE, 4},
155         {CONTENT_LEAVES, 5},
156         {CONTENT_GRASS_FOOTSTEPS, 6},
157         {CONTENT_MESE, 7},
158         {CONTENT_MUD, 8},
159         {CONTENT_CLOUD, 10},
160         {CONTENT_COALSTONE, 11},
161         {CONTENT_WOOD, 12},
162         {CONTENT_SAND, 13},
163         {CONTENT_COBBLE, 18},
164         {CONTENT_STEEL, 19},
165         {CONTENT_GLASS, 20},
166         {CONTENT_MOSSYCOBBLE, 22},
167         {CONTENT_GRAVEL, 23},
168         {CONTENT_SANDSTONE, 24},
169         {CONTENT_CACTUS, 25},
170         {CONTENT_BRICK, 26},
171         {CONTENT_CLAY, 27},
172         {CONTENT_PAPYRUS, 28},
173         {CONTENT_BOOKSHELF, 29},
174 };
175
176 MapNode mapnode_translate_from_internal(MapNode n_from, u8 version)
177 {
178         MapNode result = n_from;
179         if(version <= 19)
180         {
181                 content_t c_from = n_from.getContent();
182                 for(u32 i=0; i<sizeof(trans_table_19)/sizeof(trans_table_19[0]); i++)
183                 {
184                         if(trans_table_19[i][0] == c_from)
185                         {
186                                 result.setContent(trans_table_19[i][1]);
187                                 break;
188                         }
189                 }
190         }
191         return result;
192 }
193 MapNode mapnode_translate_to_internal(MapNode n_from, u8 version)
194 {
195         MapNode result = n_from;
196         if(version <= 19)
197         {
198                 content_t c_from = n_from.getContent();
199                 for(u32 i=0; i<sizeof(trans_table_19)/sizeof(trans_table_19[0]); i++)
200                 {
201                         if(trans_table_19[i][1] == c_from)
202                         {
203                                 result.setContent(trans_table_19[i][0]);
204                                 break;
205                         }
206                 }
207         }
208         return result;
209 }
210
211 void content_mapnode_get_name_id_mapping(NameIdMapping *nimap)
212 {
213         nimap->set(0, "stone");
214         nimap->set(2, "water_flowing");
215         nimap->set(3, "torch");
216         nimap->set(9, "water_source");
217         nimap->set(14, "sign_wall");
218         nimap->set(15, "chest");
219         nimap->set(16, "furnace");
220         nimap->set(17, "locked_chest");
221         nimap->set(21, "wooden_fence");
222         nimap->set(30, "rail");
223         nimap->set(31, "ladder");
224         nimap->set(32, "lava_flowing");
225         nimap->set(33, "lava_source");
226         nimap->set(0x800, "dirt_with_grass");
227         nimap->set(0x801, "tree");
228         nimap->set(0x802, "leaves");
229         nimap->set(0x803, "dirt_with_grass_footsteps");
230         nimap->set(0x804, "mese");
231         nimap->set(0x805, "dirt");
232         nimap->set(0x806, "cloud");
233         nimap->set(0x807, "coalstone");
234         nimap->set(0x808, "wood");
235         nimap->set(0x809, "sand");
236         nimap->set(0x80a, "cobble");
237         nimap->set(0x80b, "steel");
238         nimap->set(0x80c, "glass");
239         nimap->set(0x80d, "mossycobble");
240         nimap->set(0x80e, "gravel");
241         nimap->set(0x80f, "sandstone");
242         nimap->set(0x810, "cactus");
243         nimap->set(0x811, "brick");
244         nimap->set(0x812, "clay");
245         nimap->set(0x813, "papyrus");
246         nimap->set(0x814, "bookshelf");
247         nimap->set(0x815, "jungletree");
248         nimap->set(0x816, "junglegrass");
249         nimap->set(0x817, "nyancat");
250         nimap->set(0x818, "nyancat_rainbow");
251         nimap->set(0x819, "apple");
252         nimap->set(0x820, "sapling");
253         // Static types
254         nimap->set(CONTENT_IGNORE, "ignore");
255         nimap->set(CONTENT_AIR, "air");
256 }
257
258 class NewNameGetter
259 {
260 public:
261         NewNameGetter()
262         {
263                 old_to_new["CONTENT_STONE"] = "stone";
264                 old_to_new["CONTENT_WATER"] = "water_flowing";
265                 old_to_new["CONTENT_TORCH"] = "torch";
266                 old_to_new["CONTENT_WATERSOURCE"] = "water_source";
267                 old_to_new["CONTENT_SIGN_WALL"] = "sign_wall";
268                 old_to_new["CONTENT_CHEST"] = "chest";
269                 old_to_new["CONTENT_FURNACE"] = "furnace";
270                 old_to_new["CONTENT_LOCKABLE_CHEST"] = "locked_chest";
271                 old_to_new["CONTENT_FENCE"] = "wooden_fence";
272                 old_to_new["CONTENT_RAIL"] = "rail";
273                 old_to_new["CONTENT_LADDER"] = "ladder";
274                 old_to_new["CONTENT_LAVA"] = "lava_flowing";
275                 old_to_new["CONTENT_LAVASOURCE"] = "lava_source";
276                 old_to_new["CONTENT_GRASS"] = "dirt_with_grass";
277                 old_to_new["CONTENT_TREE"] = "tree";
278                 old_to_new["CONTENT_LEAVES"] = "leaves";
279                 old_to_new["CONTENT_GRASS_FOOTSTEPS"] = "dirt_with_grass_footsteps";
280                 old_to_new["CONTENT_MESE"] = "mese";
281                 old_to_new["CONTENT_MUD"] = "dirt";
282                 old_to_new["CONTENT_CLOUD"] = "cloud";
283                 old_to_new["CONTENT_COALSTONE"] = "coalstone";
284                 old_to_new["CONTENT_WOOD"] = "wood";
285                 old_to_new["CONTENT_SAND"] = "sand";
286                 old_to_new["CONTENT_COBBLE"] = "cobble";
287                 old_to_new["CONTENT_STEEL"] = "steel";
288                 old_to_new["CONTENT_GLASS"] = "glass";
289                 old_to_new["CONTENT_MOSSYCOBBLE"] = "mossycobble";
290                 old_to_new["CONTENT_GRAVEL"] = "gravel";
291                 old_to_new["CONTENT_SANDSTONE"] = "sandstone";
292                 old_to_new["CONTENT_CACTUS"] = "cactus";
293                 old_to_new["CONTENT_BRICK"] = "brick";
294                 old_to_new["CONTENT_CLAY"] = "clay";
295                 old_to_new["CONTENT_PAPYRUS"] = "papyrus";
296                 old_to_new["CONTENT_BOOKSHELF"] = "bookshelf";
297                 old_to_new["CONTENT_JUNGLETREE"] = "jungletree";
298                 old_to_new["CONTENT_JUNGLEGRASS"] = "junglegrass";
299                 old_to_new["CONTENT_NC"] = "nyancat";
300                 old_to_new["CONTENT_NC_RB"] = "nyancat_rainbow";
301                 old_to_new["CONTENT_APPLE"] = "apple";
302                 old_to_new["CONTENT_SAPLING"] = "sapling";
303                 // Just in case
304                 old_to_new["CONTENT_IGNORE"] = "ignore";
305                 old_to_new["CONTENT_AIR"] = "air";
306         }
307         std::string get(const std::string &old)
308         {
309                 std::map<std::string, std::string>::const_iterator i;
310                 i = old_to_new.find(old);
311                 if(i == old_to_new.end())
312                         return "";
313                 return i->second;
314         }
315 private:
316         std::map<std::string, std::string> old_to_new;
317 };
318
319 NewNameGetter newnamegetter;
320
321 std::string content_mapnode_get_new_name(const std::string &oldname)
322 {
323         return newnamegetter.get(oldname);
324 }
325
326 content_t legacy_get_id(const std::string &oldname, INodeDefManager *ndef)
327 {
328         std::string newname = content_mapnode_get_new_name(oldname);
329         if(newname == "")
330                 return CONTENT_IGNORE;
331         content_t id;
332         bool found = ndef->getId(newname, id);
333         if(!found)
334                 return CONTENT_IGNORE;
335         return id;
336 }
337
338 // Initialize default (legacy) node definitions
339 void content_mapnode_init(IWritableNodeDefManager *nodemgr)
340 {
341         content_t i;
342         ContentFeatures f;
343
344         i = CONTENT_STONE;
345         f = ContentFeatures();
346         f.name = "stone";
347         f.setAllTextures("stone.png");
348         f.setInventoryTextureCube("stone.png", "stone.png", "stone.png");
349         f.param_type = CPT_MINERAL;
350         f.is_ground_content = true;
351         f.often_contains_mineral = true;
352         f.dug_item = std::string("MaterialItem2 ")+itos(CONTENT_COBBLE)+" 1";
353         setStoneLikeMaterialProperties(f.material, 1.0);
354         nodemgr->set(i, f);
355
356         i = CONTENT_GRASS;
357         f = ContentFeatures();
358         f.name = "dirt_with_grass";
359         f.setAllTextures("mud.png^grass_side.png");
360         f.setTexture(0, "grass.png");
361         f.setTexture(1, "mud.png");
362         f.param_type = CPT_MINERAL;
363         f.is_ground_content = true;
364         f.dug_item = std::string("MaterialItem2 ")+itos(CONTENT_MUD)+" 1";
365         setDirtLikeMaterialProperties(f.material, 1.0);
366         nodemgr->set(i, f);
367
368         i = CONTENT_GRASS_FOOTSTEPS;
369         f = ContentFeatures();
370         f.name = "dirt_with_grass_footsteps";
371         f.setAllTextures("mud.png^grass_side.png");
372         f.setTexture(0, "grass_footsteps.png");
373         f.setTexture(1, "mud.png");
374         f.param_type = CPT_MINERAL;
375         f.is_ground_content = true;
376         f.dug_item = std::string("MaterialItem2 ")+itos(CONTENT_MUD)+" 1";
377         setDirtLikeMaterialProperties(f.material, 1.0);
378         nodemgr->set(i, f);
379
380         i = CONTENT_MUD;
381         f = ContentFeatures();
382         f.name = "dirt";
383         f.setAllTextures("mud.png");
384         f.setInventoryTextureCube("mud.png", "mud.png", "mud.png");
385         f.param_type = CPT_MINERAL;
386         f.is_ground_content = true;
387         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
388         setDirtLikeMaterialProperties(f.material, 1.0);
389         nodemgr->set(i, f);
390
391         i = CONTENT_SAND;
392         f = ContentFeatures();
393         f.name = "sand";
394         f.setAllTextures("sand.png");
395         f.setInventoryTextureCube("sand.png", "sand.png", "sand.png");
396         f.param_type = CPT_MINERAL;
397         f.is_ground_content = true;
398         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
399         f.cookresult_item = std::string("MaterialItem2 ")+itos(CONTENT_GLASS)+" 1";
400         setDirtLikeMaterialProperties(f.material, 1.0);
401         nodemgr->set(i, f);
402
403         i = CONTENT_GRAVEL;
404         f = ContentFeatures();
405         f.name = "gravel";
406         f.setAllTextures("gravel.png");
407         f.setInventoryTextureCube("gravel.png", "gravel.png", "gravel.png");
408         f.param_type = CPT_MINERAL;
409         f.is_ground_content = true;
410         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
411         setGravelLikeMaterialProperties(f.material, 1.0);
412         nodemgr->set(i, f);
413
414         i = CONTENT_SANDSTONE;
415         f = ContentFeatures();
416         f.name = "sandstone";
417         f.setAllTextures("sandstone.png");
418         f.setInventoryTextureCube("sandstone.png", "sandstone.png", "sandstone.png");
419         f.param_type = CPT_MINERAL;
420         f.is_ground_content = true;
421         f.dug_item = std::string("MaterialItem2 ")+itos(CONTENT_SAND)+" 1";
422         setDirtLikeMaterialProperties(f.material, 1.0);
423         nodemgr->set(i, f);
424
425         i = CONTENT_CLAY;
426         f = ContentFeatures();
427         f.name = "clay";
428         f.setAllTextures("clay.png");
429         f.setInventoryTextureCube("clay.png", "clay.png", "clay.png");
430         f.param_type = CPT_MINERAL;
431         f.is_ground_content = true;
432         f.dug_item = std::string("CraftItem lump_of_clay 4");
433         setDirtLikeMaterialProperties(f.material, 1.0);
434         nodemgr->set(i, f);
435
436         i = CONTENT_BRICK;
437         f = ContentFeatures();
438         f.name = "brick";
439         f.setAllTextures("brick.png");
440         f.setInventoryTextureCube("brick.png", "brick.png", "brick.png");
441         f.param_type = CPT_MINERAL;
442         f.is_ground_content = true;
443         f.dug_item = std::string("CraftItem clay_brick 4");
444         setStoneLikeMaterialProperties(f.material, 1.0);
445         nodemgr->set(i, f);
446
447         i = CONTENT_TREE;
448         f = ContentFeatures();
449         f.name = "tree";
450         f.setAllTextures("tree.png");
451         f.setTexture(0, "tree_top.png");
452         f.setTexture(1, "tree_top.png");
453         f.param_type = CPT_MINERAL;
454         f.is_ground_content = true;
455         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
456         f.cookresult_item = "CraftItem lump_of_coal 1";
457         f.furnace_burntime = 30;
458         setWoodLikeMaterialProperties(f.material, 1.0);
459         nodemgr->set(i, f);
460
461         i = CONTENT_JUNGLETREE;
462         f = ContentFeatures();
463         f.name = "jungletree";
464         f.setAllTextures("jungletree.png");
465         f.setTexture(0, "jungletree_top.png");
466         f.setTexture(1, "jungletree_top.png");
467         f.param_type = CPT_MINERAL;
468         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
469         f.furnace_burntime = 30;
470         setWoodLikeMaterialProperties(f.material, 1.0);
471         nodemgr->set(i, f);
472
473         i = CONTENT_JUNGLEGRASS;
474         f = ContentFeatures();
475         f.name = "junglegrass";
476         f.drawtype = NDT_PLANTLIKE;
477         f.visual_scale = 1.3;
478         f.setAllTextures("junglegrass.png");
479         f.setInventoryTexture("junglegrass.png");
480         f.light_propagates = true;
481         f.param_type = CPT_LIGHT;
482         f.air_equivalent = false; // grass grows underneath
483         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
484         f.walkable = false;
485         setLeavesLikeMaterialProperties(f.material, 1.0);
486         f.furnace_burntime = 2;
487         nodemgr->set(i, f);
488
489         i = CONTENT_LEAVES;
490         f = ContentFeatures();
491         f.name = "leaves";
492         f.drawtype = NDT_ALLFACES_OPTIONAL;
493         f.setAllTextures("leaves.png");
494         //f.setAllTextures("[noalpha:leaves.png");
495         f.light_propagates = true;
496         f.param_type = CPT_LIGHT;
497         f.extra_dug_item = std::string("MaterialItem2 ")+itos(CONTENT_SAPLING)+" 1";
498         f.extra_dug_item_rarity = 20;
499         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
500         setLeavesLikeMaterialProperties(f.material, 1.0);
501         f.furnace_burntime = 1.0;
502         nodemgr->set(i, f);
503
504         i = CONTENT_CACTUS;
505         f = ContentFeatures();
506         f.name = "cactus";
507         f.setAllTextures("cactus_side.png");
508         f.setTexture(0, "cactus_top.png");
509         f.setTexture(1, "cactus_top.png");
510         f.setInventoryTextureCube("cactus_top.png", "cactus_side.png", "cactus_side.png");
511         f.param_type = CPT_MINERAL;
512         f.is_ground_content = true;
513         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
514         setWoodLikeMaterialProperties(f.material, 0.75);
515         f.furnace_burntime = 15;
516         nodemgr->set(i, f);
517
518         i = CONTENT_PAPYRUS;
519         f = ContentFeatures();
520         f.name = "papyrus";
521         f.drawtype = NDT_PLANTLIKE;
522         f.setAllTextures("papyrus.png");
523         f.setInventoryTexture("papyrus.png");
524         f.light_propagates = true;
525         f.param_type = CPT_LIGHT;
526         f.is_ground_content = true;
527         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
528         f.walkable = false;
529         setLeavesLikeMaterialProperties(f.material, 0.5);
530         f.furnace_burntime = 1;
531         nodemgr->set(i, f);
532
533         i = CONTENT_BOOKSHELF;
534         f = ContentFeatures();
535         f.name = "bookshelf";
536         f.setAllTextures("bookshelf.png");
537         f.setTexture(0, "wood.png");
538         f.setTexture(1, "wood.png");
539         // FIXME: setInventoryTextureCube() only cares for the first texture
540         f.setInventoryTextureCube("bookshelf.png", "bookshelf.png", "bookshelf.png");
541         //f.setInventoryTextureCube("wood.png", "bookshelf.png", "bookshelf.png");
542         f.param_type = CPT_MINERAL;
543         f.is_ground_content = true;
544         setWoodLikeMaterialProperties(f.material, 0.75);
545         f.furnace_burntime = 30;
546         nodemgr->set(i, f);
547
548         i = CONTENT_GLASS;
549         f = ContentFeatures();
550         f.name = "glass";
551         f.drawtype = NDT_GLASSLIKE;
552         f.setAllTextures("glass.png");
553         f.light_propagates = true;
554         f.sunlight_propagates = true;
555         f.param_type = CPT_LIGHT;
556         f.is_ground_content = true;
557         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
558         f.setInventoryTextureCube("glass.png", "glass.png", "glass.png");
559         setGlassLikeMaterialProperties(f.material, 1.0);
560         nodemgr->set(i, f);
561
562         i = CONTENT_FENCE;
563         f = ContentFeatures();
564         f.name = "wooden_fence";
565         f.drawtype = NDT_FENCELIKE;
566         f.setInventoryTexture("fence.png");
567         f.setTexture(0, "wood.png");
568         f.light_propagates = true;
569         f.param_type = CPT_LIGHT;
570         f.is_ground_content = true;
571         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
572         f.air_equivalent = true; // grass grows underneath
573         f.selection_box.type = NODEBOX_FIXED;
574         f.selection_box.fixed = core::aabbox3d<f32>(
575                         -BS/7, -BS/2, -BS/7, BS/7, BS/2, BS/7);
576         f.furnace_burntime = 30/2;
577         setWoodLikeMaterialProperties(f.material, 0.75);
578         nodemgr->set(i, f);
579
580         i = CONTENT_RAIL;
581         f = ContentFeatures();
582         f.name = "rail";
583         f.drawtype = NDT_RAILLIKE;
584         f.setInventoryTexture("rail.png");
585         f.setTexture(0, "rail.png");
586         f.setTexture(1, "rail_curved.png");
587         f.setTexture(2, "rail_t_junction.png");
588         f.setTexture(3, "rail_crossing.png");
589         f.light_propagates = true;
590         f.param_type = CPT_LIGHT;
591         f.is_ground_content = true;
592         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
593         f.air_equivalent = true; // grass grows underneath
594         f.walkable = false;
595         f.selection_box.type = NODEBOX_FIXED;
596         f.furnace_burntime = 5;
597         setDirtLikeMaterialProperties(f.material, 0.75);
598         nodemgr->set(i, f);
599
600         i = CONTENT_LADDER;
601         f = ContentFeatures();
602         f.name = "ladder";
603         f.drawtype = NDT_SIGNLIKE;
604         f.setAllTextures("ladder.png");
605         f.setInventoryTexture("ladder.png");
606         f.light_propagates = true;
607         f.param_type = CPT_LIGHT;
608         f.is_ground_content = true;
609         f.dug_item = std::string("MaterialItem ")+itos(i)+" 1";
610         f.wall_mounted = true;
611         f.air_equivalent = true;
612         f.walkable = false;
613         f.climbable = true;
614         f.selection_box.type = NODEBOX_WALLMOUNTED;
615         f.furnace_burntime = 5;
616         setWoodLikeMaterialProperties(f.material, 0.5);
617
618         nodemgr->set(i, f);
619
620         i = CONTENT_COALSTONE;
621         f = ContentFeatures();
622         f.name = "coalstone";
623         f.setAllTextures("stone.png^mineral_coal.png");
624         f.is_ground_content = true;
625         setStoneLikeMaterialProperties(f.material, 1.5);
626         nodemgr->set(i, f);
627
628         i = CONTENT_WOOD;
629         f = ContentFeatures();
630         f.name = "wood";
631         f.setAllTextures("wood.png");
632         f.setInventoryTextureCube("wood.png", "wood.png", "wood.png");
633         f.is_ground_content = true;
634         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
635         f.furnace_burntime = 30/4;
636         setWoodLikeMaterialProperties(f.material, 0.75);
637         nodemgr->set(i, f);
638
639         i = CONTENT_MESE;
640         f = ContentFeatures();
641         f.name = "mese";
642         f.setAllTextures("mese.png");
643         f.setInventoryTextureCube("mese.png", "mese.png", "mese.png");
644         f.is_ground_content = true;
645         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
646         f.furnace_burntime = 30;
647         setStoneLikeMaterialProperties(f.material, 0.5);
648         nodemgr->set(i, f);
649
650         i = CONTENT_CLOUD;
651         f = ContentFeatures();
652         f.name = "cloud";
653         f.setAllTextures("cloud.png");
654         f.setInventoryTextureCube("cloud.png", "cloud.png", "cloud.png");
655         f.is_ground_content = true;
656         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
657         nodemgr->set(i, f);
658
659         i = CONTENT_AIR;
660         f = ContentFeatures();
661         f.name = "air";
662         f.param_type = CPT_LIGHT;
663         f.light_propagates = true;
664         f.sunlight_propagates = true;
665         f.walkable = false;
666         f.pointable = false;
667         f.diggable = false;
668         f.buildable_to = true;
669         f.air_equivalent = true;
670         nodemgr->set(i, f);
671
672         i = CONTENT_WATER;
673         f = ContentFeatures();
674         f.name = "water_flowing";
675         f.drawtype = NDT_FLOWINGLIQUID;
676         f.setAllTextures("water.png");
677         f.alpha = WATER_ALPHA;
678         f.setInventoryTextureCube("water.png", "water.png", "water.png");
679         f.param_type = CPT_LIGHT;
680         f.light_propagates = true;
681         f.walkable = false;
682         f.pointable = false;
683         f.diggable = false;
684         f.buildable_to = true;
685         f.liquid_type = LIQUID_FLOWING;
686         f.liquid_alternative_flowing = CONTENT_WATER;
687         f.liquid_alternative_source = CONTENT_WATERSOURCE;
688         f.liquid_viscosity = WATER_VISC;
689         f.post_effect_color = video::SColor(64, 100, 100, 200);
690         f.setSpecialMaterial(0, MaterialSpec("water.png", false));
691         f.setSpecialMaterial(1, MaterialSpec("water.png", true));
692         nodemgr->set(i, f);
693
694         i = CONTENT_WATERSOURCE;
695         f = ContentFeatures();
696         f.name = "water_source";
697         f.drawtype = NDT_LIQUID;
698         f.setAllTextures("water.png");
699         f.alpha = WATER_ALPHA;
700         f.setInventoryTextureCube("water.png", "water.png", "water.png");
701         f.param_type = CPT_LIGHT;
702         f.light_propagates = true;
703         f.walkable = false;
704         f.pointable = false;
705         f.diggable = false;
706         f.buildable_to = true;
707         f.liquid_type = LIQUID_SOURCE;
708         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
709         f.liquid_alternative_flowing = CONTENT_WATER;
710         f.liquid_alternative_source = CONTENT_WATERSOURCE;
711         f.liquid_viscosity = WATER_VISC;
712         f.post_effect_color = video::SColor(64, 100, 100, 200);
713         // New-style water source material (mostly unused)
714         f.setSpecialMaterial(0, MaterialSpec("water.png", false));
715         nodemgr->set(i, f);
716
717         i = CONTENT_LAVA;
718         f = ContentFeatures();
719         f.name = "lava_flowing";
720         f.drawtype = NDT_FLOWINGLIQUID;
721         f.setAllTextures("lava.png");
722         f.setInventoryTextureCube("lava.png", "lava.png", "lava.png");
723         f.param_type = CPT_LIGHT;
724         f.light_propagates = false;
725         f.light_source = LIGHT_MAX-1;
726         f.walkable = false;
727         f.pointable = false;
728         f.diggable = false;
729         f.buildable_to = true;
730         f.liquid_type = LIQUID_FLOWING;
731         f.liquid_alternative_flowing = CONTENT_LAVA;
732         f.liquid_alternative_source = CONTENT_LAVASOURCE;
733         f.liquid_viscosity = LAVA_VISC;
734         f.damage_per_second = 4*2;
735         f.post_effect_color = video::SColor(192, 255, 64, 0);
736         f.setSpecialMaterial(0, MaterialSpec("lava.png", false));
737         f.setSpecialMaterial(1, MaterialSpec("lava.png", true));
738         nodemgr->set(i, f);
739
740         i = CONTENT_LAVASOURCE;
741         f = ContentFeatures();
742         f.name = "lava_source";
743         f.drawtype = NDT_LIQUID;
744         f.setAllTextures("lava.png");
745         f.setInventoryTextureCube("lava.png", "lava.png", "lava.png");
746         f.param_type = CPT_LIGHT;
747         f.light_propagates = false;
748         f.light_source = LIGHT_MAX-1;
749         f.walkable = false;
750         f.pointable = false;
751         f.diggable = false;
752         f.buildable_to = true;
753         f.liquid_type = LIQUID_SOURCE;
754         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
755         f.liquid_alternative_flowing = CONTENT_LAVA;
756         f.liquid_alternative_source = CONTENT_LAVASOURCE;
757         f.liquid_viscosity = LAVA_VISC;
758         f.damage_per_second = 4*2;
759         f.post_effect_color = video::SColor(192, 255, 64, 0);
760         // New-style lava source material (mostly unused)
761         f.setSpecialMaterial(0, MaterialSpec("lava.png", false));
762         f.furnace_burntime = 60;
763         nodemgr->set(i, f);
764
765         i = CONTENT_TORCH;
766         f = ContentFeatures();
767         f.name = "torch";
768         f.drawtype = NDT_TORCHLIKE;
769         f.setTexture(0, "torch_on_floor.png");
770         f.setTexture(1, "torch_on_ceiling.png");
771         f.setTexture(2, "torch.png");
772         f.setInventoryTexture("torch_on_floor.png");
773         f.param_type = CPT_LIGHT;
774         f.light_propagates = true;
775         f.sunlight_propagates = true;
776         f.walkable = false;
777         f.wall_mounted = true;
778         f.air_equivalent = true;
779         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
780         f.light_source = LIGHT_MAX-1;
781         f.selection_box.type = NODEBOX_WALLMOUNTED;
782         f.selection_box.wall_top = core::aabbox3d<f32>(
783                         -BS/10, BS/2-BS/3.333*2, -BS/10, BS/10, BS/2, BS/10);
784         f.selection_box.wall_bottom = core::aabbox3d<f32>(
785                         -BS/10, -BS/2, -BS/10, BS/10, -BS/2+BS/3.333*2, BS/10);
786         f.selection_box.wall_side = core::aabbox3d<f32>(
787                         -BS/2, -BS/3.333, -BS/10, -BS/2+BS/3.333, BS/3.333, BS/10);
788         setConstantMaterialProperties(f.material, 0.0);
789         f.furnace_burntime = 4;
790         nodemgr->set(i, f);
791
792         i = CONTENT_SIGN_WALL;
793         f = ContentFeatures();
794         f.name = "sign_wall";
795         f.drawtype = NDT_SIGNLIKE;
796         f.setAllTextures("sign_wall.png");
797         f.setInventoryTexture("sign_wall.png");
798         f.param_type = CPT_LIGHT;
799         f.light_propagates = true;
800         f.sunlight_propagates = true;
801         f.walkable = false;
802         f.wall_mounted = true;
803         f.air_equivalent = true;
804         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
805         if(f.initial_metadata == NULL)
806                 f.initial_metadata = new SignNodeMetadata(NULL, "Some sign");
807         setConstantMaterialProperties(f.material, 0.5);
808         f.selection_box.type = NODEBOX_WALLMOUNTED;
809         f.furnace_burntime = 10;
810         nodemgr->set(i, f);
811
812         i = CONTENT_CHEST;
813         f = ContentFeatures();
814         f.name = "chest";
815         f.param_type = CPT_FACEDIR_SIMPLE;
816         f.setAllTextures("chest_side.png");
817         f.setTexture(0, "chest_top.png");
818         f.setTexture(1, "chest_top.png");
819         f.setTexture(5, "chest_front.png"); // Z-
820         f.setInventoryTexture("chest_top.png");
821         //f.setInventoryTextureCube("chest_top.png", "chest_side.png", "chest_side.png");
822         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
823         if(f.initial_metadata == NULL)
824                 f.initial_metadata = new ChestNodeMetadata(NULL);
825         setWoodLikeMaterialProperties(f.material, 1.0);
826         f.furnace_burntime = 30;
827         nodemgr->set(i, f);
828
829         i = CONTENT_LOCKABLE_CHEST;
830         f = ContentFeatures();
831         f.name = "locked_chest";
832         f.param_type = CPT_FACEDIR_SIMPLE;
833         f.setAllTextures("chest_side.png");
834         f.setTexture(0, "chest_top.png");
835         f.setTexture(1, "chest_top.png");
836         f.setTexture(5, "chest_lock.png"); // Z-
837         f.setInventoryTexture("chest_lock.png");
838         //f.setInventoryTextureCube("chest_top.png", "chest_side.png", "chest_side.png");
839         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
840         if(f.initial_metadata == NULL)
841                 f.initial_metadata = new LockingChestNodeMetadata(NULL);
842         setWoodLikeMaterialProperties(f.material, 1.0);
843         f.furnace_burntime = 30;
844         nodemgr->set(i, f);
845
846         i = CONTENT_FURNACE;
847         f = ContentFeatures();
848         f.name = "furnace";
849         f.param_type = CPT_FACEDIR_SIMPLE;
850         f.setAllTextures("furnace_side.png");
851         f.setTexture(5, "furnace_front.png"); // Z-
852         f.setInventoryTexture("furnace_front.png");
853         //f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
854         f.dug_item = std::string("MaterialItem2 ")+itos(CONTENT_COBBLE)+" 6";
855         if(f.initial_metadata == NULL)
856                 f.initial_metadata = new FurnaceNodeMetadata(NULL);
857         setStoneLikeMaterialProperties(f.material, 3.0);
858         nodemgr->set(i, f);
859
860         i = CONTENT_COBBLE;
861         f = ContentFeatures();
862         f.name = "cobble";
863         f.setAllTextures("cobble.png");
864         f.setInventoryTextureCube("cobble.png", "cobble.png", "cobble.png");
865         f.param_type = CPT_NONE;
866         f.is_ground_content = true;
867         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
868         f.cookresult_item = std::string("MaterialItem2 ")+itos(CONTENT_STONE)+" 1";
869         setStoneLikeMaterialProperties(f.material, 0.9);
870         nodemgr->set(i, f);
871
872         i = CONTENT_MOSSYCOBBLE;
873         f = ContentFeatures();
874         f.name = "mossycobble";
875         f.setAllTextures("mossycobble.png");
876         f.setInventoryTextureCube("mossycobble.png", "mossycobble.png", "mossycobble.png");
877         f.param_type = CPT_NONE;
878         f.is_ground_content = true;
879         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
880         setStoneLikeMaterialProperties(f.material, 0.8);
881         nodemgr->set(i, f);
882
883         i = CONTENT_STEEL;
884         f = ContentFeatures();
885         f.name = "steelblock";
886         f.setAllTextures("steel_block.png");
887         f.setInventoryTextureCube("steel_block.png", "steel_block.png",
888                         "steel_block.png");
889         f.param_type = CPT_NONE;
890         f.is_ground_content = true;
891         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
892         setStoneLikeMaterialProperties(f.material, 5.0);
893         nodemgr->set(i, f);
894
895         i = CONTENT_NC;
896         f = ContentFeatures();
897         f.name = "nyancat";
898         f.param_type = CPT_FACEDIR_SIMPLE;
899         f.setAllTextures("nc_side.png");
900         f.setTexture(5, "nc_front.png"); // Z-
901         f.setTexture(4, "nc_back.png"); // Z+
902         f.setInventoryTexture("nc_front.png");
903         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
904         setStoneLikeMaterialProperties(f.material, 3.0);
905         f.furnace_burntime = 1;
906         nodemgr->set(i, f);
907
908         i = CONTENT_NC_RB;
909         f = ContentFeatures();
910         f.name = "nyancat_rainbow";
911         f.setAllTextures("nc_rb.png");
912         f.setInventoryTexture("nc_rb.png");
913         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
914         setStoneLikeMaterialProperties(f.material, 3.0);
915         f.furnace_burntime = 1;
916         nodemgr->set(i, f);
917
918         i = CONTENT_SAPLING;
919         f = ContentFeatures();
920         f.name = "sapling";
921         f.drawtype = NDT_PLANTLIKE;
922         f.visual_scale = 1.0;
923         f.setAllTextures("sapling.png");
924         f.setInventoryTexture("sapling.png");
925         f.param_type = CPT_LIGHT;
926         f.dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
927         f.light_propagates = true;
928         f.air_equivalent = false;
929         f.walkable = false;
930         setConstantMaterialProperties(f.material, 0.0);
931         f.furnace_burntime = 10;
932         nodemgr->set(i, f);
933
934         i = CONTENT_APPLE;
935         f = ContentFeatures();
936         f.name = "apple";
937         f.drawtype = NDT_PLANTLIKE;
938         f.visual_scale = 1.0;
939         f.setAllTextures("apple.png");
940         f.setInventoryTexture("apple.png");
941         f.param_type = CPT_LIGHT;
942         f.light_propagates = true;
943         f.sunlight_propagates = true;
944         f.walkable = false;
945         f.air_equivalent = true;
946         f.dug_item = std::string("CraftItem apple 1");
947         setConstantMaterialProperties(f.material, 0.0);
948         f.furnace_burntime = 3;
949         nodemgr->set(i, f);
950 }
951
952