- void add(u16 count)
- {
- m_count += count;
- }
- void remove(u16 count)
- {
- assert(m_count >= count);
- m_count -= count;
- }
-
- /*
- Other properties
- */
-
- // Maximum size of a stack
- virtual u16 getStackMax() const {return 1;}
- // Whether it can be used
- virtual bool isUsable() const {return false;}
- // Whether it can be cooked
- virtual bool isCookable() const {return false;}
- // Result of cooking (can randomize)
- virtual InventoryItem *createCookResult() const {return NULL;}
- // Time of cooking
- virtual float getCookTime() const {return 3.0;}
- // Whether it can be burned (<0 = cannot be burned)
- virtual float getBurnTime() const {return -1;}
- // Gets amount of items that dropping one ItemSAO will decrement
- // -1 means as many as possible
- virtual s16 getDropCount() const { return -1; }
- // Whether this item can point to liquids
- virtual bool areLiquidsPointable() const { return false; }
-
- // Creates an object from the item and places it in the world.
- // If return value is true, item should be removed.
- virtual bool dropOrPlace(ServerEnvironment *env,
- ServerActiveObject *dropper,
- v3f pos, bool place, s16 count);
-
- // Eat, press, activate, whatever.
- // Called when item is left-clicked while in hand.
- // If returns true, item shall be deleted.
- virtual bool use(ServerEnvironment *env,
- ServerActiveObject *user,
- const PointedThing& pointed){return false;}
-
-protected:
- IGameDef *m_gamedef;
- u16 m_count;
-};
-
-class MaterialItem : public InventoryItem
-{
-public:
- MaterialItem(IGameDef *gamedef, std::string nodename, u16 count);
- // Legacy constructor
- MaterialItem(IGameDef *gamedef, content_t content, u16 count);
- /*
- Implementation interface
- */
- virtual const char* getName() const