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