aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/ChunkPos.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.World/ChunkPos.h
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.World/ChunkPos.h')
-rw-r--r--Minecraft.World/ChunkPos.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/Minecraft.World/ChunkPos.h b/Minecraft.World/ChunkPos.h
new file mode 100644
index 00000000..f1d483c7
--- /dev/null
+++ b/Minecraft.World/ChunkPos.h
@@ -0,0 +1,40 @@
+#pragma once
+
+class Entity;
+class TilePos;
+
+class ChunkPos
+{
+public:
+ int x, z; // 4J - these were const but needed to make an assignment operator so we could make a vector of ChunkPos
+
+ ChunkPos(int x, int z);
+
+ static __int64 hashCode(int x, int z);
+ int hashCode();
+
+ double distanceToSqr(shared_ptr<Entity> e);
+ double distanceToSqr(double px, double pz); // 4J added
+
+ int getMiddleBlockX();
+ int getMiddleBlockZ();
+
+ TilePos getMiddleBlockPosition(int y);
+ wstring toString();
+
+ static __int64 hash_fnct(const ChunkPos &k);
+ static bool eq_test(const ChunkPos &x, const ChunkPos &y);
+ bool operator == (const ChunkPos &k) const { return (this->x == k.x) && ( this->z == k.z); }
+ ChunkPos & operator= (const ChunkPos & other) { x = other.x; z = other.z; return *this; }
+};
+
+typedef struct
+{
+ __int64 operator() (const ChunkPos &k) const { return ChunkPos::hash_fnct(k); }
+
+} ChunkPosKeyHash;
+
+typedef struct
+{
+ bool operator() (const ChunkPos &x, const ChunkPos &y) const { return ChunkPos::eq_test(x, y); }
+} ChunkPosKeyEq; \ No newline at end of file