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