Merge branch 'master' of https://github.com/erlehmann/minetest-delta.git into upstrea...
[oweals/minetest.git] / src / content_inventory.cpp
1 /*
2 Minetest-c55
3 Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
4
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.
9
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.
14
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.
18 */
19
20 #include "content_inventory.h"
21 #include "inventory.h"
22 #include "serverobject.h"
23 #include "content_mapnode.h"
24
25 bool item_material_is_cookable(u8 content)
26 {
27         if(content == CONTENT_TREE)
28                 return true;
29         else if(content == CONTENT_COBBLE)
30                 return true;
31         else if(content == CONTENT_SAND)
32                 return true;
33         return false;
34 }
35
36 InventoryItem* item_material_create_cook_result(u8 content)
37 {
38         if(content == CONTENT_TREE)
39                 return new CraftItem("lump_of_coal", 1);
40         else if(content == CONTENT_COBBLE)
41                 return new MaterialItem(CONTENT_STONE, 1);
42         else if(content == CONTENT_SAND)
43                 return new MaterialItem(CONTENT_GLASS, 1);
44         return NULL;
45 }
46
47 std::string item_craft_get_image_name(const std::string &subname)
48 {
49         if(subname == "Stick")
50                 return "stick.png";
51         else if(subname == "paper")
52                 return "paper.png";
53         else if(subname == "book")
54                 return "book.png";
55         else if(subname == "lump_of_coal")
56                 return "lump_of_coal.png";
57         else if(subname == "lump_of_iron")
58                 return "lump_of_iron.png";
59         else if(subname == "lump_of_clay")
60                 return "lump_of_clay.png";
61         else if(subname == "steel_ingot")
62                 return "steel_ingot.png";
63         else if(subname == "clay_brick")
64                 return "clay_brick.png";
65         else if(subname == "rat")
66                 return "rat.png";
67         else
68                 return "cloud.png"; // just something
69 }
70
71 ServerActiveObject* item_craft_create_object(const std::string &subname,
72                 ServerEnvironment *env, u16 id, v3f pos)
73 {
74         if(subname == "rat")
75         {
76                 ServerActiveObject *obj = new RatSAO(env, id, pos);
77                 return obj;
78         }
79
80         return NULL;
81 }
82
83 s16 item_craft_get_drop_count(const std::string &subname)
84 {
85         if(subname == "rat")
86                 return 1;
87
88         return -1;
89 }
90
91 bool item_craft_is_cookable(const std::string &subname)
92 {
93         if(subname == "lump_of_iron" || subname == "lump_of_clay")
94                 return true;
95                 
96         return false;
97 }
98
99 InventoryItem* item_craft_create_cook_result(const std::string &subname)
100 {
101         if(subname == "lump_of_iron")
102                 return new CraftItem("steel_ingot", 1);
103         else if(subname == "lump_of_clay")
104                 return new CraftItem("clay_brick", 1);
105
106         return NULL;
107 }
108