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->setAllTextures("stone.png^mineral_coal.png");
155 f->is_ground_content = true;
156 setStoneLikeDiggingProperties(f->digging_properties, 1.5);
159 f = &content_features(i);
160 f->setAllTextures("wood.png");
161 f->setInventoryTextureCube("wood.png", "wood.png", "wood.png");
162 f->is_ground_content = true;
163 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
164 setWoodLikeDiggingProperties(f->digging_properties, 0.75);
167 f = &content_features(i);
168 f->setAllTextures("mese.png");
169 f->setInventoryTextureCube("mese.png", "mese.png", "mese.png");
170 f->is_ground_content = true;
171 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
172 setStoneLikeDiggingProperties(f->digging_properties, 0.5);
175 f = &content_features(i);
176 f->setAllTextures("cloud.png");
177 f->setInventoryTextureCube("cloud.png", "cloud.png", "cloud.png");
178 f->is_ground_content = true;
179 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
182 f = &content_features(i);
183 f->param_type = CPT_LIGHT;
184 f->light_propagates = true;
185 f->sunlight_propagates = true;
188 f->pointable = false;
190 f->buildable_to = true;
191 f->air_equivalent = true;
194 f = &content_features(i);
195 f->setInventoryTextureCube("water.png", "water.png", "water.png");
196 f->param_type = CPT_LIGHT;
197 f->light_propagates = true;
198 f->solidness = 0; // Drawn separately, makes no faces
200 f->pointable = false;
202 f->buildable_to = true;
203 f->liquid_type = LIQUID_FLOWING;
204 f->liquid_alternative_flowing = CONTENT_WATER;
206 i = CONTENT_WATERSOURCE;
207 f = &content_features(i);
208 //f->setInventoryTexture("water.png");
209 f->setInventoryTextureCube("water.png", "water.png", "water.png");
212 f->solidness = 0; // drawn separately, makes no faces
220 t.texture = g_texturesource->getTexture("water.png");
222 t.alpha = WATER_ALPHA;
223 t.material_type = MATERIAL_ALPHA_VERTEX;
224 t.material_flags &= ~MATERIAL_FLAG_BACKFACE_CULLING;
227 f->param_type = CPT_LIGHT;
228 f->light_propagates = true;
230 f->pointable = false;
232 f->buildable_to = true;
233 f->liquid_type = LIQUID_SOURCE;
234 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
235 f->liquid_alternative_flowing = CONTENT_WATER;
238 f = &content_features(i);
239 f->setInventoryTexture("torch_on_floor.png");
240 f->param_type = CPT_LIGHT;
241 f->light_propagates = true;
242 f->sunlight_propagates = true;
243 f->solidness = 0; // drawn separately, makes no faces
245 f->wall_mounted = true;
246 f->air_equivalent = true;
247 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
248 f->light_source = LIGHT_MAX-1;
249 f->digging_properties.set("", DiggingProperties(true, 0.0, 0));
251 i = CONTENT_SIGN_WALL;
252 f = &content_features(i);
253 f->setInventoryTexture("sign_wall.png");
254 f->param_type = CPT_LIGHT;
255 f->light_propagates = true;
256 f->sunlight_propagates = true;
257 f->solidness = 0; // drawn separately, makes no faces
259 f->wall_mounted = true;
260 f->air_equivalent = true;
261 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
262 if(f->initial_metadata == NULL)
263 f->initial_metadata = new SignNodeMetadata("Some sign");
264 f->digging_properties.set("", DiggingProperties(true, 0.5, 0));
267 f = &content_features(i);
268 f->param_type = CPT_FACEDIR_SIMPLE;
269 f->setAllTextures("chest_side.png");
270 f->setTexture(0, "chest_top.png");
271 f->setTexture(1, "chest_top.png");
272 f->setTexture(5, "chest_front.png"); // Z-
273 f->setInventoryTexture("chest_top.png");
274 //f->setInventoryTextureCube("chest_top.png", "chest_side.png", "chest_side.png");
275 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
276 if(f->initial_metadata == NULL)
277 f->initial_metadata = new ChestNodeMetadata();
278 setWoodLikeDiggingProperties(f->digging_properties, 1.0);
281 f = &content_features(i);
282 f->param_type = CPT_FACEDIR_SIMPLE;
283 f->setAllTextures("furnace_side.png");
284 f->setTexture(5, "furnace_front.png"); // Z-
285 f->setInventoryTexture("furnace_front.png");
286 //f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
287 f->dug_item = std::string("MaterialItem ")+itos(CONTENT_COBBLE)+" 6";
288 if(f->initial_metadata == NULL)
289 f->initial_metadata = new FurnaceNodeMetadata();
290 setStoneLikeDiggingProperties(f->digging_properties, 3.0);
293 f = &content_features(i);
294 f->setAllTextures("cobble.png");
295 f->setInventoryTextureCube("cobble.png", "cobble.png", "cobble.png");
296 f->param_type = CPT_NONE;
297 f->is_ground_content = true;
298 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
299 setStoneLikeDiggingProperties(f->digging_properties, 0.9);
301 i = CONTENT_MOSSYCOBBLE;
302 f = &content_features(i);
303 f->setAllTextures("mossycobble.png");
304 f->setInventoryTextureCube("mossycobble.png", "mossycobble.png", "mossycobble.png");
305 f->param_type = CPT_NONE;
306 f->is_ground_content = true;
307 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
308 setStoneLikeDiggingProperties(f->digging_properties, 0.8);
311 f = &content_features(i);
312 f->setAllTextures("steel_block.png");
313 f->setInventoryTextureCube("steel_block.png", "steel_block.png",
315 f->param_type = CPT_NONE;
316 f->is_ground_content = true;
317 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
318 setStoneLikeDiggingProperties(f->digging_properties, 5.0);
320 // NOTE: Remember to add frequently used stuff to the texture atlas in tile.cpp
324 Add MesePick to everything
326 for(u16 i=0; i<256; i++)
328 content_features(i).digging_properties.set("MesePick",
329 DiggingProperties(true, 0.0, 65535./1337));
334 void setStoneLikeDiggingProperties(DiggingPropertiesList &list, float toughness)
337 DiggingProperties(true, 15.0*toughness, 0));
340 DiggingProperties(true, 1.3*toughness, 65535./30.*toughness));
342 DiggingProperties(true, 0.75*toughness, 65535./100.*toughness));
343 list.set("SteelPick",
344 DiggingProperties(true, 0.50*toughness, 65535./333.*toughness));
346 /*list.set("MesePick",
347 DiggingProperties(true, 0.0*toughness, 65535./20.*toughness));*/
350 void setDirtLikeDiggingProperties(DiggingPropertiesList &list, float toughness)
353 DiggingProperties(true, 0.75*toughness, 0));
356 DiggingProperties(true, 0.4*toughness, 65535./50.*toughness));
358 DiggingProperties(true, 0.2*toughness, 65535./150.*toughness));
359 list.set("SteelShovel",
360 DiggingProperties(true, 0.15*toughness, 65535./400.*toughness));
363 void setWoodLikeDiggingProperties(DiggingPropertiesList &list, float toughness)
366 DiggingProperties(true, 3.0*toughness, 0));
369 DiggingProperties(true, 1.5*toughness, 65535./30.*toughness));
371 DiggingProperties(true, 0.75*toughness, 65535./100.*toughness));
373 DiggingProperties(true, 0.5*toughness, 65535./333.*toughness));