LeviLamina
Loading...
Searching...
No Matches
GameMode.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4#include "mc/common/FacingID.h"
5
6// auto generated inclusion list
7#include "mc/deps/core/math/Vec3.h"
8#include "mc/deps/input/InputMode.h"
9#include "mc/world/gamemode/IGameModeMessenger.h"
10#include "mc/world/gamemode/IGameModeTimer.h"
11#include "mc/world/level/BlockPos.h"
12
13// auto generated forward declare list
14// clang-format off
15class Actor;
16class Block;
17class HitResult;
19class ItemStack;
20class Player;
22struct IGameModeTimer;
23// clang-format on
24
25class GameMode {
26public:
27 [[nodiscard]] ::BlockPos const& getDestroyBlockPos() const { return mDestroyBlockPos.get(); }
28 [[nodiscard]] ::FacingID getDestroyBlockFace() const { return static_cast<::FacingID>(mDestroyBlockFace); }
29
30public:
31 // GameMode inner types declare
32 // clang-format off
33 struct BuildContext;
34 struct BuildDelay;
35 struct BuildPlayerContext;
36 struct ContinueBuildData;
37 // clang-format on
38
39 // GameMode inner types define
40 struct BuildContext {
41 public:
42 // member variables
43 // NOLINTBEGIN
44 ::ll::TypedStorage<1, 1, bool> mHasBuildDirection;
45 ::ll::TypedStorage<1, 1, bool> mHasLastBuiltPosition;
46 ::ll::TypedStorage<1, 1, bool> mLastBuildBlockWasInteractive;
47 ::ll::TypedStorage<1, 1, bool> mLastBuildBlockAlignedPlacement;
48 ::ll::TypedStorage<1, 1, bool> mLastBuildBlockHadSuccessfulUse;
49 ::ll::TypedStorage<4, 12, ::BlockPos> mLastBuiltBlockPosition;
50 ::ll::TypedStorage<4, 12, ::BlockPos> mBuildDirection;
51 ::ll::TypedStorage<4, 12, ::BlockPos> mNextBuildPos;
52 ::ll::TypedStorage<4, 12, ::Vec3> mInitialClickPos;
53 ::ll::TypedStorage<1, 1, uchar> mContinueFacing;
54 // NOLINTEND
55 };
56
57 struct BuildDelay {
58 public:
59 // member variables
60 // NOLINTBEGIN
61 ::ll::TypedStorage<1, 1, bool> mHasDelayElapsed;
62 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mNewLastBuildTimeIfBlockIsBuilt;
63 // NOLINTEND
64 };
65
67 public:
68 // member variables
69 // NOLINTBEGIN
70 ::ll::TypedStorage<4, 12, ::Vec3> mPosDelta;
71 ::ll::TypedStorage<1, 1, bool> mIsSneaking;
72 // NOLINTEND
73 };
74
76 public:
77 // member variables
78 // NOLINTBEGIN
79 ::ll::TypedStorage<4, 12, ::BlockPos const> mHit;
80 ::ll::TypedStorage<1, 1, uchar const> mFacing;
81 // NOLINTEND
82 };
83
84public:
85 // member variables
86 // NOLINTBEGIN
87 ::ll::TypedStorage<8, 8, ::Player&> mPlayer;
88 ::ll::TypedStorage<4, 12, ::BlockPos> mDestroyBlockPos;
89 ::ll::TypedStorage<1, 1, uchar> mDestroyBlockFace;
90 ::ll::TypedStorage<4, 4, float> mOldDestroyProgress;
91 ::ll::TypedStorage<4, 4, float> mDestroyProgress;
92 ::ll::TypedStorage<8, 8, double> mLastDestroyTime;
93 ::ll::TypedStorage<4, 4, float> mDistanceTravelled;
94 ::ll::TypedStorage<4, 12, ::Vec3> mPlayerLastPosition;
95 ::ll::TypedStorage<4, 60, ::GameMode::BuildContext> mBuildContext;
96 ::ll::TypedStorage<4, 4, float> mMinPlayerSpeed;
97 ::ll::TypedStorage<4, 4, int> mContinueBreakBlockCount;
98 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mLastBuildTime;
99 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mNoDestroyUntil;
100 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mNoDestroySoundUntil;
101 ::ll::TypedStorage<8, 8, ::std::chrono::milliseconds> creativeDestructionTickDelay;
102 ::ll::TypedStorage<8, 8, ::std::chrono::milliseconds> buildingTickDelay;
103 ::ll::TypedStorage<8, 8, ::std::chrono::milliseconds> destroySoundDelay;
104 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::IGameModeTimer>> mTimer;
105 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::IGameModeMessenger>> mMessenger;
106 // NOLINTEND
107
108public:
109 // prevent constructor by default
110 GameMode& operator=(GameMode const&);
111 GameMode(GameMode const&);
112 GameMode();
113
114public:
115 // virtual functions
116 // NOLINTBEGIN
117 virtual ~GameMode() = default;
118
119 virtual bool startDestroyBlock(::BlockPos const& pos, uchar face, bool& hasDestroyedBlock);
120
121 virtual bool destroyBlock(::BlockPos const& pos, uchar face);
122
123 virtual bool
124 continueDestroyBlock(::BlockPos const& pos, uchar face, ::Vec3 const& playerPos, bool& hasDestroyedBlock);
125
126 virtual void stopDestroyBlock(::BlockPos const& pos);
127
128 virtual void startBuildBlock(::BlockPos const& pos, uchar face);
129
130 virtual bool buildBlock(::BlockPos const& pos, uchar face, bool const isSimTick);
131
132 virtual void continueBuildBlock(::BlockPos const& pos, uchar face);
133
134 virtual void stopBuildBlock();
135
136 virtual void tick();
137
138 virtual float getPickRange(::InputMode const& currentInputMode);
139
140 virtual bool useItem(::ItemStack& item);
141
142 virtual bool useItemAsAttack(::ItemStack& item, ::Vec3 const& aimDirection);
143
144 virtual ::InteractionResult useItemOn(
145 ::ItemStack& item,
146 ::BlockPos const& at,
147 uchar face,
148 ::Vec3 const& hit,
149 ::Block const* targetBlock,
150 bool isFirstEvent
151 );
152
153 virtual bool interact(::Actor& entity, ::Vec3 const& location);
154
155 virtual bool attack(::Actor& entity, ::Vec3 const& hitPosition);
156
157 virtual void releaseUsingItem();
158
159 virtual void setTrialMode(bool isEnabled);
160
161 virtual bool isInTrialMode();
162
163 virtual void registerUpsellScreenCallback(::std::function<void(bool)> callback);
164 // NOLINTEND
165
166public:
167 // member functions
168 // NOLINTBEGIN
169 MCAPI GameMode(
170 ::Player& player,
171 ::std::unique_ptr<::IGameModeTimer> timer,
172 ::std::unique_ptr<::IGameModeMessenger> messenger
173 );
174
175 MCAPI bool _attack(::Actor& entity, bool playPredictiveSound, ::Vec3 const& hitPosition);
176
177 MCAPI bool _creativeDestroyBlock(::BlockPos const& pos, uchar face);
178
179 MCAPI bool _enableBlockBreakDelay() const;
180
181#ifdef LL_PLAT_C
182 MCAPI bool _startDestroyBlock(::BlockPos const& hitPos, ::Vec3 const&, uchar hitFace, bool& hasDestroyedBlock);
183#endif
184
185 MCAPI bool baseUseItem(::ItemStack const& item);
186
187 MCAPI bool baseUseItemAsAttack(::ItemStack const& item, ::Vec3 const& aimDirection);
188
189 MCAPI void continueBuildBlockAction(::Player const& player, ::HitResult const& hr);
190
191 MCAPI float getDestroyRate(::Block const& block);
192
193 MCAPI float getMaxPickRange();
194 // NOLINTEND
195
196public:
197 // static functions
198 // NOLINTBEGIN
199 MCAPI static void _sendPlayerInteractWithBlockAfterEvent(
200 ::ItemStack const& beforeItem,
201 ::ItemStack const& afterItem,
202 ::Player& player,
203 ::BlockPos const& at,
204 uchar face,
205 ::Vec3 const& hit,
206 bool isFirstEvent
207 );
208 // NOLINTEND
209
210public:
211 // constructor thunks
212 // NOLINTBEGIN
213 MCAPI void* $ctor(
214 ::Player& player,
215 ::std::unique_ptr<::IGameModeTimer> timer,
216 ::std::unique_ptr<::IGameModeMessenger> messenger
217 );
218 // NOLINTEND
219
220public:
221 // virtual function thunks
222 // NOLINTBEGIN
223 MCAPI bool $startDestroyBlock(::BlockPos const& pos, uchar face, bool& hasDestroyedBlock);
224
225 MCAPI bool $destroyBlock(::BlockPos const& pos, uchar face);
226
227 MCAPI bool
228 $continueDestroyBlock(::BlockPos const& pos, uchar face, ::Vec3 const& playerPos, bool& hasDestroyedBlock);
229
230 MCAPI void $stopDestroyBlock(::BlockPos const& pos);
231
232 MCAPI void $startBuildBlock(::BlockPos const& pos, uchar face);
233
234 MCAPI bool $buildBlock(::BlockPos const& pos, uchar face, bool const isSimTick);
235
236 MCAPI void $continueBuildBlock(::BlockPos const& pos, uchar face);
237
238 MCAPI void $stopBuildBlock();
239
240 MCAPI void $tick();
241
242 MCAPI float $getPickRange(::InputMode const& currentInputMode);
243
244 MCAPI bool $useItem(::ItemStack& item);
245
246 MCAPI bool $useItemAsAttack(::ItemStack& item, ::Vec3 const& aimDirection);
247
248 MCAPI ::InteractionResult $useItemOn(
249 ::ItemStack& item,
250 ::BlockPos const& at,
251 uchar face,
252 ::Vec3 const& hit,
253 ::Block const* targetBlock,
254 bool isFirstEvent
255 );
256
257 MCAPI bool $interact(::Actor& entity, ::Vec3 const& location);
258
259 MCAPI bool $attack(::Actor& entity, ::Vec3 const& hitPosition);
260
261 MCAPI void $releaseUsingItem();
262
263 MCFOLD void $setTrialMode(bool isEnabled);
264
265 MCFOLD bool $isInTrialMode();
266
267 MCFOLD void $registerUpsellScreenCallback(::std::function<void(bool)> callback);
268
269
270 // NOLINTEND
271};
Definition Actor.h:114
Definition BlockPos.h:17
Definition Block.h:42
Definition HitResult.h:18
Definition InteractionResult.h:5
Definition ItemStack.h:24
Definition Player.h:129
Definition Vec3.h:10
Definition GameMode.h:40
Definition GameMode.h:57
Definition GameMode.h:66
Definition GameMode.h:75
Definition IGameModeMessenger.h:12
Definition IGameModeTimer.h:5