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
4#include "Player.h"
5#include "net.minecraft.world.inventory.ContainerListener.h"
6using net_minecraft_world_inventory::ContainerListener;
7
8class Inventory;
9class Slot;
10class Item;
11class ItemInstance;
12class Container;
13
14class AbstractContainerMenu
15{
16public:
17 static const int SLOT_CLICKED_OUTSIDE = -999;
18
19 static const int CLICK_PICKUP = 0;
20 static const int CLICK_QUICK_MOVE = 1;
21 static const int CLICK_SWAP = 2;
22 static const int CLICK_CLONE = 3;
23 static const int CLICK_THROW = 4;
24 static const int CLICK_QUICK_CRAFT = 5;
25 static const int CLICK_PICKUP_ALL = 6;
26
27 static const int QUICKCRAFT_TYPE_CHARITABLE = 0;
28 static const int QUICKCRAFT_TYPE_GREEDY = 1;
29 static const int QUICKCRAFT_HEADER_START = 0;
30 static const int QUICKCRAFT_HEADER_CONTINUE = 1;
31 static const int QUICKCRAFT_HEADER_END = 2;
32
33 // 4J Stu - Added these to fix problem with items picked up while in the creative menu replacing slots in the creative menu
34 static const int CONTAINER_ID_CARRIED = -1;
35 static const int CONTAINER_ID_INVENTORY = 0;
36 static const int CONTAINER_ID_CREATIVE = -2;
37
38 vector<shared_ptr<ItemInstance> > lastSlots;
39 vector<Slot *> slots;
40 int containerId;
41
42private:
43 short changeUid;
44
45 int quickcraftType;
46 int quickcraftStatus;
47 unordered_set<Slot *> quickcraftSlots;
48
49private:
50 bool m_bNeedsRendered; // 4J added
51
52protected:
53 vector<ContainerListener *> containerListeners;
54
55 // 4J Stu - The java does not have ctor here (being an abstract) but we need one to initialise the member variables
56 // TODO Make sure all derived classes also call this
57 AbstractContainerMenu();
58
59 Slot *addSlot(Slot *slot);
60
61public:
62 virtual ~AbstractContainerMenu();
63 virtual void addSlotListener(ContainerListener *listener);
64 virtual void removeSlotListener(ContainerListener *listener);
65 virtual vector<shared_ptr<ItemInstance> > *getItems();
66 virtual void sendData(int id, int value);
67 virtual void broadcastChanges();
68 virtual bool needsRendered();
69 virtual bool clickMenuButton(shared_ptr<Player> player, int buttonId);
70 virtual Slot *getSlotFor(shared_ptr<Container> c, int index);
71 virtual Slot *getSlot(int index);
72 virtual shared_ptr<ItemInstance> quickMoveStack(shared_ptr<Player> player, int slotIndex);
73 virtual shared_ptr<ItemInstance> clicked(int slotIndex, int buttonNum, int clickType, shared_ptr<Player> player, bool looped = false); // 4J added looped param
74 virtual bool mayCombine(Slot *slot, shared_ptr<ItemInstance> item);
75 virtual bool canTakeItemForPickAll(shared_ptr<ItemInstance> carried, Slot *target);
76
77protected:
78 virtual void loopClick(int slotIndex, int buttonNum, bool quickKeyHeld, shared_ptr<Player> player);
79
80public:
81 virtual void removed(shared_ptr<Player> player);
82 virtual void slotsChanged();// 4J used to take a shared_ptr<Container> container but wasn't using it, so removed to simplify things
83 bool isPauseScreen();
84 void setItem(unsigned int slot, shared_ptr<ItemInstance> item);
85 void setAll(ItemInstanceArray *items);
86 virtual void setData(int id, int value);
87 short backup(shared_ptr<Inventory> inventory);
88
89private:
90 unordered_set<shared_ptr<Player> , PlayerKeyHash, PlayerKeyEq> unSynchedPlayers;
91
92public:
93 bool isSynched(shared_ptr<Player> player);
94 void setSynched(shared_ptr<Player> player, bool synched);
95 virtual bool stillValid(shared_ptr<Player> player) = 0;
96
97 // 4J Stu Added for UI
98 unsigned int getSize() { return (unsigned int)slots.size(); }
99
100
101protected:
102 // 4J Stu - Changes to return bool brought forward from 1.2
103 bool moveItemStackTo(shared_ptr<ItemInstance> itemStack, int startSlot, int endSlot, bool backwards);
104
105public:
106 virtual bool isOverrideResultClick(int slotNum, int buttonNum);
107
108 static int getQuickcraftType(int mask);
109 static int getQuickcraftHeader(int mask);
110 static int getQuickcraftMask(int header, int type);
111 static bool isValidQuickcraftType(int type);
112
113protected:
114 void resetQuickCraft();
115
116public:
117 static bool canItemQuickReplace(Slot *slot, shared_ptr<ItemInstance> item, bool ignoreSize);
118 static void getQuickCraftSlotCount(unordered_set<Slot *> *quickCraftSlots, int quickCraftingType, shared_ptr<ItemInstance> item, int carry);
119 bool canDragTo(Slot *slot);
120 static int getRedstoneSignalFromContainer(shared_ptr<Container> container);
121
122 // 4J Added
123 virtual bool isValidIngredient(shared_ptr<ItemInstance> item, int slotId);
124};