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
9
class
BlockPos
;
10
class
Vec3
;
11
// clang-format on
12
13
class
alignas(uint64) ChunkPos :
public
ll::math::intN2<ChunkPos> {
14
public
:
15
template
<std::
float
ing_po
int
T0, std::
float
ing_po
int
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
31
public
:
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
44
namespace
std
{
45
template
<>
46
struct
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
BlockPos
Definition
BlockPos.h:17
ChunkPos
Definition
ChunkPos.h:13
Vec3
Definition
Vec3.h:10
std
STL namespace.
src
mc
world
level
ChunkPos.h
Generated on
for LeviLamina by
1.16.1