]> git.lizzy.rs Git - minetest.git/blob - src/content_mapnode.cpp
30839773538934bc39ca3388df3ad36900775ab9
[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->setInventoryTextureCube("leaves.png", "leaves.png", "leaves.png");
240         }
241         else
242         {
243                 f->setAllTextures("[noalpha:leaves.png");
244         }
245         f->extra_dug_item = std::string("MaterialItem2 ")+itos(CONTENT_SAPLING)+" 1";
246         f->extra_dug_item_rarity = 10;
247         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
248         setWoodLikeDiggingProperties(f->digging_properties, 0.15);
249
250         i = CONTENT_CACTUS;
251         f = &content_features(i);
252         f->setAllTextures("cactus_side.png");
253         f->setTexture(0, "cactus_top.png");
254         f->setTexture(1, "cactus_top.png");
255         f->setInventoryTextureCube("cactus_top.png", "cactus_side.png", "cactus_side.png");
256         f->param_type = CPT_MINERAL;
257         f->is_ground_content = true;
258         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
259         setWoodLikeDiggingProperties(f->digging_properties, 0.75);
260
261         i = CONTENT_PAPYRUS;
262         f = &content_features(i);
263         f->setInventoryTexture("papyrus.png");
264         f->light_propagates = true;
265         f->param_type = CPT_LIGHT;
266         f->is_ground_content = true;
267         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
268         f->solidness = 0; // drawn separately, makes no faces
269         f->walkable = false;
270         setWoodLikeDiggingProperties(f->digging_properties, 0.25);
271
272         i = CONTENT_BOOKSHELF;
273         f = &content_features(i);
274         f->setAllTextures("bookshelf.png");
275         f->setTexture(0, "wood.png");
276         f->setTexture(1, "wood.png");
277         // FIXME: setInventoryTextureCube() only cares for the first texture
278         f->setInventoryTextureCube("bookshelf.png", "bookshelf.png", "bookshelf.png");
279         //f->setInventoryTextureCube("wood.png", "bookshelf.png", "bookshelf.png");
280         f->param_type = CPT_MINERAL;
281         f->is_ground_content = true;
282         setWoodLikeDiggingProperties(f->digging_properties, 0.75);
283
284         i = CONTENT_GLASS;
285         f = &content_features(i);
286         f->light_propagates = true;
287         f->sunlight_propagates = true;
288         f->param_type = CPT_LIGHT;
289         f->is_ground_content = true;
290         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
291         f->solidness = 0; // drawn separately, makes no faces
292         f->setInventoryTextureCube("glass.png", "glass.png", "glass.png");
293         setWoodLikeDiggingProperties(f->digging_properties, 0.15);
294
295         i = CONTENT_FENCE;
296         f = &content_features(i);
297         f->light_propagates = true;
298         f->param_type = CPT_LIGHT;
299         f->is_ground_content = true;
300         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
301         f->solidness = 0; // drawn separately, makes no faces
302         f->air_equivalent = true; // grass grows underneath
303         f->setInventoryTexture("fence.png");
304         setWoodLikeDiggingProperties(f->digging_properties, 0.75);
305
306         i = CONTENT_RAIL;
307         f = &content_features(i);
308         f->setInventoryTexture("rail.png");
309         f->light_propagates = true;
310         f->param_type = CPT_LIGHT;
311         f->is_ground_content = true;
312         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
313         f->solidness = 0; // drawn separately, makes no faces
314         f->air_equivalent = true; // grass grows underneath
315         f->walkable = false;
316         setDirtLikeDiggingProperties(f->digging_properties, 0.75);
317
318         i = CONTENT_LADDER;
319         f = &content_features(i);
320         f->setInventoryTexture("ladder.png");
321         f->light_propagates = true;
322         f->param_type = CPT_LIGHT;
323         f->is_ground_content = true;
324         f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
325         f->wall_mounted = true;
326         f->solidness = 0;
327         f->air_equivalent = true;
328         f->walkable = false;
329         f->climbable = true;
330         setWoodLikeDiggingProperties(f->digging_properties, 0.5);
331
332         // Deprecated
333         i = CONTENT_COALSTONE;
334         f = &content_features(i);
335         f->setAllTextures("stone.png^mineral_coal.png");
336         f->is_ground_content = true;
337         setStoneLikeDiggingProperties(f->digging_properties, 1.5);
338         
339         i = CONTENT_WOOD;
340         f = &content_features(i);
341         f->setAllTextures("wood.png");
342         f->setInventoryTextureCube("wood.png", "wood.png", "wood.png");
343         f->is_ground_content = true;
344         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
345         setWoodLikeDiggingProperties(f->digging_properties, 0.75);
346         
347         i = CONTENT_MESE;
348         f = &content_features(i);
349         f->setAllTextures("mese.png");
350         f->setInventoryTextureCube("mese.png", "mese.png", "mese.png");
351         f->is_ground_content = true;
352         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
353         setStoneLikeDiggingProperties(f->digging_properties, 0.5);
354         
355         i = CONTENT_CLOUD;
356         f = &content_features(i);
357         f->setAllTextures("cloud.png");
358         f->setInventoryTextureCube("cloud.png", "cloud.png", "cloud.png");
359         f->is_ground_content = true;
360         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
361         
362         i = CONTENT_AIR;
363         f = &content_features(i);
364         f->param_type = CPT_LIGHT;
365         f->light_propagates = true;
366         f->sunlight_propagates = true;
367         f->solidness = 0;
368         f->walkable = false;
369         f->pointable = false;
370         f->diggable = false;
371         f->buildable_to = true;
372         f->air_equivalent = true;
373         
374         i = CONTENT_WATER;
375         f = &content_features(i);
376         f->setInventoryTextureCube("water.png", "water.png", "water.png");
377         f->param_type = CPT_LIGHT;
378         f->light_propagates = true;
379         f->solidness = 0; // Drawn separately, makes no faces
380         f->visual_solidness = 1;
381         f->walkable = false;
382         f->pointable = false;
383         f->diggable = false;
384         f->buildable_to = true;
385         f->liquid_type = LIQUID_FLOWING;
386         f->liquid_alternative_flowing = CONTENT_WATER;
387         f->liquid_alternative_source = CONTENT_WATERSOURCE;
388         f->liquid_viscosity = WATER_VISC;
389         f->vertex_alpha = WATER_ALPHA;
390         if(f->special_material == NULL && g_texturesource)
391         {
392                 // Flowing water material
393                 f->special_material = new video::SMaterial;
394                 f->special_material->setFlag(video::EMF_LIGHTING, false);
395                 f->special_material->setFlag(video::EMF_BACK_FACE_CULLING, false);
396                 f->special_material->setFlag(video::EMF_BILINEAR_FILTER, false);
397                 f->special_material->setFlag(video::EMF_FOG_ENABLE, true);
398                 f->special_material->MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
399                 AtlasPointer *pa_water1 = new AtlasPointer(g_texturesource->getTexture(
400                                 g_texturesource->getTextureId("water.png")));
401                 f->special_material->setTexture(0, pa_water1->atlas);
402                 f->special_atlas = pa_water1;
403         }
404         
405         i = CONTENT_WATERSOURCE;
406         f = &content_features(i);
407         //f->setInventoryTexture("water.png");
408         f->setInventoryTextureCube("water.png", "water.png", "water.png");
409         if(new_style_water)
410         {
411                 f->solidness = 0; // drawn separately, makes no faces
412         }
413         else // old style
414         {
415                 f->solidness = 1;
416
417                 TileSpec t;
418                 if(g_texturesource)
419                         t.texture = g_texturesource->getTexture("water.png");
420                 
421                 t.alpha = WATER_ALPHA;
422                 t.material_type = MATERIAL_ALPHA_VERTEX;
423                 t.material_flags &= ~MATERIAL_FLAG_BACKFACE_CULLING;
424                 f->setAllTiles(t);
425         }
426         f->param_type = CPT_LIGHT;
427         f->light_propagates = true;
428         f->walkable = false;
429         f->pointable = false;
430         f->diggable = false;
431         f->buildable_to = true;
432         f->liquid_type = LIQUID_SOURCE;
433         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
434         f->liquid_alternative_flowing = CONTENT_WATER;
435         f->liquid_alternative_source = CONTENT_WATERSOURCE;
436         f->liquid_viscosity = WATER_VISC;
437         f->vertex_alpha = WATER_ALPHA;
438         if(f->special_material == NULL && g_texturesource)
439         {
440                 // Flowing water material
441                 f->special_material = new video::SMaterial;
442                 f->special_material->setFlag(video::EMF_LIGHTING, false);
443                 f->special_material->setFlag(video::EMF_BACK_FACE_CULLING, false);
444                 f->special_material->setFlag(video::EMF_BILINEAR_FILTER, false);
445                 f->special_material->setFlag(video::EMF_FOG_ENABLE, true);
446                 f->special_material->MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
447                 AtlasPointer *pa_water1 = new AtlasPointer(g_texturesource->getTexture(
448                                 g_texturesource->getTextureId("water.png")));
449                 f->special_material->setTexture(0, pa_water1->atlas);
450                 f->special_atlas = pa_water1;
451         }
452         
453         i = CONTENT_LAVA;
454         f = &content_features(i);
455         f->setInventoryTextureCube("lava.png", "lava.png", "lava.png");
456         f->param_type = CPT_LIGHT;
457         f->light_propagates = false;
458         f->light_source = LIGHT_MAX-1;
459         f->solidness = 0; // Drawn separately, makes no faces
460         f->visual_solidness = 2;
461         f->walkable = false;
462         f->pointable = false;
463         f->diggable = false;
464         f->buildable_to = true;
465         f->liquid_type = LIQUID_FLOWING;
466         f->liquid_alternative_flowing = CONTENT_LAVA;
467         f->liquid_alternative_source = CONTENT_LAVASOURCE;
468         f->liquid_viscosity = LAVA_VISC;
469         f->damage_per_second = 4*2;
470         if(f->special_material == NULL && g_texturesource)
471         {
472                 // Flowing lava material
473                 f->special_material = new video::SMaterial;
474                 f->special_material->setFlag(video::EMF_LIGHTING, false);
475                 f->special_material->setFlag(video::EMF_BACK_FACE_CULLING, false);
476                 f->special_material->setFlag(video::EMF_BILINEAR_FILTER, false);
477                 f->special_material->setFlag(video::EMF_FOG_ENABLE, true);
478                 f->special_material->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
479                 AtlasPointer *pa_lava1 = new AtlasPointer(
480                         g_texturesource->getTexture(
481                                 g_texturesource->getTextureId("lava.png")));
482                 f->special_material->setTexture(0, pa_lava1->atlas);
483                 f->special_atlas = pa_lava1;
484         }
485         
486         i = CONTENT_LAVASOURCE;
487         f = &content_features(i);
488         f->setInventoryTextureCube("lava.png", "lava.png", "lava.png");
489         if(new_style_water)
490         {
491                 f->solidness = 0; // drawn separately, makes no faces
492         }
493         else // old style
494         {
495                 f->solidness = 2;
496
497                 TileSpec t;
498                 if(g_texturesource)
499                         t.texture = g_texturesource->getTexture("lava.png");
500                 
501                 //t.alpha = 255;
502                 //t.material_type = MATERIAL_ALPHA_VERTEX;
503                 //t.material_flags &= ~MATERIAL_FLAG_BACKFACE_CULLING;
504                 f->setAllTiles(t);
505         }
506         f->param_type = CPT_LIGHT;
507         f->light_propagates = false;
508         f->light_source = LIGHT_MAX-1;
509         f->walkable = false;
510         f->pointable = false;
511         f->diggable = false;
512         f->buildable_to = true;
513         f->liquid_type = LIQUID_SOURCE;
514         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
515         f->liquid_alternative_flowing = CONTENT_LAVA;
516         f->liquid_alternative_source = CONTENT_LAVASOURCE;
517         f->liquid_viscosity = LAVA_VISC;
518         f->damage_per_second = 4*2;
519         if(f->special_material == NULL && g_texturesource)
520         {
521                 // Flowing lava material
522                 f->special_material = new video::SMaterial;
523                 f->special_material->setFlag(video::EMF_LIGHTING, false);
524                 f->special_material->setFlag(video::EMF_BACK_FACE_CULLING, false);
525                 f->special_material->setFlag(video::EMF_BILINEAR_FILTER, false);
526                 f->special_material->setFlag(video::EMF_FOG_ENABLE, true);
527                 f->special_material->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
528                 AtlasPointer *pa_lava1 = new AtlasPointer(
529                         g_texturesource->getTexture(
530                                 g_texturesource->getTextureId("lava.png")));
531                 f->special_material->setTexture(0, pa_lava1->atlas);
532                 f->special_atlas = pa_lava1;
533         }
534         
535         i = CONTENT_TORCH;
536         f = &content_features(i);
537         f->setInventoryTexture("torch_on_floor.png");
538         f->param_type = CPT_LIGHT;
539         f->light_propagates = true;
540         f->sunlight_propagates = true;
541         f->solidness = 0; // drawn separately, makes no faces
542         f->walkable = false;
543         f->wall_mounted = true;
544         f->air_equivalent = true;
545         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
546         f->light_source = LIGHT_MAX-1;
547         f->digging_properties.set("", DiggingProperties(true, 0.0, 0));
548         
549         i = CONTENT_SIGN_WALL;
550         f = &content_features(i);
551         f->setInventoryTexture("sign_wall.png");
552         f->param_type = CPT_LIGHT;
553         f->light_propagates = true;
554         f->sunlight_propagates = true;
555         f->solidness = 0; // drawn separately, makes no faces
556         f->walkable = false;
557         f->wall_mounted = true;
558         f->air_equivalent = true;
559         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
560         if(f->initial_metadata == NULL)
561                 f->initial_metadata = new SignNodeMetadata("Some sign");
562         f->digging_properties.set("", DiggingProperties(true, 0.5, 0));
563         
564         i = CONTENT_CHEST;
565         f = &content_features(i);
566         f->param_type = CPT_FACEDIR_SIMPLE;
567         f->setAllTextures("chest_side.png");
568         f->setTexture(0, "chest_top.png");
569         f->setTexture(1, "chest_top.png");
570         f->setTexture(5, "chest_front.png"); // Z-
571         f->setInventoryTexture("chest_top.png");
572         //f->setInventoryTextureCube("chest_top.png", "chest_side.png", "chest_side.png");
573         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
574         if(f->initial_metadata == NULL)
575                 f->initial_metadata = new ChestNodeMetadata();
576         setWoodLikeDiggingProperties(f->digging_properties, 1.0);
577         
578         i = CONTENT_FURNACE;
579         f = &content_features(i);
580         f->param_type = CPT_FACEDIR_SIMPLE;
581         f->setAllTextures("furnace_side.png");
582         f->setTexture(5, "furnace_front.png"); // Z-
583         f->setInventoryTexture("furnace_front.png");
584         //f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
585         f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_COBBLE)+" 6";
586         if(f->initial_metadata == NULL)
587                 f->initial_metadata = new FurnaceNodeMetadata();
588         setStoneLikeDiggingProperties(f->digging_properties, 3.0);
589         
590         i = CONTENT_COBBLE;
591         f = &content_features(i);
592         f->setAllTextures("cobble.png");
593         f->setInventoryTextureCube("cobble.png", "cobble.png", "cobble.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.9);
598
599         i = CONTENT_MOSSYCOBBLE;
600         f = &content_features(i);
601         f->setAllTextures("mossycobble.png");
602         f->setInventoryTextureCube("mossycobble.png", "mossycobble.png", "mossycobble.png");
603         f->param_type = CPT_NONE;
604         f->is_ground_content = true;
605         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
606         setStoneLikeDiggingProperties(f->digging_properties, 0.8);
607         
608         i = CONTENT_STEEL;
609         f = &content_features(i);
610         f->setAllTextures("steel_block.png");
611         f->setInventoryTextureCube("steel_block.png", "steel_block.png",
612                         "steel_block.png");
613         f->param_type = CPT_NONE;
614         f->is_ground_content = true;
615         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
616         setStoneLikeDiggingProperties(f->digging_properties, 5.0);
617         
618         i = CONTENT_NC;
619         f = &content_features(i);
620         f->param_type = CPT_FACEDIR_SIMPLE;
621         f->setAllTextures("nc_side.png");
622         f->setTexture(5, "nc_front.png"); // Z-
623         f->setTexture(4, "nc_back.png"); // Z+
624         f->setInventoryTexture("nc_front.png");
625         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
626         setStoneLikeDiggingProperties(f->digging_properties, 3.0);
627         
628         i = CONTENT_NC_RB;
629         f = &content_features(i);
630         f->setAllTextures("nc_rb.png");
631         f->setInventoryTexture("nc_rb.png");
632         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
633         setStoneLikeDiggingProperties(f->digging_properties, 3.0);
634
635         i = CONTENT_SAPLING;
636         f = &content_features(i);
637         f->param_type = CPT_LIGHT;
638         f->setAllTextures("sapling.png");
639         f->setInventoryTexture("sapling.png");
640         f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
641         f->light_propagates = true;
642         f->air_equivalent = false;
643         f->solidness = 0; // drawn separately, makes no faces
644         f->walkable = false;
645         f->digging_properties.set("", DiggingProperties(true, 0.0, 0));
646         
647         i = CONTENT_APPLE;
648         f = &content_features(i);
649         f->setInventoryTexture("apple.png");
650         f->param_type = CPT_LIGHT;
651         f->light_propagates = true;
652         f->sunlight_propagates = true;
653         f->solidness = 0; // drawn separately, makes no faces
654         f->walkable = false;
655         f->air_equivalent = true;
656         f->dug_item = std::string("CraftItem apple 1");
657         f->digging_properties.set("", DiggingProperties(true, 0.0, 0));
658         
659         // NOTE: Remember to add frequently used stuff to the texture atlas in tile.cpp
660         
661
662         /*
663                 Add MesePick to everything
664         */
665         for(u16 i=0; i<=MAX_CONTENT; i++)
666         {
667                 content_features(i).digging_properties.set("MesePick",
668                                 DiggingProperties(true, 0.0, 65535./1337));
669         }
670
671 }
672
673 void setStoneLikeDiggingProperties(DiggingPropertiesList &list, float toughness)
674 {
675         list.set("",
676                         DiggingProperties(true, 15.0*toughness, 0));
677         
678         list.set("WPick",
679                         DiggingProperties(true, 1.3*toughness, 65535./30.*toughness));
680         list.set("STPick",
681                         DiggingProperties(true, 0.75*toughness, 65535./100.*toughness));
682         list.set("SteelPick",
683                         DiggingProperties(true, 0.50*toughness, 65535./333.*toughness));
684
685         /*list.set("MesePick",
686                         DiggingProperties(true, 0.0*toughness, 65535./20.*toughness));*/
687 }
688
689 void setDirtLikeDiggingProperties(DiggingPropertiesList &list, float toughness)
690 {
691         list.set("",
692                         DiggingProperties(true, 0.75*toughness, 0));
693         
694         list.set("WShovel",
695                         DiggingProperties(true, 0.4*toughness, 65535./50.*toughness));
696         list.set("STShovel",
697                         DiggingProperties(true, 0.2*toughness, 65535./150.*toughness));
698         list.set("SteelShovel",
699                         DiggingProperties(true, 0.15*toughness, 65535./400.*toughness));
700 }
701
702 void setWoodLikeDiggingProperties(DiggingPropertiesList &list, float toughness)
703 {
704         list.set("",
705                         DiggingProperties(true, 3.0*toughness, 0));
706         
707         list.set("WAxe",
708                         DiggingProperties(true, 1.5*toughness, 65535./30.*toughness));
709         list.set("STAxe",
710                         DiggingProperties(true, 0.75*toughness, 65535./100.*toughness));
711         list.set("SteelAxe",
712                         DiggingProperties(true, 0.5*toughness, 65535./333.*toughness));
713 }
714
715