the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#pragma once
2using namespace std;
3#include "Container.h"
4#include "ListTag.h"
5#include "ItemInstance.h"
6
7class Player;
8class CompoundTag;
9
10class Inventory : public Container
11{
12public:
13 static const int POP_TIME_DURATION ;
14 static const int MAX_INVENTORY_STACK_SIZE;
15
16private:
17 static const int INVENTORY_SIZE;
18 static const int SELECTION_SIZE;
19
20public:
21 ItemInstanceArray items;
22 ItemInstanceArray armor;
23
24 int selected;
25 Player *player; // This is owned by shared_ptrs, but we are owned by it
26
27private:
28 shared_ptr<ItemInstance> heldItem;
29 shared_ptr<ItemInstance> carried;
30
31public:
32 bool changed;
33
34 Inventory(Player *player);
35 ~Inventory();
36
37 shared_ptr<ItemInstance> getSelected();
38 // 4J-PB - Added for the in-game tooltips
39 bool IsHeldItem();
40 static int getSelectionSize();
41
42private:
43 int getSlot(int tileId);
44 int getSlot(int tileId, int data);
45
46 int getSlotWithRemainingSpace(shared_ptr<ItemInstance> item);
47
48public:
49 int getFreeSlot();
50 void grabTexture(int id, int data, bool checkData, bool mayReplace);
51 void swapPaint(int wheel);
52 int clearInventory(int id, int data);
53 void replaceSlot(Item *item, int data);
54
55private:
56 int addResource(shared_ptr<ItemInstance> itemInstance);
57
58public:
59 void tick();
60 bool removeResource(int type);
61
62 // 4J-PB added to get the right resource from the inventory for removal
63 bool removeResource(int type,int iAuxVal);
64 void removeResources(shared_ptr<ItemInstance> item); // 4J Added for trading
65
66 // 4J-Stu added to the get the item that would be affected by the removeResource functions
67 shared_ptr<ItemInstance> getResourceItem(int type);
68 shared_ptr<ItemInstance> getResourceItem(int type,int iAuxVal);
69
70 bool hasResource(int type);
71 void swapSlots(int from, int to);
72 bool add(shared_ptr<ItemInstance> item);
73 shared_ptr<ItemInstance> removeItem(unsigned int slot, int count);
74 virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot);
75 void setItem(unsigned int slot, shared_ptr<ItemInstance> item);
76 float getDestroySpeed(Tile *tile);
77 ListTag<CompoundTag> *save(ListTag<CompoundTag> *listTag);
78 void load(ListTag<CompoundTag> *inventoryList);
79 unsigned int getContainerSize();
80 shared_ptr<ItemInstance> getItem(unsigned int slot);
81 wstring getName();
82 wstring getCustomName();
83 bool hasCustomName();
84 int getMaxStackSize() const;
85 bool canDestroy(Tile *tile);
86 shared_ptr<ItemInstance> getArmor(int layer);
87 int getArmorValue();
88 void hurtArmor(float dmg);
89 void dropAll();
90 void setChanged();
91 bool isSame(shared_ptr<Inventory> copy);
92
93private:
94 bool isSame(shared_ptr<ItemInstance> a, shared_ptr<ItemInstance> b);
95
96public:
97 shared_ptr<Inventory> copy();
98 void setCarried(shared_ptr<ItemInstance> carried);
99 shared_ptr<ItemInstance> getCarried();
100 bool stillValid(shared_ptr<Player> player);
101 bool contains(shared_ptr<ItemInstance> itemInstance);
102 virtual void startOpen();
103 virtual void stopOpen();
104 bool canPlaceItem(int slot, shared_ptr<ItemInstance> item);
105 void replaceWith(shared_ptr<Inventory> other);
106
107 int countMatches(shared_ptr<ItemInstance> itemInstance); // 4J Added
108};