the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "net.minecraft.world.entity.player.h"
3#include "net.minecraft.world.item.h"
4#include "AbstractContainerMenu.h"
5#include "CraftingContainer.h"
6
7CraftingContainer::~CraftingContainer()
8{
9
10}
11
12CraftingContainer::CraftingContainer(AbstractContainerMenu *menu, unsigned int w, unsigned int h)
13{
14 unsigned int size = w * h;
15 items = new ItemInstanceArray(size);
16 this->menu = menu;
17 this->width = w;
18}
19
20unsigned int CraftingContainer::getContainerSize()
21{
22 return items->length;
23}
24
25shared_ptr<ItemInstance> CraftingContainer::getItem(unsigned int slot)
26{
27 if (slot >= getContainerSize())
28 {
29 return nullptr;
30 }
31 return (*items)[slot];
32}
33
34shared_ptr<ItemInstance> CraftingContainer::getItem(unsigned int x, unsigned int y)
35{
36 if (x < 0 || x >= width)
37 {
38 return nullptr;
39 }
40 unsigned int pos = x + y * width;
41 return getItem(pos);
42}
43
44wstring CraftingContainer::getName()
45{
46 return L"";
47}
48
49wstring CraftingContainer::getCustomName()
50{
51 return L"";
52}
53
54bool CraftingContainer::hasCustomName()
55{
56 return false;
57}
58
59shared_ptr<ItemInstance> CraftingContainer::removeItemNoUpdate(int slot)
60{
61 if ((*items)[slot] != NULL)
62 {
63 shared_ptr<ItemInstance> item = (*items)[slot];
64 (*items)[slot] = nullptr;
65 return item;
66 }
67 return nullptr;
68}
69
70shared_ptr<ItemInstance> CraftingContainer::removeItem(unsigned int slot, int count)
71{
72 if ((*items)[slot] != NULL)
73 {
74 if ((*items)[slot]->count <= count)
75 {
76 shared_ptr<ItemInstance> item = (*items)[slot];
77 (*items)[slot] = nullptr;
78 menu->slotsChanged(); // 4J - used to take pointer to this, but wasn't using it so removed
79 return item;
80 }
81 else
82 {
83 shared_ptr<ItemInstance> i = (*items)[slot]->remove(count);
84 if ((*items)[slot]->count == 0) (*items)[slot] = nullptr;
85 menu->slotsChanged(); // 4J - used to take pointer to this, but wasn't using it so removed
86 return i;
87 }
88 }
89 return nullptr;
90}
91
92void CraftingContainer::setItem(unsigned int slot, shared_ptr<ItemInstance> item)
93{
94 (*items)[slot] = item;
95 if(menu) menu->slotsChanged();
96}
97
98int CraftingContainer::getMaxStackSize() const
99{
100 return Container::LARGE_MAX_STACK_SIZE;
101}
102
103void CraftingContainer::setChanged()
104{
105}
106
107bool CraftingContainer::stillValid(shared_ptr<Player> player)
108{
109 return true;
110}
111
112bool CraftingContainer::canPlaceItem(int slot, shared_ptr<ItemInstance> item)
113{
114 return true;
115}