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