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 content_t trans_table_19[][2] = {
38 {CONTENT_GRASS_FOOTSTEPS, 6},
42 {CONTENT_COALSTONE, 11},
48 {CONTENT_MOSSYCOBBLE, 22},
52 MapNode mapnode_translate_from_internal(MapNode n_from, u8 version)
54 MapNode result = n_from;
57 content_t c_from = n_from.getContent();
58 for(u32 i=0; i<sizeof(trans_table_19)/sizeof(trans_table_19[0]); i++)
60 if(trans_table_19[i][0] == c_from)
62 result.setContent(trans_table_19[i][1]);
69 MapNode mapnode_translate_to_internal(MapNode n_from, u8 version)
71 MapNode result = n_from;
74 content_t c_from = n_from.getContent();
75 for(u32 i=0; i<sizeof(trans_table_19)/sizeof(trans_table_19[0]); i++)
77 if(trans_table_19[i][1] == c_from)
79 result.setContent(trans_table_19[i][0]);
87 void content_mapnode_init()
90 bool new_style_water = g_settings.getBool("new_style_water");
91 bool new_style_leaves = g_settings.getBool("new_style_leaves");
92 bool invisible_stone = g_settings.getBool("invisible_stone");
95 ContentFeatures *f = NULL;
98 f = &content_features(i);
99 f->setAllTextures("stone.png");
100 f->setInventoryTextureCube("stone.png", "stone.png", "stone.png");
101 f->param_type = CPT_MINERAL;
102 f->is_ground_content = true;
103 f->dug_item = std::string("MaterialItem ")+itos(CONTENT_COBBLE)+" 1";
104 setStoneLikeDiggingProperties(f->digging_properties, 1.0);
106 f->solidness = 0; // For debugging, hides regular stone
109 f = &content_features(i);
110 f->setAllTextures("mud.png^grass_side.png");
111 f->setTexture(0, "grass.png");
112 f->setTexture(1, "mud.png");
113 f->param_type = CPT_MINERAL;
114 f->is_ground_content = true;
115 f->dug_item = std::string("MaterialItem ")+itos(CONTENT_MUD)+" 1";
116 setDirtLikeDiggingProperties(f->digging_properties, 1.0);
118 i = CONTENT_GRASS_FOOTSTEPS;
119 f = &content_features(i);
120 f->setAllTextures("mud.png^grass_side.png");
121 f->setTexture(0, "grass_footsteps.png");
122 f->setTexture(1, "mud.png");
123 f->param_type = CPT_MINERAL;
124 f->is_ground_content = true;
125 f->dug_item = std::string("MaterialItem ")+itos(CONTENT_MUD)+" 1";
126 setDirtLikeDiggingProperties(f->digging_properties, 1.0);
129 f = &content_features(i);
130 f->setAllTextures("mud.png");
131 f->setInventoryTextureCube("mud.png", "mud.png", "mud.png");
132 f->param_type = CPT_MINERAL;
133 f->is_ground_content = true;
134 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
135 setDirtLikeDiggingProperties(f->digging_properties, 1.0);
138 f = &content_features(i);
139 f->setAllTextures("sand.png");
140 f->setInventoryTextureCube("sand.png", "sand.png", "sand.png");
141 f->param_type = CPT_MINERAL;
142 f->is_ground_content = true;
143 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
144 setDirtLikeDiggingProperties(f->digging_properties, 1.0);
147 f = &content_features(i);
148 f->setAllTextures("gravel.png");
149 f->setInventoryTextureCube("gravel.png", "gravel.png", "gravel.png");
150 f->param_type = CPT_MINERAL;
151 f->is_ground_content = true;
152 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
153 setDirtLikeDiggingProperties(f->digging_properties, 1.75);
156 f = &content_features(i);
157 f->setAllTextures("tree.png");
158 f->setTexture(0, "tree_top.png");
159 f->setTexture(1, "tree_top.png");
160 f->param_type = CPT_MINERAL;
161 f->is_ground_content = true;
162 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
163 setWoodLikeDiggingProperties(f->digging_properties, 1.0);
166 f = &content_features(i);
167 f->light_propagates = true;
168 //f->param_type = CPT_MINERAL;
169 f->param_type = CPT_LIGHT;
170 f->is_ground_content = true;
173 f->solidness = 0; // drawn separately, makes no faces
174 f->setInventoryTextureCube("leaves.png", "leaves.png", "leaves.png");
178 f->setAllTextures("[noalpha:leaves.png");
180 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
181 setWoodLikeDiggingProperties(f->digging_properties, 0.15);
184 f = &content_features(i);
185 f->light_propagates = true;
186 f->param_type = CPT_LIGHT;
187 f->is_ground_content = true;
188 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
189 f->solidness = 0; // drawn separately, makes no faces
190 f->setInventoryTextureCube("glass.png", "glass.png", "glass.png");
191 setWoodLikeDiggingProperties(f->digging_properties, 0.15);
194 f = &content_features(i);
195 f->light_propagates = true;
196 f->param_type = CPT_LIGHT;
197 f->is_ground_content = true;
198 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
199 f->solidness = 0; // drawn separately, makes no faces
200 f->air_equivalent = true; // grass grows underneath
201 f->setInventoryTexture("item_fence.png");
202 setWoodLikeDiggingProperties(f->digging_properties, 0.75);
205 i = CONTENT_COALSTONE;
206 f = &content_features(i);
207 f->setAllTextures("stone.png^mineral_coal.png");
208 f->is_ground_content = true;
209 setStoneLikeDiggingProperties(f->digging_properties, 1.5);
212 f = &content_features(i);
213 f->setAllTextures("wood.png");
214 f->setInventoryTextureCube("wood.png", "wood.png", "wood.png");
215 f->is_ground_content = true;
216 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
217 setWoodLikeDiggingProperties(f->digging_properties, 0.75);
220 f = &content_features(i);
221 f->setAllTextures("mese.png");
222 f->setInventoryTextureCube("mese.png", "mese.png", "mese.png");
223 f->is_ground_content = true;
224 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
225 setStoneLikeDiggingProperties(f->digging_properties, 0.5);
228 f = &content_features(i);
229 f->setAllTextures("cloud.png");
230 f->setInventoryTextureCube("cloud.png", "cloud.png", "cloud.png");
231 f->is_ground_content = true;
232 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
235 f = &content_features(i);
236 f->param_type = CPT_LIGHT;
237 f->light_propagates = true;
238 f->sunlight_propagates = true;
241 f->pointable = false;
243 f->buildable_to = true;
244 f->air_equivalent = true;
247 f = &content_features(i);
248 f->setInventoryTextureCube("water.png", "water.png", "water.png");
249 f->param_type = CPT_LIGHT;
250 f->light_propagates = true;
251 f->solidness = 0; // Drawn separately, makes no faces
253 f->pointable = false;
255 f->buildable_to = true;
256 f->liquid_type = LIQUID_FLOWING;
257 f->liquid_alternative_flowing = CONTENT_WATER;
259 i = CONTENT_WATERSOURCE;
260 f = &content_features(i);
261 //f->setInventoryTexture("water.png");
262 f->setInventoryTextureCube("water.png", "water.png", "water.png");
265 f->solidness = 0; // drawn separately, makes no faces
273 t.texture = g_texturesource->getTexture("water.png");
275 t.alpha = WATER_ALPHA;
276 t.material_type = MATERIAL_ALPHA_VERTEX;
277 t.material_flags &= ~MATERIAL_FLAG_BACKFACE_CULLING;
280 f->param_type = CPT_LIGHT;
281 f->light_propagates = true;
283 f->pointable = false;
285 f->buildable_to = true;
286 f->liquid_type = LIQUID_SOURCE;
287 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
288 f->liquid_alternative_flowing = CONTENT_WATER;
291 f = &content_features(i);
292 f->setInventoryTexture("torch_on_floor.png");
293 f->param_type = CPT_LIGHT;
294 f->light_propagates = true;
295 f->sunlight_propagates = true;
296 f->solidness = 0; // drawn separately, makes no faces
298 f->wall_mounted = true;
299 f->air_equivalent = true;
300 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
301 f->light_source = LIGHT_MAX-1;
302 f->digging_properties.set("", DiggingProperties(true, 0.0, 0));
304 i = CONTENT_SIGN_WALL;
305 f = &content_features(i);
306 f->setInventoryTexture("sign_wall.png");
307 f->param_type = CPT_LIGHT;
308 f->light_propagates = true;
309 f->sunlight_propagates = true;
310 f->solidness = 0; // drawn separately, makes no faces
312 f->wall_mounted = true;
313 f->air_equivalent = true;
314 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
315 if(f->initial_metadata == NULL)
316 f->initial_metadata = new SignNodeMetadata("Some sign");
317 f->digging_properties.set("", DiggingProperties(true, 0.5, 0));
320 f = &content_features(i);
321 f->param_type = CPT_FACEDIR_SIMPLE;
322 f->setAllTextures("chest_side.png");
323 f->setTexture(0, "chest_top.png");
324 f->setTexture(1, "chest_top.png");
325 f->setTexture(5, "chest_front.png"); // Z-
326 f->setInventoryTexture("chest_top.png");
327 //f->setInventoryTextureCube("chest_top.png", "chest_side.png", "chest_side.png");
328 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
329 if(f->initial_metadata == NULL)
330 f->initial_metadata = new ChestNodeMetadata();
331 setWoodLikeDiggingProperties(f->digging_properties, 1.0);
334 f = &content_features(i);
335 f->param_type = CPT_FACEDIR_SIMPLE;
336 f->setAllTextures("furnace_side.png");
337 f->setTexture(5, "furnace_front.png"); // Z-
338 f->setInventoryTexture("furnace_front.png");
339 //f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
340 f->dug_item = std::string("MaterialItem ")+itos(CONTENT_COBBLE)+" 6";
341 if(f->initial_metadata == NULL)
342 f->initial_metadata = new FurnaceNodeMetadata();
343 setStoneLikeDiggingProperties(f->digging_properties, 3.0);
346 f = &content_features(i);
347 f->setAllTextures("cobble.png");
348 f->setInventoryTextureCube("cobble.png", "cobble.png", "cobble.png");
349 f->param_type = CPT_NONE;
350 f->is_ground_content = true;
351 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
352 setStoneLikeDiggingProperties(f->digging_properties, 0.9);
354 i = CONTENT_MOSSYCOBBLE;
355 f = &content_features(i);
356 f->setAllTextures("mossycobble.png");
357 f->setInventoryTextureCube("mossycobble.png", "mossycobble.png", "mossycobble.png");
358 f->param_type = CPT_NONE;
359 f->is_ground_content = true;
360 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
361 setStoneLikeDiggingProperties(f->digging_properties, 0.8);
364 f = &content_features(i);
365 f->setAllTextures("steel_block.png");
366 f->setInventoryTextureCube("steel_block.png", "steel_block.png",
368 f->param_type = CPT_NONE;
369 f->is_ground_content = true;
370 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
371 setStoneLikeDiggingProperties(f->digging_properties, 5.0);
373 // NOTE: Remember to add frequently used stuff to the texture atlas in tile.cpp
377 Add MesePick to everything
379 for(u16 i=0; i<256; i++)
381 content_features(i).digging_properties.set("MesePick",
382 DiggingProperties(true, 0.0, 65535./1337));
387 void setStoneLikeDiggingProperties(DiggingPropertiesList &list, float toughness)
390 DiggingProperties(true, 15.0*toughness, 0));
393 DiggingProperties(true, 1.3*toughness, 65535./30.*toughness));
395 DiggingProperties(true, 0.75*toughness, 65535./100.*toughness));
396 list.set("SteelPick",
397 DiggingProperties(true, 0.50*toughness, 65535./333.*toughness));
399 /*list.set("MesePick",
400 DiggingProperties(true, 0.0*toughness, 65535./20.*toughness));*/
403 void setDirtLikeDiggingProperties(DiggingPropertiesList &list, float toughness)
406 DiggingProperties(true, 0.75*toughness, 0));
409 DiggingProperties(true, 0.4*toughness, 65535./50.*toughness));
411 DiggingProperties(true, 0.2*toughness, 65535./150.*toughness));
412 list.set("SteelShovel",
413 DiggingProperties(true, 0.15*toughness, 65535./400.*toughness));
416 void setWoodLikeDiggingProperties(DiggingPropertiesList &list, float toughness)
419 DiggingProperties(true, 3.0*toughness, 0));
422 DiggingProperties(true, 1.5*toughness, 65535./30.*toughness));
424 DiggingProperties(true, 0.75*toughness, 65535./100.*toughness));
426 DiggingProperties(true, 0.5*toughness, 65535./333.*toughness));