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.
20 #include "content_inventory.h"
21 #include "inventory.h"
22 #include "content_mapnode.h"
23 //#include "serverobject.h"
24 #include "content_sao.h"
26 bool item_material_is_cookable(content_t content)
28 if(content == CONTENT_TREE)
30 else if(content == CONTENT_COBBLE)
32 else if(content == CONTENT_SAND)
37 InventoryItem* item_material_create_cook_result(content_t content)
39 if(content == CONTENT_TREE)
40 return new CraftItem("lump_of_coal", 1);
41 else if(content == CONTENT_COBBLE)
42 return new MaterialItem(CONTENT_STONE, 1);
43 else if(content == CONTENT_SAND)
44 return new MaterialItem(CONTENT_GLASS, 1);
48 std::string item_craft_get_image_name(const std::string &subname)
50 if(subname == "Stick")
52 else if(subname == "paper")
54 else if(subname == "book")
56 else if(subname == "lump_of_coal")
57 return "lump_of_coal.png";
58 else if(subname == "lump_of_iron")
59 return "lump_of_iron.png";
60 else if(subname == "lump_of_clay")
61 return "lump_of_clay.png";
62 else if(subname == "steel_ingot")
63 return "steel_ingot.png";
64 else if(subname == "clay_brick")
65 return "clay_brick.png";
66 else if(subname == "rat")
68 else if(subname == "cooked_rat")
69 return "cooked_rat.png";
70 else if(subname == "scorched_stuff")
71 return "scorched_stuff.png";
72 else if(subname == "firefly")
74 else if(subname == "apple")
76 else if(subname == "apple_iron")
77 return "apple_iron.png";
79 return "cloud.png"; // just something
82 ServerActiveObject* item_craft_create_object(const std::string &subname,
83 ServerEnvironment *env, u16 id, v3f pos)
87 ServerActiveObject *obj = new RatSAO(env, id, pos);
90 else if(subname == "firefly")
92 ServerActiveObject *obj = new FireflySAO(env, id, pos);
99 s16 item_craft_get_drop_count(const std::string &subname)
101 if(subname == "rat" || subname == "firefly")
107 bool item_craft_is_cookable(const std::string &subname)
109 if(subname == "lump_of_iron" || subname == "lump_of_clay" || subname == "rat" || subname == "cooked_rat")
115 InventoryItem* item_craft_create_cook_result(const std::string &subname)
117 if(subname == "lump_of_iron")
118 return new CraftItem("steel_ingot", 1);
119 else if(subname == "lump_of_clay")
120 return new CraftItem("clay_brick", 1);
121 else if(subname == "rat")
122 return new CraftItem("cooked_rat", 1);
123 else if(subname == "cooked_rat")
124 return new CraftItem("scorched_stuff", 1);
129 bool item_craft_is_eatable(const std::string &subname)
131 if(subname == "cooked_rat")
133 else if(subname == "apple")
135 else if(subname == "apple_iron")
140 s16 item_craft_eat_hp_change(const std::string &subname)
142 if(subname == "cooked_rat")
143 return 6; // 3 hearts
144 else if(subname == "apple")
145 return 4; // 2 hearts
146 else if(subname == "apple_iron")
147 return 8; // 4 hearts