aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/GameRules/GameRule.h
diff options
context:
space:
mode:
authordaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
committerdaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
commitb691c43c44ff180d10e7d4a9afc83b98551ff586 (patch)
tree3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.Client/Common/GameRules/GameRule.h
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.Client/Common/GameRules/GameRule.h')
-rw-r--r--Minecraft.Client/Common/GameRules/GameRule.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/Minecraft.Client/Common/GameRules/GameRule.h b/Minecraft.Client/Common/GameRules/GameRule.h
new file mode 100644
index 00000000..bdc2ceff
--- /dev/null
+++ b/Minecraft.Client/Common/GameRules/GameRule.h
@@ -0,0 +1,62 @@
+#pragma once
+using namespace std;
+
+#include <unordered_map>
+
+class CompoundTag;
+class GameRuleDefinition;
+class Connection;
+
+// A game rule maintains the state for one particular definition
+class GameRule
+{
+public:
+ typedef struct _ValueType
+ {
+ union{
+ __int64 i64;
+ int i;
+ char c;
+ bool b;
+ float f;
+ double d;
+ GameRule *gr;
+ };
+ bool isPointer;
+
+ _ValueType()
+ {
+ i64 = 0;
+ isPointer = false;
+ }
+ } ValueType;
+
+private:
+ GameRuleDefinition *m_definition;
+ Connection *m_connection;
+
+public:
+ typedef unordered_map<wstring,ValueType> stringValueMapType;
+ stringValueMapType m_parameters; // These are the members of this rule that maintain it's state
+
+public:
+ GameRule(GameRuleDefinition *definition, Connection *connection = NULL);
+ virtual ~GameRule();
+
+ Connection *getConnection() { return m_connection; }
+
+ ValueType getParameter(const wstring &parameterName);
+ void setParameter(const wstring &parameterName,ValueType value);
+ GameRuleDefinition *getGameRuleDefinition();
+
+ // All the hooks go here
+ void onUseTile(int tileId, int x, int y, int z);
+ void onCollectItem(shared_ptr<ItemInstance> item);
+
+ // 4J-JEV: For saving.
+ //CompoundTag *toTags(unordered_map<GameRuleDefinition *, int> *map);
+ //static GameRule *fromTags(Connection *c, CompoundTag *cTag, vector<GameRuleDefinition *> *grds);
+
+ void write(DataOutputStream *dos);
+ void read(DataInputStream *dos);
+}; \ No newline at end of file