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_craft.h"
21 #include "inventory.h"
22 #include "content_mapnode.h"
24 #include "mapnode.h" // For content_t
27 void craft_set_creative_inventory(Player *player, IGameDef *gamedef)
29 INodeDefManager *ndef = gamedef->ndef();
31 player->resetInventory();
33 // Give some good tools
35 InventoryItem *item = new ToolItem(gamedef, "MesePick", 0);
36 void* r = player->inventory.addItem("main", item);
40 InventoryItem *item = new ToolItem(gamedef, "SteelPick", 0);
41 void* r = player->inventory.addItem("main", item);
45 InventoryItem *item = new ToolItem(gamedef, "SteelAxe", 0);
46 void* r = player->inventory.addItem("main", item);
50 InventoryItem *item = new ToolItem(gamedef, "SteelShovel", 0);
51 void* r = player->inventory.addItem("main", item);
59 // CONTENT_IGNORE-terminated list
60 content_t material_items[] = {
61 LEGN(ndef, "CONTENT_TORCH"),
62 LEGN(ndef, "CONTENT_COBBLE"),
63 LEGN(ndef, "CONTENT_MUD"),
64 LEGN(ndef, "CONTENT_STONE"),
65 LEGN(ndef, "CONTENT_SAND"),
66 LEGN(ndef, "CONTENT_SANDSTONE"),
67 LEGN(ndef, "CONTENT_CLAY"),
68 LEGN(ndef, "CONTENT_BRICK"),
69 LEGN(ndef, "CONTENT_TREE"),
70 LEGN(ndef, "CONTENT_LEAVES"),
71 LEGN(ndef, "CONTENT_CACTUS"),
72 LEGN(ndef, "CONTENT_PAPYRUS"),
73 LEGN(ndef, "CONTENT_BOOKSHELF"),
74 LEGN(ndef, "CONTENT_GLASS"),
75 LEGN(ndef, "CONTENT_FENCE"),
76 LEGN(ndef, "CONTENT_RAIL"),
77 LEGN(ndef, "CONTENT_MESE"),
78 LEGN(ndef, "CONTENT_WATERSOURCE"),
79 LEGN(ndef, "CONTENT_CLOUD"),
80 LEGN(ndef, "CONTENT_CHEST"),
81 LEGN(ndef, "CONTENT_FURNACE"),
82 LEGN(ndef, "CONTENT_SIGN_WALL"),
83 LEGN(ndef, "CONTENT_LAVASOURCE"),
87 content_t *mip = material_items;
88 for(u16 i=0; i<PLAYER_INVENTORY_SIZE; i++)
90 if(*mip == CONTENT_IGNORE)
93 InventoryItem *item = new MaterialItem(gamedef, *mip, 1);
94 player->inventory.addItem("main", item);
100 assert(USEFUL_LEGN(ndef, "CONTENT_COUNT") <= PLAYER_INVENTORY_SIZE);
103 InventoryItem *item = new MaterialItem(gamedef, LEGN(ndef, "CONTENT_TORCH"), 1);
104 player->inventory.addItem("main", item);
107 for(u16 i=0; i<USEFUL_LEGN(ndef, "CONTENT_COUNT"); i++)
109 // Skip some materials
110 if(i == LEGN(ndef, "CONTENT_WATER") || i == LEGN(ndef, "CONTENT_TORCH")
111 || i == LEGN(ndef, "CONTENT_COALSTONE"))
114 InventoryItem *item = new MaterialItem(gamedef, i, 1);
115 player->inventory.addItem("main", item);
121 InventoryItem *item = new MapBlockObjectItem(gamedef, "Sign Example text");
122 void* r = player->inventory.addItem("main", item);