3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4 Copyright (C) 2013 Kahrl <kahrl@gmx.net>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #ifndef ITEMDEF_HEADER
22 #define ITEMDEF_HEADER
24 #include "irrlichttypes_extrabloated.h"
28 #include "itemgroup.h"
31 struct ToolCapabilities
;
51 std::string name
; // "" = hand
52 std::string description
; // Shown in tooltip.
57 std::string inventory_image
; // Optional for nodes, mandatory for tools/craftitems
58 std::string wield_image
; // If empty, inventory_image or mesh (only nodes) is used
62 Item stack and interaction properties
66 bool liquids_pointable
;
67 // May be NULL. If non-NULL, deleted by destructor
68 ToolCapabilities
*tool_capabilities
;
70 SimpleSoundSpec sound_place
;
73 // Client shall immediately place this node when player places the item.
74 // Server will update the precise end result a moment later.
76 std::string node_placement_prediction
;
82 ItemDefinition(const ItemDefinition
&def
);
83 ItemDefinition
& operator=(const ItemDefinition
&def
);
86 void serialize(std::ostream
&os
, u16 protocol_version
) const;
87 void deSerialize(std::istream
&is
);
96 virtual ~IItemDefManager(){}
98 // Get item definition
99 virtual const ItemDefinition
& get(const std::string
&name
) const=0;
100 // Get alias definition
101 virtual std::string
getAlias(const std::string
&name
) const=0;
102 // Get set of all defined item names and aliases
103 virtual std::set
<std::string
> getAll() const=0;
104 // Check if item is known
105 virtual bool isKnown(const std::string
&name
) const=0;
107 // Get item inventory texture
108 virtual video::ITexture
* getInventoryTexture(const std::string
&name
,
109 IGameDef
*gamedef
) const=0;
110 // Get item wield mesh
111 virtual scene::IMesh
* getWieldMesh(const std::string
&name
,
112 IGameDef
*gamedef
) const=0;
115 virtual void serialize(std::ostream
&os
, u16 protocol_version
)=0;
118 class IWritableItemDefManager
: public IItemDefManager
121 IWritableItemDefManager(){}
122 virtual ~IWritableItemDefManager(){}
124 // Get item definition
125 virtual const ItemDefinition
& get(const std::string
&name
) const=0;
126 // Get alias definition
127 virtual std::string
getAlias(const std::string
&name
) const=0;
128 // Get set of all defined item names and aliases
129 virtual std::set
<std::string
> getAll() const=0;
130 // Check if item is known
131 virtual bool isKnown(const std::string
&name
) const=0;
133 // Get item inventory texture
134 virtual video::ITexture
* getInventoryTexture(const std::string
&name
,
135 IGameDef
*gamedef
) const=0;
136 // Get item wield mesh
137 virtual scene::IMesh
* getWieldMesh(const std::string
&name
,
138 IGameDef
*gamedef
) const=0;
141 // Remove all registered item and node definitions and aliases
142 // Then re-add the builtin item definitions
143 virtual void clear()=0;
144 // Register item definition
145 virtual void registerItem(const ItemDefinition
&def
)=0;
146 // Set an alias so that items named <name> will load as <convert_to>.
147 // Alias is not set if <name> has already been defined.
148 // Alias will be removed if <name> is defined at a later point of time.
149 virtual void registerAlias(const std::string
&name
,
150 const std::string
&convert_to
)=0;
152 virtual void serialize(std::ostream
&os
, u16 protocol_version
)=0;
153 virtual void deSerialize(std::istream
&is
)=0;
155 // Do stuff asked by threads that can only be done in the main thread
156 virtual void processQueue(IGameDef
*gamedef
)=0;
159 IWritableItemDefManager
* createItemDefManager();