3 Copyright (C) 2010 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.
28 ContentFeatures::~ContentFeatures()
34 struct ContentFeatures g_content_features[256];
36 ContentFeatures & content_features(u8 i)
38 return g_content_features[i];
41 void init_mapnode(IIrrlichtWrapper *irrlicht)
44 ContentFeatures *f = NULL;
47 f = &g_content_features[i];
48 f->setAllTextures(irrlicht->getTextureId("stone.png"));
49 f->param_type = CPT_MINERAL;
50 f->is_ground_content = true;
53 f = &g_content_features[i];
54 f->setAllTextures(TextureSpec(irrlicht->getTextureId("mud.png"),
55 irrlicht->getTextureId("grass_side.png")));
56 f->setTexture(0, irrlicht->getTextureId("grass.png"));
57 f->setTexture(1, irrlicht->getTextureId("mud.png"));
58 f->setInventoryTexture(irrlicht->getTextureId("grass.png"));
59 f->param_type = CPT_MINERAL;
60 f->is_ground_content = true;
62 i = CONTENT_GRASS_FOOTSTEPS;
63 f = &g_content_features[i];
64 f->setAllTextures(TextureSpec(irrlicht->getTextureId("mud.png"),
65 irrlicht->getTextureId("grass_side.png")));
66 f->setTexture(0, irrlicht->getTextureId("grass_footsteps.png"));
67 f->setTexture(1, irrlicht->getTextureId("mud.png"));
68 f->setInventoryTexture(irrlicht->getTextureId("grass_footsteps.png"));
69 f->param_type = CPT_MINERAL;
70 f->is_ground_content = true;
73 f = &g_content_features[i];
74 f->setAllTextures(irrlicht->getTextureId("mud.png"));
75 f->param_type = CPT_MINERAL;
76 f->is_ground_content = true;
79 f = &g_content_features[i];
80 f->setAllTextures(irrlicht->getTextureId("sand.png"));
81 f->param_type = CPT_MINERAL;
82 f->is_ground_content = true;
85 f = &g_content_features[i];
86 f->setAllTextures(irrlicht->getTextureId("tree.png"));
87 f->setTexture(0, irrlicht->getTextureId("tree_top.png"));
88 f->setTexture(1, irrlicht->getTextureId("tree_top.png"));
89 f->setInventoryTexture(irrlicht->getTextureId("tree_top.png"));
90 f->param_type = CPT_MINERAL;
91 f->is_ground_content = true;
94 f = &g_content_features[i];
95 f->setAllTextures(irrlicht->getTextureId("leaves.png"));
96 f->param_type = CPT_MINERAL;
97 f->is_ground_content = true;
99 i = CONTENT_COALSTONE;
100 f = &g_content_features[i];
101 //f->translate_to = new MapNode(CONTENT_STONE, MINERAL_COAL);
102 f->setAllTextures(TextureSpec(irrlicht->getTextureId("coal.png"),
103 irrlicht->getTextureId("mineral_coal.png")));
104 f->is_ground_content = true;
107 f = &g_content_features[i];
108 f->setAllTextures(irrlicht->getTextureId("wood.png"));
109 f->is_ground_content = true;
112 f = &g_content_features[i];
113 f->setAllTextures(irrlicht->getTextureId("mese.png"));
114 f->is_ground_content = true;
117 f = &g_content_features[i];
118 f->setAllTextures(irrlicht->getTextureId("cloud.png"));
119 f->is_ground_content = true;
122 f = &g_content_features[i];
123 f->param_type = CPT_LIGHT;
124 f->light_propagates = true;
125 f->sunlight_propagates = true;
128 f->pointable = false;
130 f->buildable_to = true;
133 f = &g_content_features[i];
134 f->setInventoryTexture(irrlicht->getTextureId("water.png"));
135 f->param_type = CPT_LIGHT;
136 f->light_propagates = true;
137 f->solidness = 0; // Drawn separately, makes no faces
139 f->pointable = false;
141 f->buildable_to = true;
142 f->liquid_type = LIQUID_FLOWING;
144 bool new_style_water = g_settings.getBool("new_style_water");
146 i = CONTENT_WATERSOURCE;
147 f = &g_content_features[i];
148 //f->setTexture(0, irrlicht->getTextureId("water.png"), WATER_ALPHA);
149 if(new_style_water == false)
150 f->setAllTextures(irrlicht->getTextureId("water.png"), WATER_ALPHA);
151 f->setInventoryTexture(irrlicht->getTextureId("water.png"));
152 f->param_type = CPT_LIGHT;
153 f->light_propagates = true;
156 f->pointable = false;
158 f->buildable_to = true;
159 f->liquid_type = LIQUID_SOURCE;
162 f = &g_content_features[i];
163 f->setInventoryTexture(irrlicht->getTextureId("torch_on_floor.png"));
164 f->param_type = CPT_LIGHT;
165 f->light_propagates = true;
166 f->solidness = 0; // drawn separately, makes no faces
168 f->wall_mounted = true;
172 TileSpec MapNode::getTile(v3s16 dir)
178 if(dir == v3s16(0,0,0))
180 else if(dir == v3s16(0,1,0))
182 else if(dir == v3s16(0,-1,0))
184 else if(dir == v3s16(1,0,0))
186 else if(dir == v3s16(-1,0,0))
188 else if(dir == v3s16(0,0,1))
190 else if(dir == v3s16(0,0,-1))
195 spec = content_features(d).tiles[0];
197 spec = content_features(d).tiles[dir_i];
199 if(content_features(d).param_type == CPT_MINERAL)
201 u8 mineral = param & 0x1f;
202 // Add mineral block texture
203 textureid_t tid = mineral_block_texture(mineral);
205 spec.spec.addTid(tid);
211 u8 MapNode::getMineral()
213 if(content_features(d).param_type == CPT_MINERAL)
221 // Pointers to c_str()s g_content_features[i].inventory_image_path
222 //const char * g_content_inventory_texture_paths[USEFUL_CONTENT_COUNT] = {0};
224 void init_content_inventory_texture_paths()
226 dstream<<"DEPRECATED "<<__FUNCTION_NAME<<std::endl;
227 /*for(u16 i=0; i<USEFUL_CONTENT_COUNT; i++)
229 g_content_inventory_texture_paths[i] =
230 g_content_features[i].inventory_image_path.c_str();