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.inventory.h"
3#include "HopperMenu.h"
4
5HopperMenu::HopperMenu(shared_ptr<Container> inventory, shared_ptr<Container> hopper)
6{
7 this->hopper = hopper;
8 hopper->startOpen();
9 int yo = 51;
10
11 for (int x = 0; x < hopper->getContainerSize(); x++)
12 {
13 addSlot(new Slot(hopper, x, 44 + x * 18, 20));
14 }
15
16 for (int y = 0; y < 3; y++)
17 {
18 for (int x = 0; x < 9; x++)
19 {
20 addSlot(new Slot(inventory, x + y * 9 + 9, 8 + x * 18, y * 18 + yo));
21 }
22 }
23 for (int x = 0; x < 9; x++)
24 {
25 addSlot(new Slot(inventory, x, 8 + x * 18, 58 + yo));
26 }
27}
28
29bool HopperMenu::stillValid(shared_ptr<Player> player)
30{
31 return hopper->stillValid(player);
32}
33
34shared_ptr<ItemInstance> HopperMenu::quickMoveStack(shared_ptr<Player> player, int slotIndex)
35{
36 shared_ptr<ItemInstance> clicked = nullptr;
37 Slot *slot = slots.at(slotIndex);
38 if (slot != NULL && slot->hasItem())
39 {
40 shared_ptr<ItemInstance> stack = slot->getItem();
41 clicked = stack->copy();
42
43 if (slotIndex < hopper->getContainerSize())
44 {
45 if (!moveItemStackTo(stack, hopper->getContainerSize(), slots.size(), true))
46 {
47 return nullptr;
48 }
49 } else {
50 if (!moveItemStackTo(stack, 0, hopper->getContainerSize(), false))
51 {
52 return nullptr;
53 }
54 }
55 if (stack->count == 0)
56 {
57 slot->set(nullptr);
58 }
59 else
60 {
61 slot->setChanged();
62 }
63 }
64 return clicked;
65}
66
67void HopperMenu::removed(shared_ptr<Player> player)
68{
69 AbstractContainerMenu::removed(player);
70 hopper->stopOpen();
71}
72
73shared_ptr<Container> HopperMenu::getContainer()
74{
75 return hopper;
76}