the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 80 lines 2.6 kB view raw
1#pragma once 2 3#include "TileEntity.h" 4#include "Hopper.h" 5 6class HopperTileEntity : public TileEntity, public Hopper 7{ 8public: 9 eINSTANCEOF GetType() { return eTYPE_HOPPERTILEENTITY; } 10 static TileEntity *create() { return new HopperTileEntity(); } 11 // 4J Added 12 virtual shared_ptr<TileEntity> clone(); 13 14public: 15 static const int MOVE_ITEM_SPEED = 8; 16 17private: 18 ItemInstanceArray items; 19 wstring name; 20 int cooldownTime ; 21 22public: 23 HopperTileEntity(); 24 ~HopperTileEntity(); 25 26 virtual void load(CompoundTag *base); 27 virtual void save(CompoundTag *base); 28 virtual void setChanged(); 29 virtual unsigned int getContainerSize(); 30 virtual shared_ptr<ItemInstance> getItem(unsigned int slot); 31 virtual shared_ptr<ItemInstance> removeItem(unsigned int slot, int count); 32 virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot); 33 virtual void setItem(unsigned int slot, shared_ptr<ItemInstance> item); 34 virtual wstring getName(); 35 virtual wstring getCustomName(); 36 virtual bool hasCustomName(); 37 virtual void setCustomName(const wstring &name); 38 virtual int getMaxStackSize() const; 39 virtual bool stillValid(shared_ptr<Player> player); 40 virtual void startOpen(); 41 virtual void stopOpen(); 42 virtual bool canPlaceItem(int slot, shared_ptr<ItemInstance> item); 43 virtual void tick(); 44 virtual bool tryMoveItems(); 45 46private: 47 virtual bool ejectItems(); 48 49public: 50 static bool suckInItems(Hopper *hopper); 51 52private: 53 static bool tryTakeInItemFromSlot(Hopper *hopper, Container *container, int slot, int face); 54 55public: 56 static bool addItem(Container *container, shared_ptr<ItemEntity> item); 57 static shared_ptr<ItemInstance> addItem(Container *container, shared_ptr<ItemInstance> item, int face); 58 59private: 60 static bool canPlaceItemInContainer(Container *container, shared_ptr<ItemInstance> item, int slot, int face); 61 static bool canTakeItemFromContainer(Container *container, shared_ptr<ItemInstance> item, int slot, int face); 62 static shared_ptr<ItemInstance> tryMoveInItem(Container *container, shared_ptr<ItemInstance> item, int slot, int face); 63 virtual shared_ptr<Container> getAttachedContainer(); 64 65public: 66 static shared_ptr<Container> getSourceContainer(Hopper *hopper); 67 static shared_ptr<ItemEntity> getItemAt(Level *level, double xt, double yt, double zt); 68 static shared_ptr<Container> getContainerAt(Level *level, double x, double y, double z); 69 70private: 71 static bool canMergeItems(shared_ptr<ItemInstance> a, shared_ptr<ItemInstance> b); 72 73public: 74 virtual Level *getLevel(); 75 virtual double getLevelX(); 76 virtual double getLevelY(); 77 virtual double getLevelZ(); 78 virtual void setCooldown(int time); 79 virtual bool isOnCooldown(); 80};