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