summaryrefslogtreecommitdiffstats
path: root/source/cPlayer.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-05-29 21:56:07 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-05-29 21:56:07 +0200
commit322ba59c3a0500226e1b934c3390cffe4360ddb4 (patch)
tree0f5d1917a78bc71f03de16f31bad4b0d58a22cf5 /source/cPlayer.cpp
parentAdded code for the chunks to manipulate their neighbors while ticking. Also added some basic farming support - melon and pumpkin growing code. Untested and untestable so far, will test and fix later. (diff)
downloadcuberite-322ba59c3a0500226e1b934c3390cffe4360ddb4.tar
cuberite-322ba59c3a0500226e1b934c3390cffe4360ddb4.tar.gz
cuberite-322ba59c3a0500226e1b934c3390cffe4360ddb4.tar.bz2
cuberite-322ba59c3a0500226e1b934c3390cffe4360ddb4.tar.lz
cuberite-322ba59c3a0500226e1b934c3390cffe4360ddb4.tar.xz
cuberite-322ba59c3a0500226e1b934c3390cffe4360ddb4.tar.zst
cuberite-322ba59c3a0500226e1b934c3390cffe4360ddb4.zip
Diffstat (limited to 'source/cPlayer.cpp')
-rw-r--r--source/cPlayer.cpp72
1 files changed, 63 insertions, 9 deletions
diff --git a/source/cPlayer.cpp b/source/cPlayer.cpp
index 87db2d19d..9cfe4d644 100644
--- a/source/cPlayer.cpp
+++ b/source/cPlayer.cpp
@@ -305,20 +305,31 @@ void cPlayer::Heal( int a_Health )
}
}
-void cPlayer::Feed( short a_Food )
+
+
+
+
+bool cPlayer::Feed(short a_Food)
{
- if( m_FoodLevel < GetMaxFoodLevel() )
+ if (m_FoodLevel >= GetMaxFoodLevel())
{
- m_FoodLevel = MIN(a_Food + m_FoodLevel, GetMaxFoodLevel());
-
- cPacket_UpdateHealth Health;
- Health.m_Health = m_Health;
- Health.m_Food = GetFood();
- Health.m_Saturation = GetFoodSaturation();
- m_ClientHandle->Send( Health );
+ return false;
}
+
+ m_FoodLevel = MIN(a_Food + m_FoodLevel, GetMaxFoodLevel());
+
+ cPacket_UpdateHealth Health;
+ Health.m_Health = m_Health;
+ Health.m_Food = GetFood();
+ Health.m_Saturation = GetFoodSaturation();
+ m_ClientHandle->Send( Health );
+ return true;
}
+
+
+
+
void cPlayer::TakeDamage( int a_Damage, cEntity* a_Instigator )
{
if ( !(m_GameMode == 1) ) {
@@ -985,3 +996,46 @@ void cPlayer::UseEquippedItem()
+
+bool cPlayer::EatItem(int a_ItemType)
+{
+ // TODO: Handle hunger
+ switch (a_ItemType)
+ {
+ case E_ITEM_APPLE: return Feed(24); // 2 food bars
+ case E_ITEM_GOLDEN_APPLE: return Feed(60); // 5 food
+ case E_ITEM_MUSHROOM_SOUP: return Feed(48); // 4 food
+ case E_ITEM_BREAD: return Feed(30); // 2.5 food
+ case E_ITEM_RAW_MEAT: return Feed(18); // 1.5 food
+ case E_ITEM_COOKED_MEAT: return Feed(48); // 4 food
+ case E_ITEM_RAW_FISH: return Feed(12); // 1 food
+ case E_ITEM_COOKED_FISH: return Feed(30); // 2.5 food
+ case E_ITEM_COOKED_CHICKEN: return Feed(36); // 3 food
+ case E_ITEM_RAW_BEEF: return Feed(18); // 1.5 food
+ case E_ITEM_STEAK: return Feed(48); // 4 food
+ case E_ITEM_RAW_CHICKEN:
+ {
+ if (!Feed(12)) // 1 food
+ {
+ return false;
+ }
+ // TODO: A random chance to get food-poisoned
+ return true;
+ }
+
+ case E_ITEM_ROTTEN_FLESH:
+ {
+ if (!Feed(24))
+ {
+ return false;
+ }
+ // TODO: Food-poisoning
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+