the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 62 lines 1.4 kB view raw
1#pragma once 2using namespace std; 3 4#include <unordered_map> 5 6class CompoundTag; 7class GameRuleDefinition; 8class Connection; 9 10// A game rule maintains the state for one particular definition 11class GameRule 12{ 13public: 14 typedef struct _ValueType 15 { 16 union{ 17 __int64 i64; 18 int i; 19 char c; 20 bool b; 21 float f; 22 double d; 23 GameRule *gr; 24 }; 25 bool isPointer; 26 27 _ValueType() 28 { 29 i64 = 0; 30 isPointer = false; 31 } 32 } ValueType; 33 34private: 35 GameRuleDefinition *m_definition; 36 Connection *m_connection; 37 38public: 39 typedef unordered_map<wstring,ValueType> stringValueMapType; 40 stringValueMapType m_parameters; // These are the members of this rule that maintain it's state 41 42public: 43 GameRule(GameRuleDefinition *definition, Connection *connection = NULL); 44 virtual ~GameRule(); 45 46 Connection *getConnection() { return m_connection; } 47 48 ValueType getParameter(const wstring &parameterName); 49 void setParameter(const wstring &parameterName,ValueType value); 50 GameRuleDefinition *getGameRuleDefinition(); 51 52 // All the hooks go here 53 void onUseTile(int tileId, int x, int y, int z); 54 void onCollectItem(shared_ptr<ItemInstance> item); 55 56 // 4J-JEV: For saving. 57 //CompoundTag *toTags(unordered_map<GameRuleDefinition *, int> *map); 58 //static GameRule *fromTags(Connection *c, CompoundTag *cTag, vector<GameRuleDefinition *> *grds); 59 60 void write(DataOutputStream *dos); 61 void read(DataInputStream *dos); 62};