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");
41 ContentFeatures *f = NULL;
44 f = &content_features(i);
45 f->setAllTextures("stone.png");
46 f->setInventoryTextureCube("stone.png", "stone.png", "stone.png");
47 f->param_type = CPT_MINERAL;
48 f->is_ground_content = true;
49 f->dug_item = std::string("MaterialItem ")+itos(CONTENT_COBBLE)+" 1";
50 setStoneLikeDiggingProperties(f->digging_properties, 1.0);
53 f = &content_features(i);
54 f->setAllTextures("mud.png^grass_side.png");
55 f->setTexture(0, "grass.png");
56 f->setTexture(1, "mud.png");
57 f->param_type = CPT_MINERAL;
58 f->is_ground_content = true;
59 f->dug_item = std::string("MaterialItem ")+itos(CONTENT_MUD)+" 1";
60 setDirtLikeDiggingProperties(f->digging_properties, 1.0);
62 i = CONTENT_GRASS_FOOTSTEPS;
63 f = &content_features(i);
64 f->setAllTextures("mud.png^grass_side.png");
65 f->setTexture(0, "grass_footsteps.png");
66 f->setTexture(1, "mud.png");
67 f->param_type = CPT_MINERAL;
68 f->is_ground_content = true;
69 f->dug_item = std::string("MaterialItem ")+itos(CONTENT_MUD)+" 1";
70 setDirtLikeDiggingProperties(f->digging_properties, 1.0);
73 f = &content_features(i);
74 f->setAllTextures("mud.png");
75 f->setInventoryTextureCube("mud.png", "mud.png", "mud.png");
76 f->param_type = CPT_MINERAL;
77 f->is_ground_content = true;
78 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
79 setDirtLikeDiggingProperties(f->digging_properties, 1.0);
82 f = &content_features(i);
83 f->setAllTextures("sand.png");
84 f->param_type = CPT_MINERAL;
85 f->is_ground_content = true;
86 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
87 setDirtLikeDiggingProperties(f->digging_properties, 1.0);
90 f = &content_features(i);
91 f->setAllTextures("tree.png");
92 f->setTexture(0, "tree_top.png");
93 f->setTexture(1, "tree_top.png");
94 f->param_type = CPT_MINERAL;
95 f->is_ground_content = true;
96 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
97 setWoodLikeDiggingProperties(f->digging_properties, 1.0);
100 f = &content_features(i);
101 f->light_propagates = true;
102 //f->param_type = CPT_MINERAL;
103 f->param_type = CPT_LIGHT;
104 f->is_ground_content = true;
107 f->solidness = 0; // drawn separately, makes no faces
108 f->setInventoryTextureCube("leaves.png", "leaves.png", "leaves.png");
112 f->setAllTextures("[noalpha:leaves.png");
114 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
115 setWoodLikeDiggingProperties(f->digging_properties, 0.15);
118 f = &content_features(i);
119 f->light_propagates = true;
120 f->param_type = CPT_LIGHT;
121 f->is_ground_content = true;
122 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
123 f->solidness = 0; // drawn separately, makes no faces
124 f->setInventoryTextureCube("glass.png", "glass.png", "glass.png");
125 setWoodLikeDiggingProperties(f->digging_properties, 0.15);
128 f = &content_features(i);
129 f->light_propagates = true;
130 f->param_type = CPT_LIGHT;
131 f->is_ground_content = true;
132 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
133 f->solidness = 0; // drawn separately, makes no faces
134 f->air_equivalent = true; // grass grows underneath
135 f->setInventoryTexture("item_fence.png");
136 setWoodLikeDiggingProperties(f->digging_properties, 0.75);
139 i = CONTENT_COALSTONE;
140 f = &content_features(i);
141 //f->translate_to = new MapNode(CONTENT_STONE, MINERAL_COAL);
142 f->setAllTextures("stone.png^mineral_coal.png");
143 f->is_ground_content = true;
144 setStoneLikeDiggingProperties(f->digging_properties, 1.5);
147 f = &content_features(i);
148 f->setAllTextures("wood.png");
149 f->is_ground_content = true;
150 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
151 setWoodLikeDiggingProperties(f->digging_properties, 0.75);
154 f = &content_features(i);
155 f->setAllTextures("mese.png");
156 f->is_ground_content = true;
157 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
158 setStoneLikeDiggingProperties(f->digging_properties, 0.5);
161 f = &content_features(i);
162 f->setAllTextures("cloud.png");
163 f->is_ground_content = true;
164 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
167 f = &content_features(i);
168 f->param_type = CPT_LIGHT;
169 f->light_propagates = true;
170 f->sunlight_propagates = true;
173 f->pointable = false;
175 f->buildable_to = true;
176 f->air_equivalent = true;
179 f = &content_features(i);
180 f->setInventoryTextureCube("water.png", "water.png", "water.png");
181 f->param_type = CPT_LIGHT;
182 f->light_propagates = true;
183 f->solidness = 0; // Drawn separately, makes no faces
185 f->pointable = false;
187 f->buildable_to = true;
188 f->liquid_type = LIQUID_FLOWING;
189 f->liquid_alternative_flowing = CONTENT_WATER;
191 i = CONTENT_WATERSOURCE;
192 f = &content_features(i);
193 f->setInventoryTexture("water.png");
196 f->solidness = 0; // drawn separately, makes no faces
204 t.texture = g_texturesource->getTexture("water.png");
206 t.alpha = WATER_ALPHA;
207 t.material_type = MATERIAL_ALPHA_VERTEX;
208 t.material_flags &= ~MATERIAL_FLAG_BACKFACE_CULLING;
211 f->param_type = CPT_LIGHT;
212 f->light_propagates = true;
214 f->pointable = false;
216 f->buildable_to = true;
217 f->liquid_type = LIQUID_SOURCE;
218 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
219 f->liquid_alternative_flowing = CONTENT_WATER;
222 f = &content_features(i);
223 f->setInventoryTexture("torch_on_floor.png");
224 f->param_type = CPT_LIGHT;
225 f->light_propagates = true;
226 f->sunlight_propagates = true;
227 f->solidness = 0; // drawn separately, makes no faces
229 f->wall_mounted = true;
230 f->air_equivalent = true;
231 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
232 f->light_source = LIGHT_MAX;
233 f->digging_properties.set("", DiggingProperties(true, 0.0, 0));
235 i = CONTENT_SIGN_WALL;
236 f = &content_features(i);
237 f->setInventoryTexture("sign_wall.png");
238 f->param_type = CPT_LIGHT;
239 f->light_propagates = true;
240 f->sunlight_propagates = true;
241 f->solidness = 0; // drawn separately, makes no faces
243 f->wall_mounted = true;
244 f->air_equivalent = true;
245 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
246 if(f->initial_metadata == NULL)
247 f->initial_metadata = new SignNodeMetadata("Some sign");
248 f->digging_properties.set("", DiggingProperties(true, 0.5, 0));
251 f = &content_features(i);
252 f->param_type = CPT_FACEDIR_SIMPLE;
253 f->setAllTextures("chest_side.png");
254 f->setTexture(0, "chest_top.png");
255 f->setTexture(1, "chest_top.png");
256 f->setTexture(5, "chest_front.png"); // Z-
257 f->setInventoryTexture("chest_top.png");
258 //f->setInventoryTextureCube("chest_top.png", "chest_side.png", "chest_side.png");
259 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
260 if(f->initial_metadata == NULL)
261 f->initial_metadata = new ChestNodeMetadata();
262 setWoodLikeDiggingProperties(f->digging_properties, 1.0);
265 f = &content_features(i);
266 f->param_type = CPT_FACEDIR_SIMPLE;
267 f->setAllTextures("furnace_side.png");
268 f->setTexture(5, "furnace_front.png"); // Z-
269 f->setInventoryTexture("furnace_front.png");
270 //f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
271 f->dug_item = std::string("MaterialItem ")+itos(CONTENT_COBBLE)+" 6";
272 if(f->initial_metadata == NULL)
273 f->initial_metadata = new FurnaceNodeMetadata();
274 setStoneLikeDiggingProperties(f->digging_properties, 3.0);
277 f = &content_features(i);
278 f->setAllTextures("cobble.png");
279 f->setInventoryTextureCube("cobble.png", "cobble.png", "cobble.png");
280 f->param_type = CPT_NONE;
281 f->is_ground_content = true;
282 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
283 setStoneLikeDiggingProperties(f->digging_properties, 1.0);
286 f = &content_features(i);
287 f->setAllTextures("steel_block.png");
288 f->setInventoryTextureCube("steel_block.png", "steel_block.png",
290 f->param_type = CPT_NONE;
291 f->is_ground_content = true;
292 f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
293 setStoneLikeDiggingProperties(f->digging_properties, 5.0);
295 // NOTE: Remember to add frequently used stuff to the texture atlas in tile.cpp
299 Add MesePick to everything
301 for(u16 i=0; i<256; i++)
303 content_features(i).digging_properties.set("MesePick",
304 DiggingProperties(true, 0.0, 65535./1337));
309 void setStoneLikeDiggingProperties(DiggingPropertiesList &list, float toughness)
312 DiggingProperties(true, 15.0*toughness, 0));
315 DiggingProperties(true, 1.3*toughness, 65535./30.*toughness));
317 DiggingProperties(true, 0.75*toughness, 65535./100.*toughness));
318 list.set("SteelPick",
319 DiggingProperties(true, 0.50*toughness, 65535./333.*toughness));
321 /*list.set("MesePick",
322 DiggingProperties(true, 0.0*toughness, 65535./20.*toughness));*/
325 void setDirtLikeDiggingProperties(DiggingPropertiesList &list, float toughness)
328 DiggingProperties(true, 0.75*toughness, 0));
331 DiggingProperties(true, 0.4*toughness, 65535./50.*toughness));
333 DiggingProperties(true, 0.2*toughness, 65535./150.*toughness));
334 list.set("SteelShovel",
335 DiggingProperties(true, 0.15*toughness, 65535./400.*toughness));
338 void setWoodLikeDiggingProperties(DiggingPropertiesList &list, float toughness)
341 DiggingProperties(true, 3.0*toughness, 0));
344 DiggingProperties(true, 1.5*toughness, 65535./30.*toughness));
346 DiggingProperties(true, 0.75*toughness, 65535./100.*toughness));
348 DiggingProperties(true, 0.5*toughness, 65535./333.*toughness));