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