LeviLamina
Loading...
Searching...
No Matches
ChunkPos.h
1#pragma once
2
3#include "ll/api/utils/HashUtils.h"
4#include "mc/_HeaderOutputPredefine.h"
5#include "mc/deps/core/math/Vec3.h"
6#include "mc/world/level/BlockPos.h"
7
8// clang-format off
9class BlockPos;
10class Vec3;
11// clang-format on
12
13class alignas(uint64) ChunkPos : public ll::math::intN2<ChunkPos> {
14public:
15 template <std::floating_point T0, std::floating_point T1>
16 [[nodiscard]] constexpr ChunkPos(T0 x, T1 z)
17 : intN2((static_cast<int>(std::floor(x)) >> 4), (static_cast<int>(std::floor(z)) >> 4)) {}
18
19 using intN2::intN2;
20
21 ChunkPos(BlockPos const& bp) {
22 x = bp.x >> 4;
23 z = bp.z >> 4;
24 }
25
26 ChunkPos(Vec3 const& pos) {
27 x = static_cast<int>(floorf(pos.x)) >> 4;
28 z = static_cast<int>(floorf(pos.z)) >> 4;
29 }
30
31public:
32 // static variables
33 // NOLINTBEGIN
34 MCAPI static ::ChunkPos const& INVALID();
35
36 MCAPI static ::ChunkPos const& MAX();
37
38 MCAPI static ::ChunkPos const& MIN();
39
40 MCAPI static ::ChunkPos const& ONE();
41 // NOLINTEND
42};
43
44namespace std {
45template <>
46struct hash<ChunkPos> {
47 size_t operator()(ChunkPos const& pos) const noexcept {
48 return ll::hash_utils::HashCombiner{}.add(pos.x).add(pos.z);
49 }
50};
51} // namespace std
Definition BlockPos.h:17
Definition ChunkPos.h:13
Definition Vec3.h:10
STL namespace.