3 Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
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.
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.
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.
23 #include "content_mapnode.h"
25 #include "content_nodemeta.h"
27 // TODO: Get rid of these and set up some attributes like toughness,
28 // fluffyness, and a funciton to calculate time and durability loss
29 // (and sound? and whatever else) from them
30 void setStoneLikeDiggingProperties(DiggingPropertiesList &list, float toughness);
31 void setDirtLikeDiggingProperties(DiggingPropertiesList &list, float toughness);
32 void setWoodLikeDiggingProperties(DiggingPropertiesList &list, float toughness);
34 void content_mapnode_init()
37 bool new_style_water = g_settings.getBool("new_style_water");
38 bool new_style_leaves = g_settings.getBool("new_style_leaves");
39 bool invisible_stone = g_settings.getBool("invisible_stone");
42 ContentFeatures *f = NULL;
45 f = &content_features(i);
46 f->setAllTextures("stone.png");
47 f->setInventoryTextureCube("stone.png", "stone.png", "stone.png");
48 f->param_type = CPT_MINERAL;
49 f->is_ground_content = true;
50 f->dug_item = std::string("MaterialItem ")+itos(CONTENT_COBBLE)+" 1";
51 setStoneLikeDiggingProperties(f->digging_properties, 1.0);
53 f->solidness = 0; // For debugging, hides regular stone
56 f = &content_features(i);
57 f->setAllTextures("mud.png^grass_side.png");
58 f->setTexture(0, "grass.png");
59 f->setTexture(1, "mud.png");
60 f->param_type = CPT_MINERAL;
61 f->is_ground_content = true;
62 f->dug_item = std::string("MaterialItem ")+itos(CONTENT_MUD)+" 1";
63 setDirtLikeDiggingProperties(f->digging_properties, 1.0);
65 i = CONTENT_GRASS_FOOTSTEPS;
66 f = &content_features(i);
67 f->setAllTextures("mud.png^grass_side.png");
68 f->setTexture(0, "grass_footsteps.png");
69 f->setTexture(1, "mud.png");
70 f->param_type = CPT_MINERAL;
71 f->is_ground_content = true;
72 f->dug_item = std::string("MaterialItem ")+itos(CONTENT_MUD)+" 1";
73 setDirtLikeDiggingProperties(f->digging_properties, 1.0);
76 f = &content_features(i);
77 f->setAllTextures("mud.png");
78 f->setInventoryTextureCube("mud.png", "mud.png", "mud.png");
79 f->param_type = CPT_MINERAL;
80 f->is_ground_content = true;
81 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
82 setDirtLikeDiggingProperties(f->digging_properties, 1.0);
85 f = &content_features(i);
86 f->setAllTextures("sand.png");
87 f->setInventoryTextureCube("sand.png", "sand.png", "sand.png");
88 f->param_type = CPT_MINERAL;
89 f->is_ground_content = true;
90 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
91 setDirtLikeDiggingProperties(f->digging_properties, 1.0);
94 f = &content_features(i);
95 f->setAllTextures("gravel.png");
96 f->setInventoryTextureCube("gravel.png", "gravel.png", "gravel.png");
97 f->param_type = CPT_MINERAL;
98 f->is_ground_content = true;
99 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
100 setDirtLikeDiggingProperties(f->digging_properties, 1.75);
103 f = &content_features(i);
104 f->setAllTextures("tree.png");
105 f->setTexture(0, "tree_top.png");
106 f->setTexture(1, "tree_top.png");
107 f->param_type = CPT_MINERAL;
108 f->is_ground_content = true;
109 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
110 setWoodLikeDiggingProperties(f->digging_properties, 1.0);
113 f = &content_features(i);
114 f->light_propagates = true;
115 //f->param_type = CPT_MINERAL;
116 f->param_type = CPT_LIGHT;
117 f->is_ground_content = true;
120 f->solidness = 0; // drawn separately, makes no faces
121 f->setInventoryTextureCube("leaves.png", "leaves.png", "leaves.png");
125 f->setAllTextures("[noalpha:leaves.png");
127 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
128 setWoodLikeDiggingProperties(f->digging_properties, 0.15);
131 f = &content_features(i);
132 f->light_propagates = true;
133 f->param_type = CPT_LIGHT;
134 f->is_ground_content = true;
135 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
136 f->solidness = 0; // drawn separately, makes no faces
137 f->setInventoryTextureCube("glass.png", "glass.png", "glass.png");
138 setWoodLikeDiggingProperties(f->digging_properties, 0.15);
141 f = &content_features(i);
142 f->light_propagates = true;
143 f->param_type = CPT_LIGHT;
144 f->is_ground_content = true;
145 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
146 f->solidness = 0; // drawn separately, makes no faces
147 f->air_equivalent = true; // grass grows underneath
148 f->setInventoryTexture("item_fence.png");
149 setWoodLikeDiggingProperties(f->digging_properties, 0.75);
152 i = CONTENT_COALSTONE;
153 f = &content_features(i);
154 //f->translate_to = new MapNode(CONTENT_STONE, MINERAL_COAL);
155 f->setAllTextures("stone.png^mineral_coal.png");
156 f->is_ground_content = true;
157 setStoneLikeDiggingProperties(f->digging_properties, 1.5);
160 f = &content_features(i);
161 f->setAllTextures("wood.png");
162 f->setInventoryTextureCube("wood.png", "wood.png", "wood.png");
163 f->is_ground_content = true;
164 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
165 setWoodLikeDiggingProperties(f->digging_properties, 0.75);
168 f = &content_features(i);
169 f->setAllTextures("mese.png");
170 f->setInventoryTextureCube("mese.png", "mese.png", "mese.png");
171 f->is_ground_content = true;
172 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
173 setStoneLikeDiggingProperties(f->digging_properties, 0.5);
176 f = &content_features(i);
177 f->setAllTextures("cloud.png");
178 f->setInventoryTextureCube("cloud.png", "cloud.png", "cloud.png");
179 f->is_ground_content = true;
180 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
183 f = &content_features(i);
184 f->param_type = CPT_LIGHT;
185 f->light_propagates = true;
186 f->sunlight_propagates = true;
189 f->pointable = false;
191 f->buildable_to = true;
192 f->air_equivalent = true;
195 f = &content_features(i);
196 f->setInventoryTextureCube("water.png", "water.png", "water.png");
197 f->param_type = CPT_LIGHT;
198 f->light_propagates = true;
199 f->solidness = 0; // Drawn separately, makes no faces
201 f->pointable = false;
203 f->buildable_to = true;
204 f->liquid_type = LIQUID_FLOWING;
205 f->liquid_alternative_flowing = CONTENT_WATER;
207 i = CONTENT_WATERSOURCE;
208 f = &content_features(i);
209 //f->setInventoryTexture("water.png");
210 f->setInventoryTextureCube("water.png", "water.png", "water.png");
213 f->solidness = 0; // drawn separately, makes no faces
221 t.texture = g_texturesource->getTexture("water.png");
223 t.alpha = WATER_ALPHA;
224 t.material_type = MATERIAL_ALPHA_VERTEX;
225 t.material_flags &= ~MATERIAL_FLAG_BACKFACE_CULLING;
228 f->param_type = CPT_LIGHT;
229 f->light_propagates = true;
231 f->pointable = false;
233 f->buildable_to = true;
234 f->liquid_type = LIQUID_SOURCE;
235 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
236 f->liquid_alternative_flowing = CONTENT_WATER;
239 f = &content_features(i);
240 f->setInventoryTexture("torch_on_floor.png");
241 f->param_type = CPT_LIGHT;
242 f->light_propagates = true;
243 f->sunlight_propagates = true;
244 f->solidness = 0; // drawn separately, makes no faces
246 f->wall_mounted = true;
247 f->air_equivalent = true;
248 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
249 f->light_source = LIGHT_MAX-1;
250 f->digging_properties.set("", DiggingProperties(true, 0.0, 0));
252 i = CONTENT_SIGN_WALL;
253 f = &content_features(i);
254 f->setInventoryTexture("sign_wall.png");
255 f->param_type = CPT_LIGHT;
256 f->light_propagates = true;
257 f->sunlight_propagates = true;
258 f->solidness = 0; // drawn separately, makes no faces
260 f->wall_mounted = true;
261 f->air_equivalent = true;
262 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
263 if(f->initial_metadata == NULL)
264 f->initial_metadata = new SignNodeMetadata("Some sign");
265 f->digging_properties.set("", DiggingProperties(true, 0.5, 0));
268 f = &content_features(i);
269 f->param_type = CPT_FACEDIR_SIMPLE;
270 f->setAllTextures("chest_side.png");
271 f->setTexture(0, "chest_top.png");
272 f->setTexture(1, "chest_top.png");
273 f->setTexture(5, "chest_front.png"); // Z-
274 f->setInventoryTexture("chest_top.png");
275 //f->setInventoryTextureCube("chest_top.png", "chest_side.png", "chest_side.png");
276 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
277 if(f->initial_metadata == NULL)
278 f->initial_metadata = new ChestNodeMetadata();
279 setWoodLikeDiggingProperties(f->digging_properties, 1.0);
282 f = &content_features(i);
283 f->param_type = CPT_FACEDIR_SIMPLE;
284 f->setAllTextures("furnace_side.png");
285 f->setTexture(5, "furnace_front.png"); // Z-
286 f->setInventoryTexture("furnace_front.png");
287 //f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
288 f->dug_item = std::string("MaterialItem ")+itos(CONTENT_COBBLE)+" 6";
289 if(f->initial_metadata == NULL)
290 f->initial_metadata = new FurnaceNodeMetadata();
291 setStoneLikeDiggingProperties(f->digging_properties, 3.0);
294 f = &content_features(i);
295 f->setAllTextures("cobble.png");
296 f->setInventoryTextureCube("cobble.png", "cobble.png", "cobble.png");
297 f->param_type = CPT_NONE;
298 f->is_ground_content = true;
299 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
300 setStoneLikeDiggingProperties(f->digging_properties, 0.9);
302 i = CONTENT_MOSSYCOBBLE;
303 f = &content_features(i);
304 f->setAllTextures("mossycobble.png");
305 f->setInventoryTextureCube("mossycobble.png", "mossycobble.png", "mossycobble.png");
306 f->param_type = CPT_NONE;
307 f->is_ground_content = true;
308 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
309 setStoneLikeDiggingProperties(f->digging_properties, 0.8);
312 f = &content_features(i);
313 f->setAllTextures("steel_block.png");
314 f->setInventoryTextureCube("steel_block.png", "steel_block.png",
316 f->param_type = CPT_NONE;
317 f->is_ground_content = true;
318 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
319 setStoneLikeDiggingProperties(f->digging_properties, 5.0);
321 // NOTE: Remember to add frequently used stuff to the texture atlas in tile.cpp
325 Add MesePick to everything
327 for(u16 i=0; i<256; i++)
329 content_features(i).digging_properties.set("MesePick",
330 DiggingProperties(true, 0.0, 65535./1337));
335 void setStoneLikeDiggingProperties(DiggingPropertiesList &list, float toughness)
338 DiggingProperties(true, 15.0*toughness, 0));
341 DiggingProperties(true, 1.3*toughness, 65535./30.*toughness));
343 DiggingProperties(true, 0.75*toughness, 65535./100.*toughness));
344 list.set("SteelPick",
345 DiggingProperties(true, 0.50*toughness, 65535./333.*toughness));
347 /*list.set("MesePick",
348 DiggingProperties(true, 0.0*toughness, 65535./20.*toughness));*/
351 void setDirtLikeDiggingProperties(DiggingPropertiesList &list, float toughness)
354 DiggingProperties(true, 0.75*toughness, 0));
357 DiggingProperties(true, 0.4*toughness, 65535./50.*toughness));
359 DiggingProperties(true, 0.2*toughness, 65535./150.*toughness));
360 list.set("SteelShovel",
361 DiggingProperties(true, 0.15*toughness, 65535./400.*toughness));
364 void setWoodLikeDiggingProperties(DiggingPropertiesList &list, float toughness)
367 DiggingProperties(true, 3.0*toughness, 0));
370 DiggingProperties(true, 1.5*toughness, 65535./30.*toughness));
372 DiggingProperties(true, 0.75*toughness, 65535./100.*toughness));
374 DiggingProperties(true, 0.5*toughness, 65535./333.*toughness));