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