summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarchshift <admin@archshift.com>2014-06-09 02:06:15 +0200
committerarchshift <admin@archshift.com>2014-06-17 20:39:20 +0200
commit3766ac96d77329c679d01d1ab1a846384acab42f (patch)
tree0c60ce53163377434dd7de63f1f456ba2475743b
parentSplash potion: Adjusted speed, fixed spawn position (diff)
downloadcuberite-3766ac96d77329c679d01d1ab1a846384acab42f.tar
cuberite-3766ac96d77329c679d01d1ab1a846384acab42f.tar.gz
cuberite-3766ac96d77329c679d01d1ab1a846384acab42f.tar.bz2
cuberite-3766ac96d77329c679d01d1ab1a846384acab42f.tar.lz
cuberite-3766ac96d77329c679d01d1ab1a846384acab42f.tar.xz
cuberite-3766ac96d77329c679d01d1ab1a846384acab42f.tar.zst
cuberite-3766ac96d77329c679d01d1ab1a846384acab42f.zip
-rw-r--r--src/ClientHandle.cpp7
-rw-r--r--src/Items/ItemHandler.cpp4
-rw-r--r--src/Items/ItemHandler.h4
-rw-r--r--src/Items/ItemMilk.h4
-rw-r--r--src/Items/ItemPotion.h13
5 files changed, 14 insertions, 18 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index ab36bff91..9443cf2c9 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -850,7 +850,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
case DIG_STATUS_SHOOT_EAT:
{
cItemHandler * ItemHandler = cItemHandler::GetItemHandler(m_Player->GetEquippedItem());
- if (ItemHandler->IsFood() || ItemHandler->IsDrinkable(&m_Player->GetEquippedItem()))
+ if (ItemHandler->IsFood() || ItemHandler->IsDrinkable(m_Player->GetEquippedItem().m_ItemDamage))
{
m_Player->AbortEating();
return;
@@ -1176,15 +1176,16 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
return;
}
+ short EquippedDamage = Equipped.m_ItemDamage;
cItemHandler * ItemHandler = cItemHandler::GetItemHandler(Equipped.m_ItemType);
if (ItemHandler->IsPlaceable() && (a_BlockFace != BLOCK_FACE_NONE))
{
HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler);
}
- else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable(&Equipped)) && !m_Player->IsGameModeCreative())
+ else if ((ItemHandler->IsFood() || ItemHandler->IsDrinkable(EquippedDamage)) && !m_Player->IsGameModeCreative())
{
- if (m_Player->IsSatiated() && !ItemHandler->IsDrinkable(&Equipped))
+ if (m_Player->IsSatiated() && !ItemHandler->IsDrinkable(EquippedDamage))
{
// The player is satiated, they cannot eat
return;
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index f847c8ffa..3d13af3a7 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -504,9 +504,9 @@ bool cItemHandler::IsFood(void)
-bool cItemHandler::IsDrinkable(const cItem * a_Item)
+bool cItemHandler::IsDrinkable(short a_ItemDamage)
{
- UNUSED(a_Item);
+ UNUSED(a_ItemDamage);
switch (m_ItemType)
{
diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h
index ead2c9769..cffca11ab 100644
--- a/src/Items/ItemHandler.h
+++ b/src/Items/ItemHandler.h
@@ -83,7 +83,7 @@ public:
virtual bool IsFood(void);
/** Indicates if this item is drinkable */
- virtual bool IsDrinkable(const cItem * a_Item);
+ virtual bool IsDrinkable(short a_ItemDamage);
/** Blocks simply get placed */
virtual bool IsPlaceable(void);
@@ -102,7 +102,7 @@ public:
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
);
- /** Returns whether this tool/item can harvest a specific block (e.g. wooden pickaxe can harvest stone, but wood can�t) DEFAULT: False */
+ /** Returns whether this tool/item can harvest a specific block (e.g. wooden pickaxe can harvest stone, but wood can't) DEFAULT: False */
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType);
static cItemHandler * GetItemHandler(int a_ItemType);
diff --git a/src/Items/ItemMilk.h b/src/Items/ItemMilk.h
index 62506a223..db7bc13be 100644
--- a/src/Items/ItemMilk.h
+++ b/src/Items/ItemMilk.h
@@ -11,9 +11,9 @@ public:
{
}
- virtual bool IsDrinkable(const cItem * a_Item) override
+ virtual bool IsDrinkable(short a_ItemDamage) override
{
- UNUSED(a_Item);
+ UNUSED(a_ItemDamage);
return true;
}
diff --git a/src/Items/ItemPotion.h b/src/Items/ItemPotion.h
index 029bb52cd..c2441fa48 100644
--- a/src/Items/ItemPotion.h
+++ b/src/Items/ItemPotion.h
@@ -104,22 +104,17 @@ class cItemPotionHandler:
return base * tier_multi * ext_multi * splash_multi;
}
- bool IsDrinkable(short a_ItemDamage)
- {
- // Drinkable potion if 13th bit is set
- // For reference: http://minecraft.gamepedia.com/Potions#Data_value_table
- return a_ItemDamage & 8192;
- }
-
public:
cItemPotionHandler():
super(E_ITEM_POTIONS)
{
}
- virtual bool IsDrinkable(const cItem * a_Item) override
+ virtual bool IsDrinkable(short a_ItemDamage) override
{
- return IsDrinkable(a_Item->m_ItemDamage);
+ // Drinkable potion if 13th bit is set
+ // For reference: http://minecraft.gamepedia.com/Potions#Data_value_table
+ return a_ItemDamage & 8192;
}
virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override