summaryrefslogtreecommitdiffstats
path: root/source/ClientHandle.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-07-29 09:57:34 +0200
committermadmaxoft <github@xoft.cz>2013-07-29 09:57:34 +0200
commit5530178aad3fa1a3061962d47d77b627ab5ceae3 (patch)
tree61ee7896061b4ef92877c120d9f5e917a6c5c924 /source/ClientHandle.cpp
parentMerge pull request #15 from mc-server/webadmin (diff)
parentUpdated the automatic Lua bindings (diff)
downloadcuberite-5530178aad3fa1a3061962d47d77b627ab5ceae3.tar
cuberite-5530178aad3fa1a3061962d47d77b627ab5ceae3.tar.gz
cuberite-5530178aad3fa1a3061962d47d77b627ab5ceae3.tar.bz2
cuberite-5530178aad3fa1a3061962d47d77b627ab5ceae3.tar.lz
cuberite-5530178aad3fa1a3061962d47d77b627ab5ceae3.tar.xz
cuberite-5530178aad3fa1a3061962d47d77b627ab5ceae3.tar.zst
cuberite-5530178aad3fa1a3061962d47d77b627ab5ceae3.zip
Diffstat (limited to 'source/ClientHandle.cpp')
-rw-r--r--source/ClientHandle.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp
index 155eac38a..d66e47d32 100644
--- a/source/ClientHandle.cpp
+++ b/source/ClientHandle.cpp
@@ -555,11 +555,8 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, ch
cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem());
if (ItemHandler->IsFood())
{
- if (PlgMgr->CallHookPlayerEating(*m_Player))
- {
- // A plugin doesn't agree with the action. The plugin itself is responsible for handling the consequences (possible inventory mismatch)
- return;
- }
+ m_Player->AbortEating();
+ return;
}
else
{
@@ -569,7 +566,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, ch
return;
}
}
- LOGINFO("%s: Status SHOOT / EAT not implemented", __FUNCTION__);
+ LOGINFO("%s: Status SHOOT not implemented", __FUNCTION__);
return;
}
@@ -804,15 +801,19 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, c
}
else if (ItemHandler->IsFood())
{
- cItem Item;
- Item.m_ItemType = Equipped.m_ItemType;
- Item.m_ItemCount = 1;
- if (ItemHandler->EatItem(m_Player, &Item))
+ if (m_Player->IsSatiated())
{
- ItemHandler->OnFoodEaten(World, m_Player, &Item);
- m_Player->GetInventory().RemoveOneEquippedItem();
+ // The player is satiated, they cannot eat
return;
}
+ m_Player->StartEating();
+ if (PlgMgr->CallHookPlayerEating(*m_Player))
+ {
+ // A plugin won't let us eat, abort (send the proper packets to the client, too):
+ m_Player->AbortEating();
+ return;
+ }
+ return;
}
else
{