summaryrefslogtreecommitdiffstats
path: root/source/Inventory.h
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-19 20:22:37 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-19 20:22:37 +0200
commit90c398a3926f097e51955817e2829d831ae2bd2b (patch)
treeaf4e2d236a5e0595f19975dcd2295c60c4a59712 /source/Inventory.h
parentDebuggers: sorted things into separate functions, commented out most of them; added ForEachEntity() testing - list all and kill all entities. (diff)
downloadcuberite-90c398a3926f097e51955817e2829d831ae2bd2b.tar
cuberite-90c398a3926f097e51955817e2829d831ae2bd2b.tar.gz
cuberite-90c398a3926f097e51955817e2829d831ae2bd2b.tar.bz2
cuberite-90c398a3926f097e51955817e2829d831ae2bd2b.tar.lz
cuberite-90c398a3926f097e51955817e2829d831ae2bd2b.tar.xz
cuberite-90c398a3926f097e51955817e2829d831ae2bd2b.tar.zst
cuberite-90c398a3926f097e51955817e2829d831ae2bd2b.zip
Diffstat (limited to 'source/Inventory.h')
-rw-r--r--source/Inventory.h33
1 files changed, 22 insertions, 11 deletions
diff --git a/source/Inventory.h b/source/Inventory.h
index 82ecb97f9..af4beb699 100644
--- a/source/Inventory.h
+++ b/source/Inventory.h
@@ -27,8 +27,8 @@ public:
void Clear(); // tolua_export
- cItem* GetSlotsForType( int a_Type );
- int GetSlotCountForType( int a_Type );
+ // cItem * GetSlotsForType( int a_Type );
+ // int GetSlotCountForType( int a_Type );
bool AddItem( cItem & a_Item ); // tolua_export
bool AddItemAnyAmount( cItem & a_Item ); // tolua_export
@@ -39,21 +39,30 @@ public:
void SendWholeInventory(cClientHandle & a_Client);
- cItem * GetSlot(int a_SlotNum ); // tolua_export
- cItem * GetSlots(void) { return m_Slots; }
const cItem * GetSlots(void) const { return m_Slots; }
- cItem * GetFromHotBar(int a_HotBarSlotNum); // tolua_export
- cItem & GetEquippedItem(void); // tolua_export
+ // tolua_begin
+
+ const cItem & GetSlot(int a_SlotNum) const;
+ const cItem & GetHotBarSlot(int a_HotBarSlotNum) const;
const cItem & GetEquippedItem(void) const;
- void SetEquippedSlot(int a_SlotNum); // tolua_export
- short GetEquippedSlot(void) { return m_EquippedSlot; } // tolua_export
+ void SetSlot(int a_SlotNum, const cItem & a_Item);
+ void SetHotBarSlot(int a_HotBarSlotNum, const cItem & a_Item);
+
+ void SetEquippedSlotNum(int a_SlotNum);
+ int GetEquippedSlotNum(void) { return m_EquippedSlotNum; }
+
+ /// Adds the specified damage to the specified item; deletes the item and returns true if the item broke.
+ bool cInventory::DamageItem(int a_SlotNum, short a_Amount);
+
+ /// Adds the specified damage to the currently held item; deletes the item and returns true if the item broke.
+ bool DamageEquippedItem(short a_Amount = 1);
- // tolua_begin
const cItem & GetEquippedHelmet (void) const { return m_Slots[c_ArmorOffset]; }
const cItem & GetEquippedChestplate(void) const { return m_Slots[c_ArmorOffset + 1]; }
const cItem & GetEquippedLeggings (void) const { return m_Slots[c_ArmorOffset + 2]; }
const cItem & GetEquippedBoots (void) const { return m_Slots[c_ArmorOffset + 3]; }
+
// tolua_end
void SendSlot( int a_SlotNum ); // tolua_export
@@ -74,6 +83,9 @@ public:
static const unsigned int c_ArmorOffset = 5;
static const unsigned int c_MainOffset = 9;
static const unsigned int c_HotOffset = 36;
+
+ /// Converts a slot number into the ID for the EntityEquipment packet
+ static int SlotNumToEntityEquipmentID(short a_SlotNum);
protected:
bool AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, bool* a_bChangedSlots, int a_Mode = 0 );
@@ -85,8 +97,7 @@ protected:
cItem * m_ArmorSlots;
cItem * m_HotSlots;
- cItem * m_EquippedItem;
- short m_EquippedSlot;
+ int m_EquippedSlotNum;
cPlayer & m_Owner;
}; // tolua_export