the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 104 lines 2.4 kB view raw
1#include "stdafx.h" 2#include "net.minecraft.world.entity.player.h" 3#include "ContainerOpenPacket.h" 4#include "CompoundContainer.h" 5 6CompoundContainer::CompoundContainer(int name, shared_ptr<Container> c1, shared_ptr<Container> c2) 7{ 8 this->name = name; 9 if (c1 == NULL) c1 = c2; 10 if (c2 == NULL) c2 = c1; 11 this->c1 = c1; 12 this->c2 = c2; 13} 14 15int CompoundContainer::getContainerType() 16{ 17 return ContainerOpenPacket::LARGE_CHEST; 18} 19 20unsigned int CompoundContainer::getContainerSize() 21{ 22 return c1->getContainerSize() + c2->getContainerSize(); 23} 24 25bool CompoundContainer::contains(shared_ptr<Container> c) 26{ 27 return c1 == c || c2 == c; 28} 29 30wstring CompoundContainer::getName() 31{ 32 if (c1->hasCustomName()) return c1->getName(); 33 if (c2->hasCustomName()) return c2->getName(); 34 return app.GetString(name); 35} 36 37wstring CompoundContainer::getCustomName() 38{ 39 if (c1->hasCustomName()) return c1->getName(); 40 if (c2->hasCustomName()) return c2->getName(); 41 return L""; 42} 43 44bool CompoundContainer::hasCustomName() 45{ 46 return c1->hasCustomName() || c2->hasCustomName(); 47} 48 49shared_ptr<ItemInstance> CompoundContainer::getItem(unsigned int slot) 50{ 51 if (slot >= c1->getContainerSize()) return c2->getItem(slot - c1->getContainerSize()); 52 else return c1->getItem(slot); 53} 54 55shared_ptr<ItemInstance> CompoundContainer::removeItem(unsigned int slot, int i) 56{ 57 if (slot >= c1->getContainerSize()) return c2->removeItem(slot - c1->getContainerSize(), i); 58 else return c1->removeItem(slot, i); 59} 60 61shared_ptr<ItemInstance> CompoundContainer::removeItemNoUpdate(int slot) 62{ 63 if (slot >= c1->getContainerSize()) return c2->removeItemNoUpdate(slot - c1->getContainerSize()); 64 else return c1->removeItemNoUpdate(slot); 65} 66 67void CompoundContainer::setItem(unsigned int slot, shared_ptr<ItemInstance> item) 68{ 69 if (slot >= c1->getContainerSize()) c2->setItem(slot - c1->getContainerSize(), item); 70 else c1->setItem(slot, item); 71} 72 73int CompoundContainer::getMaxStackSize() const 74{ 75 return c1->getMaxStackSize(); 76} 77 78void CompoundContainer::setChanged() 79{ 80 c1->setChanged(); 81 c2->setChanged(); 82} 83 84bool CompoundContainer::stillValid(shared_ptr<Player> player) 85{ 86 return c1->stillValid(player) && c2->stillValid(player); 87} 88 89void CompoundContainer::startOpen() 90{ 91 c1->startOpen(); 92 c2->startOpen(); 93} 94 95void CompoundContainer::stopOpen() 96{ 97 c1->stopOpen(); 98 c2->stopOpen(); 99} 100 101bool CompoundContainer::canPlaceItem(int slot, shared_ptr<ItemInstance> item) 102{ 103 return true; 104}