LeviLamina
Loading...
Searching...
No Matches
HitResult.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4#include "mc/world/actor/Actor.h"
5
6// auto generated inclusion list
7#include "mc/deps/core/math/Vec3.h"
8#include "mc/deps/ecs/WeakEntityRef.h"
9#include "mc/world/level/BlockPos.h"
10#include "mc/world/phys/AABB.h"
11#include "mc/world/phys/HitResultType.h"
12
13// auto generated forward declare list
14// clang-format off
15class Actor;
16struct AABBHitResult;
17// clang-format on
18
19class HitResult {
20public:
21 [[nodiscard]] constexpr explicit operator bool() const {
22 return mType == HitResultType::Tile || mType == HitResultType::Entity;
23 }
24
25 HitResult(::HitResult&&) = default;
26
27 HitResult(
28 ::Vec3 const& startPos,
29 ::Vec3 const& rayDir,
30 ::Actor& entity,
31 ::Vec3 const& pos,
32 ::AABB const& entityAABB
33 )
34 : mStartPos(startPos),
35 mRayDir(rayDir),
36 mType(HitResultType::Entity),
37 mFacing(0),
38 mPos(pos),
39 mEntity(entity.getEntityContext().getWeakRef()),
40 mEntityAABB(entityAABB),
41 mIsHitLiquid(false),
42 mLiquidFacing(0),
43 mIndirectHit(false) {}
44
45public:
46 // member variables
47 // NOLINTBEGIN
48 ::Vec3 mStartPos;
49 ::Vec3 mRayDir;
50 ::HitResultType mType;
51 uchar mFacing;
52 ::BlockPos mBlock;
53 ::Vec3 mPos;
54 ::WeakEntityRef mEntity;
55 ::AABB mEntityAABB;
56 bool mIsHitLiquid;
57 uchar mLiquidFacing;
58 ::BlockPos mLiquid;
59 ::Vec3 mLiquidPos;
60 bool mIndirectHit;
61 // NOLINTEND
62
63#ifdef LL_PLAT_S
64public:
65 // prevent constructor by default
66 HitResult& operator=(HitResult const&);
67 HitResult(HitResult const&);
68
69#else // LL_PLAT_C
70public:
71 // prevent constructor by default
72 HitResult(HitResult const&);
73
74#endif
75public:
76 // member functions
77 // NOLINTBEGIN
78 MCAPI HitResult();
79
80 MCAPI explicit HitResult(::AABBHitResult const& hit);
81
82 MCAPI HitResult(::Vec3 const& startPos, ::Vec3 const& rayDir, ::Actor& entity);
83
84 MCAPI HitResult(::Vec3 const& startPos, ::Vec3 const& rayDir, ::Vec3 const& rayEnd);
85
86#ifdef LL_PLAT_C
87 MCAPI HitResult(::Vec3 const& startPos, ::Vec3 const& rayDir, ::Actor& entity, ::Vec3 const& pos);
88#endif
89
90 MCAPI HitResult(
91 ::Vec3 const& startPos,
92 ::Vec3 const& rayDir,
93 ::BlockPos const& blockPos,
94 uchar facing,
95 ::Vec3 const& pos
96 );
97
98 MCAPI float distanceToSqr(::Actor const& otherEntity) const;
99
100 MCAPI ::Actor* getEntity() const;
101
102 MCAPI ::HitResult& operator=(::HitResult&&);
103
104#ifdef LL_PLAT_C
105 MCAPI ::HitResult& operator=(::HitResult const&);
106#endif
107
108 MCAPI void setIsHitLiquid(bool isHit, ::HitResult const& liquidHit);
109 // NOLINTEND
110
111public:
112 // constructor thunks
113 // NOLINTBEGIN
114 MCAPI void* $ctor();
115
116 MCAPI void* $ctor(::AABBHitResult const& hit);
117
118 MCAPI void* $ctor(::Vec3 const& startPos, ::Vec3 const& rayDir, ::Actor& entity);
119
120 MCAPI void* $ctor(::Vec3 const& startPos, ::Vec3 const& rayDir, ::Vec3 const& rayEnd);
121
122#ifdef LL_PLAT_C
123 MCAPI void* $ctor(::Vec3 const& startPos, ::Vec3 const& rayDir, ::Actor& entity, ::Vec3 const& pos);
124#endif
125
126 MCAPI void*
127 $ctor(::Vec3 const& startPos, ::Vec3 const& rayDir, ::BlockPos const& blockPos, uchar facing, ::Vec3 const& pos);
128 // NOLINTEND
129};
Definition AABB.h:18
Definition Actor.h:123
Definition BlockPos.h:21
Definition Vec3.h:10
Definition WeakEntityRef.h:14
Definition AABBHitResult.h:8