Files
MinecraftConsoles/Minecraft.World/ChunkPos.h

41 lines
1.0 KiB
C
Raw Normal View History

2026-03-01 12:16:08 +08:00
#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);
2026-03-01 12:16:08 +08:00
int hashCode();
double distanceToSqr(shared_ptr<Entity> e);
2026-03-01 12:16:08 +08:00
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);
2026-03-01 12:16:08 +08:00
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; }
};
struct ChunkPosKeyHash
2026-03-01 12:16:08 +08:00
{
inline __int64 operator()(const ChunkPos &k) const
{ return ChunkPos::hash_fnct(k); }
};
2026-03-01 12:16:08 +08:00
struct ChunkPosKeyEq
2026-03-01 12:16:08 +08:00
{
inline bool operator()(const ChunkPos &x, const ChunkPos &y) const
{ return ChunkPos::eq_test(x, y); }
};