Better node texture generation
[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 // For g_settings
21 #include "main.h"
22
23 #include "content_mapnode.h"
24 #include "mapnode.h"
25 #include "content_nodemeta.h"
26 #include "settings.h"
27 #include "nodedef.h"
28
29 #define WATER_ALPHA 160
30
31 #define WATER_VISC 1
32 #define LAVA_VISC 7
33
34 void setConstantMaterialProperties(MaterialProperties &mprop, float time)
35 {
36         mprop.diggability = DIGGABLE_CONSTANT;
37         mprop.constant_time = time;
38 }
39
40 void setStoneLikeMaterialProperties(MaterialProperties &mprop, float toughness)
41 {
42         mprop.diggability = DIGGABLE_NORMAL;
43         mprop.weight = 5.0 * toughness;
44         mprop.crackiness = 1.0;
45         mprop.crumbliness = -0.1;
46         mprop.cuttability = -0.2;
47 }
48
49 void setDirtLikeMaterialProperties(MaterialProperties &mprop, float toughness)
50 {
51         mprop.diggability = DIGGABLE_NORMAL;
52         mprop.weight = toughness * 1.2;
53         mprop.crackiness = 0;
54         mprop.crumbliness = 1.2;
55         mprop.cuttability = -0.4;
56 }
57
58 void setGravelLikeMaterialProperties(MaterialProperties &mprop, float toughness)
59 {
60         mprop.diggability = DIGGABLE_NORMAL;
61         mprop.weight = toughness * 2.0;
62         mprop.crackiness = 0.2;
63         mprop.crumbliness = 1.5;
64         mprop.cuttability = -1.0;
65 }
66
67 void setWoodLikeMaterialProperties(MaterialProperties &mprop, float toughness)
68 {
69         mprop.diggability = DIGGABLE_NORMAL;
70         mprop.weight = toughness * 1.0;
71         mprop.crackiness = 0.75;
72         mprop.crumbliness = -1.0;
73         mprop.cuttability = 1.5;
74 }
75
76 void setLeavesLikeMaterialProperties(MaterialProperties &mprop, float toughness)
77 {
78         mprop.diggability = DIGGABLE_NORMAL;
79         mprop.weight = -0.5 * toughness;
80         mprop.crackiness = 0;
81         mprop.crumbliness = 0;
82         mprop.cuttability = 2.0;
83 }
84
85 void setGlassLikeMaterialProperties(MaterialProperties &mprop, float toughness)
86 {
87         mprop.diggability = DIGGABLE_NORMAL;
88         mprop.weight = 0.1 * toughness;
89         mprop.crackiness = 2.0;
90         mprop.crumbliness = -1.0;
91         mprop.cuttability = -1.0;
92 }
93
94 /*
95         A conversion table for backwards compatibility.
96         Maps <=v19 content types to current ones.
97         Should never be touched.
98 */
99 content_t trans_table_19[21][2] = {
100         {CONTENT_GRASS, 1},
101         {CONTENT_TREE, 4},
102         {CONTENT_LEAVES, 5},
103         {CONTENT_GRASS_FOOTSTEPS, 6},
104         {CONTENT_MESE, 7},
105         {CONTENT_MUD, 8},
106         {CONTENT_CLOUD, 10},
107         {CONTENT_COALSTONE, 11},
108         {CONTENT_WOOD, 12},
109         {CONTENT_SAND, 13},
110         {CONTENT_COBBLE, 18},
111         {CONTENT_STEEL, 19},
112         {CONTENT_GLASS, 20},
113         {CONTENT_MOSSYCOBBLE, 22},
114         {CONTENT_GRAVEL, 23},
115         {CONTENT_SANDSTONE, 24},
116         {CONTENT_CACTUS, 25},
117         {CONTENT_BRICK, 26},
118         {CONTENT_CLAY, 27},
119         {CONTENT_PAPYRUS, 28},
120         {CONTENT_BOOKSHELF, 29},
121 };
122
123 MapNode mapnode_translate_from_internal(MapNode n_from, u8 version)
124 {
125         MapNode result = n_from;
126         if(version <= 19)
127         {
128                 content_t c_from = n_from.getContent();
129                 for(u32 i=0; i<sizeof(trans_table_19)/sizeof(trans_table_19[0]); i++)
130                 {
131                         if(trans_table_19[i][0] == c_from)
132                         {
133                                 result.setContent(trans_table_19[i][1]);
134                                 break;
135                         }
136                 }
137         }
138         return result;
139 }
140 MapNode mapnode_translate_to_internal(MapNode n_from, u8 version)
141 {
142         MapNode result = n_from;
143         if(version <= 19)
144         {
145                 content_t c_from = n_from.getContent();
146                 for(u32 i=0; i<sizeof(trans_table_19)/sizeof(trans_table_19[0]); i++)
147                 {
148                         if(trans_table_19[i][1] == c_from)
149                         {
150                                 result.setContent(trans_table_19[i][0]);
151                                 break;
152                         }
153                 }
154         }
155         return result;
156 }
157
158 // See header for description
159 void content_mapnode_init(ITextureSource *tsrc, IWritableNodeDefManager *nodemgr)
160 {
161         if(tsrc == NULL)
162                 dstream<<"INFO: Initial run of content_mapnode_init with "
163                                 "tsrc=NULL. If this segfaults, "
164                                 "there is a bug with something not checking for "
165                                 "the NULL value."<<std::endl;
166         else
167                 dstream<<"INFO: Full run of content_mapnode_init with "
168                                 "tsrc!=NULL"<<std::endl;
169
170         // Read some settings
171         bool new_style_water = g_settings->getBool("new_style_water");
172         bool new_style_leaves = g_settings->getBool("new_style_leaves");
173         bool invisible_stone = g_settings->getBool("invisible_stone");
174         bool opaque_water = g_settings->getBool("opaque_water");
175
176         content_t i;
177         ContentFeatures *f = NULL;
178
179         i = CONTENT_STONE;
180         f = nodemgr->getModifiable(i);
181         f->setAllTextures("stone.png");
182         f->setInventoryTextureCube("stone.png", "stone.png", "stone.png");
183         f->param_type = CPT_MINERAL;
184         f->is_ground_content = true;
185         f->often_contains_mineral = true;
186         f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_COBBLE)+" 1";
187         setStoneLikeMaterialProperties(f->material, 1.0);
188         if(invisible_stone)
189                 f->solidness = 0; // For debugging, hides regular stone
190         
191         i = CONTENT_GRASS;
192         f = nodemgr->getModifiable(i);
193         f->setAllTextures("mud.png^grass_side.png");
194         f->setTexture(0, "grass.png");
195         f->setTexture(1, "mud.png");
196         f->param_type = CPT_MINERAL;
197         f->is_ground_content = true;
198         f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_MUD)+" 1";
199         setDirtLikeMaterialProperties(f->material, 1.0);
200         
201         i = CONTENT_GRASS_FOOTSTEPS;
202         f = nodemgr->getModifiable(i);
203         f->setAllTextures("mud.png^grass_side.png");
204         f->setTexture(0, "grass_footsteps.png");
205         f->setTexture(1, "mud.png");
206         f->param_type = CPT_MINERAL;
207         f->is_ground_content = true;
208         f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_MUD)+" 1";
209         setDirtLikeMaterialProperties(f->material, 1.0);
210         
211         i = CONTENT_MUD;
212         f = nodemgr->getModifiable(i);
213         f->setAllTextures("mud.png");
214         f->setInventoryTextureCube("mud.png", "mud.png", "mud.png");
215         f->param_type = CPT_MINERAL;
216         f->is_ground_content = true;
217         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
218         setDirtLikeMaterialProperties(f->material, 1.0);
219         
220         i = CONTENT_SAND;
221         f = nodemgr->getModifiable(i);
222         f->setAllTextures("sand.png");
223         f->setInventoryTextureCube("sand.png", "sand.png", "sand.png");
224         f->param_type = CPT_MINERAL;
225         f->is_ground_content = true;
226         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
227         setDirtLikeMaterialProperties(f->material, 1.0);
228         
229         i = CONTENT_GRAVEL;
230         f = nodemgr->getModifiable(i);
231         f->setAllTextures("gravel.png");
232         f->setInventoryTextureCube("gravel.png", "gravel.png", "gravel.png");
233         f->param_type = CPT_MINERAL;
234         f->is_ground_content = true;
235         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
236         setGravelLikeMaterialProperties(f->material, 1.0);
237         
238         i = CONTENT_SANDSTONE;
239         f = nodemgr->getModifiable(i);
240         f->setAllTextures("sandstone.png");
241         f->setInventoryTextureCube("sandstone.png", "sandstone.png", "sandstone.png");
242         f->param_type = CPT_MINERAL;
243         f->is_ground_content = true;
244         f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_SAND)+" 1";
245         setDirtLikeMaterialProperties(f->material, 1.0);
246
247         i = CONTENT_CLAY;
248         f = nodemgr->getModifiable(i);
249         f->setAllTextures("clay.png");
250         f->setInventoryTextureCube("clay.png", "clay.png", "clay.png");
251         f->param_type = CPT_MINERAL;
252         f->is_ground_content = true;
253         f->dug_item = std::string("CraftItem lump_of_clay 4");
254         setDirtLikeMaterialProperties(f->material, 1.0);
255
256         i = CONTENT_BRICK;
257         f = nodemgr->getModifiable(i);
258         f->setAllTextures("brick.png");
259         f->setInventoryTextureCube("brick.png", "brick.png", "brick.png");
260         f->param_type = CPT_MINERAL;
261         f->is_ground_content = true;
262         f->dug_item = std::string("CraftItem clay_brick 4");
263         setStoneLikeMaterialProperties(f->material, 1.0);
264
265         i = CONTENT_TREE;
266         f = nodemgr->getModifiable(i);
267         f->setAllTextures("tree.png");
268         f->setTexture(0, "tree_top.png");
269         f->setTexture(1, "tree_top.png");
270         f->param_type = CPT_MINERAL;
271         f->is_ground_content = true;
272         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
273         setWoodLikeMaterialProperties(f->material, 1.0);
274         
275         i = CONTENT_JUNGLETREE;
276         f = nodemgr->getModifiable(i);
277         f->setAllTextures("jungletree.png");
278         f->setTexture(0, "jungletree_top.png");
279         f->setTexture(1, "jungletree_top.png");
280         f->param_type = CPT_MINERAL;
281         //f->is_ground_content = true;
282         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
283         setWoodLikeMaterialProperties(f->material, 1.0);
284         
285         i = CONTENT_JUNGLEGRASS;
286         f = nodemgr->getModifiable(i);
287         f->setInventoryTexture("junglegrass.png");
288         f->used_texturenames.insert("junglegrass.png"); // Add to atlas
289         f->light_propagates = true;
290         f->param_type = CPT_LIGHT;
291         //f->is_ground_content = true;
292         f->air_equivalent = false; // grass grows underneath
293         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
294         f->solidness = 0; // drawn separately, makes no faces
295         f->walkable = false;
296         setLeavesLikeMaterialProperties(f->material, 1.0);
297
298         i = CONTENT_LEAVES;
299         f = nodemgr->getModifiable(i);
300         f->light_propagates = true;
301         //f->param_type = CPT_MINERAL;
302         f->param_type = CPT_LIGHT;
303         //f->is_ground_content = true;
304         if(new_style_leaves)
305         {
306                 f->solidness = 0; // drawn separately, makes no faces
307                 f->visual_solidness = 1;
308                 f->setAllTextures("leaves.png");
309                 f->setInventoryTextureCube("leaves.png", "leaves.png", "leaves.png");
310         }
311         else
312         {
313                 f->setAllTextures("[noalpha:leaves.png");
314         }
315         f->extra_dug_item = std::string("MaterialItem2 ")+itos(CONTENT_SAPLING)+" 1";
316         f->extra_dug_item_rarity = 20;
317         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
318         setLeavesLikeMaterialProperties(f->material, 1.0);
319
320         i = CONTENT_CACTUS;
321         f = nodemgr->getModifiable(i);
322         f->setAllTextures("cactus_side.png");
323         f->setTexture(0, "cactus_top.png");
324         f->setTexture(1, "cactus_top.png");
325         f->setInventoryTextureCube("cactus_top.png", "cactus_side.png", "cactus_side.png");
326         f->param_type = CPT_MINERAL;
327         f->is_ground_content = true;
328         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
329         setWoodLikeMaterialProperties(f->material, 0.75);
330
331         i = CONTENT_PAPYRUS;
332         f = nodemgr->getModifiable(i);
333         f->setInventoryTexture("papyrus.png");
334         f->used_texturenames.insert("papyrus.png"); // Add to atlas
335         f->light_propagates = true;
336         f->param_type = CPT_LIGHT;
337         f->is_ground_content = true;
338         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
339         f->solidness = 0; // drawn separately, makes no faces
340         f->walkable = false;
341         setLeavesLikeMaterialProperties(f->material, 0.5);
342
343         i = CONTENT_BOOKSHELF;
344         f = nodemgr->getModifiable(i);
345         f->setAllTextures("bookshelf.png");
346         f->setTexture(0, "wood.png");
347         f->setTexture(1, "wood.png");
348         // FIXME: setInventoryTextureCube() only cares for the first texture
349         f->setInventoryTextureCube("bookshelf.png", "bookshelf.png", "bookshelf.png");
350         //f->setInventoryTextureCube("wood.png", "bookshelf.png", "bookshelf.png");
351         f->param_type = CPT_MINERAL;
352         f->is_ground_content = true;
353         setWoodLikeMaterialProperties(f->material, 0.75);
354
355         i = CONTENT_GLASS;
356         f = nodemgr->getModifiable(i);
357         f->light_propagates = true;
358         f->sunlight_propagates = true;
359         f->param_type = CPT_LIGHT;
360         f->is_ground_content = true;
361         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
362         f->solidness = 0; // drawn separately, makes no faces
363         f->visual_solidness = 1;
364         f->setAllTextures("glass.png");
365         f->setInventoryTextureCube("glass.png", "glass.png", "glass.png");
366         setGlassLikeMaterialProperties(f->material, 1.0);
367
368         i = CONTENT_FENCE;
369         f = nodemgr->getModifiable(i);
370         f->light_propagates = true;
371         f->param_type = CPT_LIGHT;
372         f->is_ground_content = true;
373         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
374         f->solidness = 0; // drawn separately, makes no faces
375         f->air_equivalent = true; // grass grows underneath
376         f->setInventoryTexture("fence.png");
377         f->used_texturenames.insert("fence.png"); // Add to atlas
378         f->selection_box.type = NODEBOX_FIXED;
379         f->selection_box.fixed = core::aabbox3d<f32>(
380                         -BS/7, -BS/2, -BS/7, BS/7, BS/2, BS/7);
381         setWoodLikeMaterialProperties(f->material, 0.75);
382
383         i = CONTENT_RAIL;
384         f = nodemgr->getModifiable(i);
385         f->setInventoryTexture("rail.png");
386         f->used_texturenames.insert("rail.png"); // Add to atlas
387         f->light_propagates = true;
388         f->param_type = CPT_LIGHT;
389         f->is_ground_content = true;
390         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
391         f->solidness = 0; // drawn separately, makes no faces
392         f->air_equivalent = true; // grass grows underneath
393         f->walkable = false;
394         f->selection_box.type = NODEBOX_FIXED;
395         setDirtLikeMaterialProperties(f->material, 0.75);
396
397         i = CONTENT_LADDER;
398         f = nodemgr->getModifiable(i);
399         f->setInventoryTexture("ladder.png");
400         f->used_texturenames.insert("ladder.png"); // Add to atlas
401         f->light_propagates = true;
402         f->param_type = CPT_LIGHT;
403         f->is_ground_content = true;
404         f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
405         f->wall_mounted = true;
406         f->solidness = 0;
407         f->air_equivalent = true;
408         f->walkable = false;
409         f->climbable = true;
410         f->selection_box.type = NODEBOX_WALLMOUNTED;
411         setWoodLikeMaterialProperties(f->material, 0.5);
412
413         // Deprecated
414         i = CONTENT_COALSTONE;
415         f = nodemgr->getModifiable(i);
416         f->setAllTextures("stone.png^mineral_coal.png");
417         f->is_ground_content = true;
418         setStoneLikeMaterialProperties(f->material, 1.5);
419         
420         i = CONTENT_WOOD;
421         f = nodemgr->getModifiable(i);
422         f->setAllTextures("wood.png");
423         f->setInventoryTextureCube("wood.png", "wood.png", "wood.png");
424         f->is_ground_content = true;
425         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
426         setWoodLikeMaterialProperties(f->material, 0.75);
427         
428         i = CONTENT_MESE;
429         f = nodemgr->getModifiable(i);
430         f->setAllTextures("mese.png");
431         f->setInventoryTextureCube("mese.png", "mese.png", "mese.png");
432         f->is_ground_content = true;
433         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
434         setStoneLikeMaterialProperties(f->material, 0.5);
435         
436         i = CONTENT_CLOUD;
437         f = nodemgr->getModifiable(i);
438         f->setAllTextures("cloud.png");
439         f->setInventoryTextureCube("cloud.png", "cloud.png", "cloud.png");
440         f->is_ground_content = true;
441         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
442         
443         i = CONTENT_AIR;
444         f = nodemgr->getModifiable(i);
445         f->param_type = CPT_LIGHT;
446         f->light_propagates = true;
447         f->sunlight_propagates = true;
448         f->solidness = 0;
449         f->walkable = false;
450         f->pointable = false;
451         f->diggable = false;
452         f->buildable_to = true;
453         f->air_equivalent = true;
454         
455         i = CONTENT_WATER;
456         f = nodemgr->getModifiable(i);
457         f->setInventoryTextureCube("water.png", "water.png", "water.png");
458         f->param_type = CPT_LIGHT;
459         f->light_propagates = true;
460         f->solidness = 0; // Drawn separately, makes no faces
461         f->visual_solidness = 1;
462         f->walkable = false;
463         f->pointable = false;
464         f->diggable = false;
465         f->buildable_to = true;
466         f->liquid_type = LIQUID_FLOWING;
467         f->liquid_alternative_flowing = CONTENT_WATER;
468         f->liquid_alternative_source = CONTENT_WATERSOURCE;
469         f->liquid_viscosity = WATER_VISC;
470 #ifndef SERVER
471         if(!opaque_water)
472                 f->alpha = WATER_ALPHA;
473         f->post_effect_color = video::SColor(64, 100, 100, 200);
474         if(f->special_material == NULL && tsrc)
475         {
476                 // Flowing water material
477                 f->special_material = new video::SMaterial;
478                 f->special_material->setFlag(video::EMF_LIGHTING, false);
479                 f->special_material->setFlag(video::EMF_BACK_FACE_CULLING, false);
480                 f->special_material->setFlag(video::EMF_BILINEAR_FILTER, false);
481                 f->special_material->setFlag(video::EMF_FOG_ENABLE, true);
482                 if(!opaque_water)
483                         f->special_material->MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
484                 AtlasPointer *pa_water1 = new AtlasPointer(tsrc->getTexture(
485                                 tsrc->getTextureId("water.png")));
486                 f->special_material->setTexture(0, pa_water1->atlas);
487
488                 // Flowing water material, backface culled
489                 f->special_material2 = new video::SMaterial;
490                 *f->special_material2 = *f->special_material;
491                 f->special_material2->setFlag(video::EMF_BACK_FACE_CULLING, true);
492                 
493                 f->special_atlas = pa_water1;
494         }
495 #endif
496         
497         i = CONTENT_WATERSOURCE;
498         f = nodemgr->getModifiable(i);
499         if(new_style_water)
500         {
501                 f->solidness = 0; // drawn separately, makes no faces
502         }
503         else // old style
504         {
505                 f->solidness = 1;
506                 f->setAllTextures("water.png", WATER_ALPHA);
507                 f->backface_culling = false;
508         }
509         //f->setInventoryTexture("water.png");
510         f->setInventoryTextureCube("water.png", "water.png", "water.png");
511         f->param_type = CPT_LIGHT;
512         f->light_propagates = true;
513         f->walkable = false;
514         f->pointable = false;
515         f->diggable = false;
516         f->buildable_to = true;
517         f->liquid_type = LIQUID_SOURCE;
518         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
519         f->liquid_alternative_flowing = CONTENT_WATER;
520         f->liquid_alternative_source = CONTENT_WATERSOURCE;
521         f->liquid_viscosity = WATER_VISC;
522 #ifndef SERVER
523         if(!opaque_water)
524                 f->alpha = WATER_ALPHA;
525         f->post_effect_color = video::SColor(64, 100, 100, 200);
526         if(f->special_material == NULL && tsrc)
527         {
528                 // New-style water source material (mostly unused)
529                 f->special_material = new video::SMaterial;
530                 f->special_material->setFlag(video::EMF_LIGHTING, false);
531                 f->special_material->setFlag(video::EMF_BACK_FACE_CULLING, false);
532                 f->special_material->setFlag(video::EMF_BILINEAR_FILTER, false);
533                 f->special_material->setFlag(video::EMF_FOG_ENABLE, true);
534                 f->special_material->MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
535                 AtlasPointer *pa_water1 = new AtlasPointer(tsrc->getTexture(
536                                 tsrc->getTextureId("water.png")));
537                 f->special_material->setTexture(0, pa_water1->atlas);
538                 f->special_atlas = pa_water1;
539         }
540 #endif
541         
542         i = CONTENT_LAVA;
543         f = nodemgr->getModifiable(i);
544         f->setInventoryTextureCube("lava.png", "lava.png", "lava.png");
545         f->used_texturenames.insert("lava.png"); // Add to atlas
546         f->param_type = CPT_LIGHT;
547         f->light_propagates = false;
548         f->light_source = LIGHT_MAX-1;
549         f->solidness = 0; // Drawn separately, makes no faces
550         f->visual_solidness = 1; // Does not completely cover block boundaries
551         f->walkable = false;
552         f->pointable = false;
553         f->diggable = false;
554         f->buildable_to = true;
555         f->liquid_type = LIQUID_FLOWING;
556         f->liquid_alternative_flowing = CONTENT_LAVA;
557         f->liquid_alternative_source = CONTENT_LAVASOURCE;
558         f->liquid_viscosity = LAVA_VISC;
559         f->damage_per_second = 4*2;
560 #ifndef SERVER
561         f->post_effect_color = video::SColor(192, 255, 64, 0);
562         if(f->special_material == NULL && tsrc)
563         {
564                 // Flowing lava material
565                 f->special_material = new video::SMaterial;
566                 f->special_material->setFlag(video::EMF_LIGHTING, false);
567                 f->special_material->setFlag(video::EMF_BACK_FACE_CULLING, false);
568                 f->special_material->setFlag(video::EMF_BILINEAR_FILTER, false);
569                 f->special_material->setFlag(video::EMF_FOG_ENABLE, true);
570                 f->special_material->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
571
572                 AtlasPointer *pa_lava1 = new AtlasPointer(
573                         tsrc->getTexture(
574                                 tsrc->getTextureId("lava.png")));
575                 f->special_material->setTexture(0, pa_lava1->atlas);
576
577                 // Flowing lava material, backface culled
578                 f->special_material2 = new video::SMaterial;
579                 *f->special_material2 = *f->special_material;
580                 f->special_material2->setFlag(video::EMF_BACK_FACE_CULLING, true);
581
582                 f->special_atlas = pa_lava1;
583         }
584 #endif
585         
586         i = CONTENT_LAVASOURCE;
587         f = nodemgr->getModifiable(i);
588         f->used_texturenames.insert("ladder.png"); // Add to atlas
589         if(new_style_water)
590         {
591                 f->solidness = 0; // drawn separately, makes no faces
592         }
593         else // old style
594         {
595                 f->solidness = 2;
596                 f->setAllTextures("lava.png");
597         }
598         f->setInventoryTextureCube("lava.png", "lava.png", "lava.png");
599         f->param_type = CPT_LIGHT;
600         f->light_propagates = false;
601         f->light_source = LIGHT_MAX-1;
602         f->walkable = false;
603         f->pointable = false;
604         f->diggable = false;
605         f->buildable_to = true;
606         f->liquid_type = LIQUID_SOURCE;
607         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
608         f->liquid_alternative_flowing = CONTENT_LAVA;
609         f->liquid_alternative_source = CONTENT_LAVASOURCE;
610         f->liquid_viscosity = LAVA_VISC;
611         f->damage_per_second = 4*2;
612 #ifndef SERVER
613         f->post_effect_color = video::SColor(192, 255, 64, 0);
614         if(f->special_material == NULL && tsrc)
615         {
616                 // New-style lava source material (mostly unused)
617                 f->special_material = new video::SMaterial;
618                 f->special_material->setFlag(video::EMF_LIGHTING, false);
619                 f->special_material->setFlag(video::EMF_BACK_FACE_CULLING, false);
620                 f->special_material->setFlag(video::EMF_BILINEAR_FILTER, false);
621                 f->special_material->setFlag(video::EMF_FOG_ENABLE, true);
622                 f->special_material->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
623                 AtlasPointer *pa_lava1 = new AtlasPointer(
624                         tsrc->getTexture(
625                                 tsrc->getTextureId("lava.png")));
626                 f->special_material->setTexture(0, pa_lava1->atlas);
627
628                 f->special_atlas = pa_lava1;
629         }
630 #endif
631         
632         i = CONTENT_TORCH;
633         f = nodemgr->getModifiable(i);
634         f->setInventoryTexture("torch_on_floor.png");
635         f->used_texturenames.insert("torch_on_floor.png"); // Add to atlas
636         f->used_texturenames.insert("torch_on_ceiling.png"); // Add to atlas
637         f->used_texturenames.insert("torch.png"); // Add to atlas
638         f->param_type = CPT_LIGHT;
639         f->light_propagates = true;
640         f->sunlight_propagates = true;
641         f->solidness = 0; // drawn separately, makes no faces
642         f->walkable = false;
643         f->wall_mounted = true;
644         f->air_equivalent = true;
645         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
646         f->light_source = LIGHT_MAX-1;
647         f->selection_box.type = NODEBOX_WALLMOUNTED;
648         f->selection_box.wall_top = core::aabbox3d<f32>(
649                         -BS/10, BS/2-BS/3.333*2, -BS/10, BS/10, BS/2, BS/10);
650         f->selection_box.wall_bottom = core::aabbox3d<f32>(
651                         -BS/10, -BS/2, -BS/10, BS/10, -BS/2+BS/3.333*2, BS/10);
652         f->selection_box.wall_side = core::aabbox3d<f32>(
653                         -BS/2, -BS/3.333, -BS/10, -BS/2+BS/3.333, BS/3.333, BS/10);
654         setConstantMaterialProperties(f->material, 0.0);
655         
656         i = CONTENT_SIGN_WALL;
657         f = nodemgr->getModifiable(i);
658         f->setInventoryTexture("sign_wall.png");
659         f->used_texturenames.insert("sign_wall.png"); // Add to atlas
660         f->param_type = CPT_LIGHT;
661         f->light_propagates = true;
662         f->sunlight_propagates = true;
663         f->solidness = 0; // drawn separately, makes no faces
664         f->walkable = false;
665         f->wall_mounted = true;
666         f->air_equivalent = true;
667         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
668         if(f->initial_metadata == NULL)
669                 f->initial_metadata = new SignNodeMetadata(NULL, "Some sign");
670         setConstantMaterialProperties(f->material, 0.5);
671         f->selection_box.type = NODEBOX_WALLMOUNTED;
672         
673         i = CONTENT_CHEST;
674         f = nodemgr->getModifiable(i);
675         f->param_type = CPT_FACEDIR_SIMPLE;
676         f->setAllTextures("chest_side.png");
677         f->setTexture(0, "chest_top.png");
678         f->setTexture(1, "chest_top.png");
679         f->setTexture(5, "chest_front.png"); // Z-
680         f->setInventoryTexture("chest_top.png");
681         //f->setInventoryTextureCube("chest_top.png", "chest_side.png", "chest_side.png");
682         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
683         if(f->initial_metadata == NULL)
684                 f->initial_metadata = new ChestNodeMetadata(NULL);
685         setWoodLikeMaterialProperties(f->material, 1.0);
686         
687         i = CONTENT_LOCKABLE_CHEST;
688         f = nodemgr->getModifiable(i);
689         f->param_type = CPT_FACEDIR_SIMPLE;
690         f->setAllTextures("chest_side.png");
691         f->setTexture(0, "chest_top.png");
692         f->setTexture(1, "chest_top.png");
693         f->setTexture(5, "chest_lock.png"); // Z-
694         f->setInventoryTexture("chest_lock.png");
695         //f->setInventoryTextureCube("chest_top.png", "chest_side.png", "chest_side.png");
696         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
697         if(f->initial_metadata == NULL)
698                 f->initial_metadata = new LockingChestNodeMetadata(NULL);
699         setWoodLikeMaterialProperties(f->material, 1.0);
700
701         i = CONTENT_FURNACE;
702         f = nodemgr->getModifiable(i);
703         f->param_type = CPT_FACEDIR_SIMPLE;
704         f->setAllTextures("furnace_side.png");
705         f->setTexture(5, "furnace_front.png"); // Z-
706         f->setInventoryTexture("furnace_front.png");
707         //f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
708         f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_COBBLE)+" 6";
709         if(f->initial_metadata == NULL)
710                 f->initial_metadata = new FurnaceNodeMetadata(NULL);
711         setStoneLikeMaterialProperties(f->material, 3.0);
712         
713         i = CONTENT_COBBLE;
714         f = nodemgr->getModifiable(i);
715         f->setAllTextures("cobble.png");
716         f->setInventoryTextureCube("cobble.png", "cobble.png", "cobble.png");
717         f->param_type = CPT_NONE;
718         f->is_ground_content = true;
719         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
720         setStoneLikeMaterialProperties(f->material, 0.9);
721
722         i = CONTENT_MOSSYCOBBLE;
723         f = nodemgr->getModifiable(i);
724         f->setAllTextures("mossycobble.png");
725         f->setInventoryTextureCube("mossycobble.png", "mossycobble.png", "mossycobble.png");
726         f->param_type = CPT_NONE;
727         f->is_ground_content = true;
728         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
729         setStoneLikeMaterialProperties(f->material, 0.8);
730         
731         i = CONTENT_STEEL;
732         f = nodemgr->getModifiable(i);
733         f->setAllTextures("steel_block.png");
734         f->setInventoryTextureCube("steel_block.png", "steel_block.png",
735                         "steel_block.png");
736         f->param_type = CPT_NONE;
737         f->is_ground_content = true;
738         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
739         setStoneLikeMaterialProperties(f->material, 5.0);
740         
741         i = CONTENT_NC;
742         f = nodemgr->getModifiable(i);
743         f->param_type = CPT_FACEDIR_SIMPLE;
744         f->setAllTextures("nc_side.png");
745         f->setTexture(5, "nc_front.png"); // Z-
746         f->setTexture(4, "nc_back.png"); // Z+
747         f->setInventoryTexture("nc_front.png");
748         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
749         setStoneLikeMaterialProperties(f->material, 3.0);
750         
751         i = CONTENT_NC_RB;
752         f = nodemgr->getModifiable(i);
753         f->setAllTextures("nc_rb.png");
754         f->setInventoryTexture("nc_rb.png");
755         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
756         setStoneLikeMaterialProperties(f->material, 3.0);
757
758         i = CONTENT_SAPLING;
759         f = nodemgr->getModifiable(i);
760         f->param_type = CPT_LIGHT;
761         f->setAllTextures("sapling.png");
762         f->setInventoryTexture("sapling.png");
763         f->used_texturenames.insert("sapling.png"); // Add to atlas
764         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
765         f->light_propagates = true;
766         f->air_equivalent = false;
767         f->solidness = 0; // drawn separately, makes no faces
768         f->walkable = false;
769         setConstantMaterialProperties(f->material, 0.0);
770         
771         i = CONTENT_APPLE;
772         f = nodemgr->getModifiable(i);
773         f->setInventoryTexture("apple.png");
774         f->used_texturenames.insert("apple.png"); // Add to atlas
775         f->param_type = CPT_LIGHT;
776         f->light_propagates = true;
777         f->sunlight_propagates = true;
778         f->solidness = 0; // drawn separately, makes no faces
779         f->walkable = false;
780         f->air_equivalent = true;
781         f->dug_item = std::string("CraftItem apple 1");
782         setConstantMaterialProperties(f->material, 0.0);
783 }
784
785