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