the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 81 lines 1.6 kB view raw
1#include "stdafx.h" 2#include "net.minecraft.world.entity.player.h" 3#include "net.minecraft.world.level.tile.entity.h" 4#include "Container.h" 5#include "Slot.h" 6#include "TrapMenu.h" 7 8TrapMenu::TrapMenu(shared_ptr<Container> inventory, shared_ptr<DispenserTileEntity> trap) 9{ 10 this->trap = trap; 11 12 for (int y = 0; y < 3; y++) 13 { 14 for (int x = 0; x < 3; x++) 15 { 16 addSlot(new Slot(trap, x + y * 3, 62 + x * 18, 17 + y * 18)); 17 } 18 } 19 20 for (int y = 0; y < 3; y++) 21 { 22 for (int x = 0; x < 9; x++) 23 { 24 addSlot(new Slot(inventory, x + y * 9 + 9, 8 + x * 18, 84 + y * 18)); 25 } 26 } 27 for (int x = 0; x < 9; x++) 28 { 29 addSlot(new Slot(inventory, x, 8 + x * 18, 70 + 4 * 18)); 30 } 31} 32 33bool TrapMenu::stillValid(shared_ptr<Player> player) 34{ 35 return trap->stillValid(player); 36} 37 38// 4J Stu - Brought forward from 1.2 39shared_ptr<ItemInstance> TrapMenu::quickMoveStack(shared_ptr<Player> player, int slotIndex) 40{ 41 shared_ptr<ItemInstance> clicked = nullptr; 42 Slot *slot = slots.at(slotIndex); 43 if (slot != NULL && slot->hasItem()) 44 { 45 shared_ptr<ItemInstance> stack = slot->getItem(); 46 clicked = stack->copy(); 47 48 if (slotIndex < INV_SLOT_START) 49 { 50 if (!moveItemStackTo(stack, INV_SLOT_START, USE_ROW_SLOT_END, true)) 51 { 52 return nullptr; 53 } 54 } 55 else 56 { 57 if (!moveItemStackTo(stack, 0, INV_SLOT_START, false)) 58 { 59 return nullptr; 60 } 61 } 62 if (stack->count == 0) 63 { 64 slot->set(nullptr); 65 } 66 else 67 { 68 slot->setChanged(); 69 } 70 if (stack->count == clicked->count) 71 { 72 // nothing moved 73 return nullptr; 74 } 75 else 76 { 77 slot->onTake(player, stack); 78 } 79 } 80 return clicked; 81}