mirror of
https://github.com/celisej567/mcpe.git
synced 2026-01-05 18:10:09 +03:00
62 lines
1.4 KiB
C++
62 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <vector>
|
|
#include "world/item/ItemInstance.hpp"
|
|
#include "world/entity/Player.hpp"
|
|
|
|
class Entity;
|
|
class Player; // in case we're included from Player.hpp
|
|
|
|
#define C_MAX_HOTBAR_ITEMS (9)
|
|
#define C_NUM_SURVIVAL_SLOTS (36)
|
|
#define C_MAX_AMOUNT (64)
|
|
|
|
class Inventory
|
|
{
|
|
public:
|
|
Inventory(Player*);
|
|
void prepareCreativeInventory();
|
|
void prepareSurvivalInventory();
|
|
|
|
int getNumSlots();
|
|
int getNumItems();
|
|
|
|
void addCreativeItem(int itemID, int auxValue = 0);
|
|
void addTestItem(int itemID, int amount, int auxValue = 0);
|
|
|
|
void clear();
|
|
void addItem(ItemInstance* pInst);
|
|
|
|
ItemInstance* getItem(int slotNo);
|
|
ItemInstance* getQuickSlotItem(int slotNo);
|
|
ItemInstance* getSelectedItem();
|
|
int getQuickSlotItemId(int slotNo);
|
|
int getSelectedItemId();
|
|
void selectItem(int slotNo, int maxHotBarSlot); // selects an item by slot number and puts it in the quick slots if needed
|
|
void selectSlot(int slotNo);
|
|
|
|
void setQuickSlotIndexByItemId(int slotNo, int itemID);
|
|
void selectItemById(int itemID, int maxHotBarSlot);
|
|
|
|
int getAttackDamage(Entity*);
|
|
|
|
int getSelectedSlotNo() const
|
|
{
|
|
return m_selectedHotbarSlot;
|
|
}
|
|
|
|
// v0.2.0 name alias
|
|
ItemInstance* getSelected() {
|
|
return getSelectedItem();
|
|
}
|
|
|
|
public:
|
|
int m_selectedHotbarSlot;
|
|
private:
|
|
Player* m_pPlayer;
|
|
bool m_bIsSurvival;
|
|
|
|
int m_hotbar[C_MAX_HOTBAR_ITEMS];
|
|
std::vector<ItemInstance> m_items;
|
|
};
|