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