summaryrefslogtreecommitdiff
path: root/src/inventory.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-07-30 18:51:15 +0300
committerPerttu Ahola <celeron55@gmail.com>2011-07-30 18:51:15 +0300
commitd62ae0e18bc570033ada07454b1642f696fe17b1 (patch)
tree69564fe33c88a90e74ccf0da356e9664ecc32817 /src/inventory.cpp
parent4556c212dba726271352b05a9299564e05abb218 (diff)
downloadminetest-d62ae0e18bc570033ada07454b1642f696fe17b1.tar.gz
minetest-d62ae0e18bc570033ada07454b1642f696fe17b1.tar.bz2
minetest-d62ae0e18bc570033ada07454b1642f696fe17b1.zip
Rats are now eatable. Also made their selection box move smoothly.
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r--src/inventory.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 7ef7f0138..ca050614f 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -31,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content_mapnode.h"
#include "content_inventory.h"
#include "content_sao.h"
+#include "player.h"
/*
InventoryItem
@@ -168,6 +169,20 @@ InventoryItem *CraftItem::createCookResult()
return item_craft_create_cook_result(m_subname);
}
+bool CraftItem::use(ServerEnvironment *env, Player *player)
+{
+ if(item_craft_is_eatable(m_subname))
+ {
+ s16 hp_change = item_craft_eat_hp_change(m_subname);
+ if(player->hp + hp_change > 20)
+ player->hp = 20;
+ else
+ player->hp += hp_change;
+ return true;
+ }
+ return false;
+}
+
/*
MapBlockObjectItem DEPRECATED
TODO: Remove