LeviLamina
Loading...
Searching...
No Matches
SimulatedPlayer.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4#include "mc/deps/core/math/Vec2.h"
5#include "mc/deps/core/math/Vec3.h"
6#include "mc/server/sim/LookDuration.h"
7#include "mc/world/actor/provider/SynchedActorDataAccess.h"
8
9// auto generated inclusion list
10#include "mc/certificates/identity/PlayerAuthenticationType.h"
11#include "mc/common/SubClientId.h"
12#include "mc/deps/core/utility/AutomaticID.h"
13#include "mc/deps/core/utility/NonOwnerPointer.h"
14#include "mc/scripting/modules/minecraft/ScriptFacing.h"
15#include "mc/server/ServerPlayer.h"
16#include "mc/server/sim/BuildIntent.h"
17#include "mc/server/sim/LookAtIntent.h"
18#include "mc/server/sim/LookDuration.h"
19#include "mc/server/sim/MovementIntent.h"
20#include "mc/world/actor/ActorInitializationMethod.h"
21#include "mc/world/actor/player/PlayerMovementSettings.h"
22#include "mc/world/level/BlockPos.h"
23#include "mc/world/level/GameType.h"
24#include "mc/world/level/storage/PlayerSuspendLevelStorageSaveToken.h"
25
26// auto generated forward declare list
27// clang-format off
28class Actor;
29class BlockSource;
30class ChunkSource;
31class ChunkViewSource;
32class Dimension;
33class EntityContext;
34class ItemStack;
35class Level;
38class PacketSender;
41class Vec2;
42class Vec3;
43struct ActorUniqueID;
46namespace ClientBlobCache::Server { class ActiveTransfersManager; }
47namespace ScriptModuleGameTest { struct ScriptNavigationResult; }
48namespace gametest { class BaseGameTestHelper; }
49namespace mce { class UUID; }
50// clang-format on
51
53public:
55 create(std::string const& name, Vec3 const& pos, DimensionType dimId = 0, Vec2 const& rotation = {0, 0});
56
57 bool simulateSneaking() {
58 setSneaking(true);
59 return SynchedActorDataAccess::getActorFlag(getEntityContext(), ActorFlags::Sneaking);
60 }
61 bool simulateStopSneaking() {
62 setSneaking(false);
63 return !SynchedActorDataAccess::getActorFlag(getEntityContext(), ActorFlags::Sneaking);
64 }
65 bool simulateUseItem() { return simulateUseItemInSlot(getSelectedItemSlot()); }
66
67 LLAPI bool simulateDestroyBlock(BlockPos const&, ScriptModuleMinecraft::ScriptFacing);
68 LLAPI bool simulateDestroyLookAt(float handLength = 5.5f);
69 LLAPI void simulateStopMoving();
70 LLAPI bool simulateAttack(Actor* target);
71 LLAPI void simulateStartBuildInSlot(int slot);
72 LLAPI void simulateStopBuild();
73 LLAPI void simulateStopUsingItem();
74 LLAPI bool simulateGiveItem(ItemStack& item, bool selectSlot);
75 LLAPI bool simulateSetItem(ItemStack const& item, bool selectSlot, int slot);
76 LLAPI bool simulateDropSelectedItem();
77 LLAPI bool simulateInteract(Actor& actor);
78 LLAPI void simulateStopInteracting();
79 LLAPI bool isSimulatingDestroyingBlock();
80 // LLAPI void simulateLookAt(Vec3 const& pos, sim::LookDuration lookType = sim::LookDuration::Instant);
81 LLAPI void simulateLookAt(Actor& actor, sim::LookDuration lookType = sim::LookDuration::Instant);
82 // LLAPI void simulateLookAt(BlockPos const& blockPos, sim::LookDuration lookType = sim::LookDuration::Instant);
83 LLAPI void simulateDisconnect();
84 LLAPI bool simulateRespawn();
85 LLAPI void simulateFly();
86 LLAPI void simulateStopFlying();
87 LLAPI void simulateWorldMove(::Vec3 const& worldDirection, float = 1.0f);
88 LLAPI void simulateLocalMove(::Vec3 const& localDirection, float = 1.0f);
89 LLAPI void simulateMoveToLocation(::Vec3 const& position, float speed, bool faceTarget);
90
91 LLAPI static ::SimulatedPlayer* tryGetFromEntity(::EntityContext& entity, bool includeRemoved);
92
93public:
94 // member variables
95 // NOLINTBEGIN
96 ::ll::TypedStorage<8, 48, ::sim::MovementIntent> mSimulatedMovement;
97 ::ll::TypedStorage<1, 2, ::sim::BuildIntent> mBuildIntention;
98 ::ll::TypedStorage<8, 40, ::sim::LookAtIntent> mLookAtIntent;
99 ::ll::TypedStorage<4, 16, ::std::optional<::BlockPos>> mDestroyingBlockPos;
100 ::ll::TypedStorage<1, 2, ::std::optional<uchar>> mDestroyingBlockFace;
101 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::gametest::BaseGameTestHelper>> mGameTestHelper;
102 ::ll::TypedStorage<8, 16, ::std::optional<uint64>> mCooldownTick;
103 ::ll::TypedStorage<8, 64, ::PlayerMovementSettings> mMovementSettings;
104 ::ll::TypedStorage<4, 4, float> mBaseInputSpeed;
105 ::ll::TypedStorage<8, 32, ::std::string> mXuid;
106 ::ll::TypedStorage<8, 40, ::PlayerSuspendLevelStorageSaveToken const> mPlayerSuspendLevelStorageSaveToken;
107 // NOLINTEND
108
109public:
110 // prevent constructor by default
112
113public:
114 // virtual functions
115 // NOLINTBEGIN
116 // vIndex: 4
117 virtual void
118 initializeComponents(::ActorInitializationMethod method, ::VariantParameterList const& params) /*override*/;
119
120 // vIndex: 146
121 virtual void aiStep() /*override*/;
122
123 // vIndex: 233
124 virtual bool isSimulated() const /*override*/;
125
126 // vIndex: 234
127 virtual ::std::string getXuid() const /*override*/;
128
129 // vIndex: 235
130 virtual ::PlayerMovementSettings const& getMovementSettings() const /*override*/;
131
132 // vIndex: 21
133 virtual void teleportTo(
134 ::Vec3 const& pos,
135 bool shouldStopRiding,
136 int cause,
137 int sourceEntityType,
138 bool keepVelocity
139 ) /*override*/;
140
141 // vIndex: 245
142 virtual int _getSpawnChunkLimit() const /*override*/;
143
144 // vIndex: 241
145 virtual ::std::shared_ptr<::ChunkViewSource> _createChunkSource(::ChunkSource& mainChunkSource) /*override*/;
146
147 // vIndex: 246
148 virtual void _updateChunkPublisherView(::Vec3 const& position, float minDistance) /*override*/;
149
150 // vIndex: 8
151 virtual ~SimulatedPlayer() /*override*/;
152 // NOLINTEND
153
154public:
155 // member functions
156 // NOLINTBEGIN
157 MCAPI SimulatedPlayer(
158 ::Level& level,
159 ::PacketSender& packetSender,
160 ::ServerNetworkSystem& network,
162 ::GameType playerGameType,
163 ::NetworkIdentifier const& owner,
164 ::SubClientId subid,
165 ::std::function<void(::ServerPlayer&)> playerLoadedCallback,
166 ::mce::UUID uuid,
167 ::std::string const& deviceId,
168 ::PlayerAuthenticationType authType,
169 ::PlayerAuthenticationInfo const& authInfo,
170 int maxChunkRadius,
171 bool enableItemStackNetManager,
172 ::EntityContext& entityContext
173 );
174
175 MCAPI void _addMoveComponent();
176
177 MCAPI ::ScriptModuleGameTest::ScriptNavigationResult
178 _createNavigationResult(::NavigationComponent* navigation) const;
179
180 MCFOLD ::BlockSource& _getRegion();
181
182 MCAPI bool _trySwing();
183
184 MCAPI void _updateMovement();
185
186 MCAPI void _updateRidingComponents();
187
188 MCAPI void preAiStep();
189
190 MCAPI void setGameTestHelper(::Bedrock::NonOwnerPointer<::gametest::BaseGameTestHelper> gameTestHelper);
191
192 MCAPI bool simulateAttack();
193
194 MCAPI void simulateChat(::std::string const& message);
195
196 MCAPI bool simulateInteract();
197
198 MCAPI bool simulateInteract(::BlockPos const& pos, ::ScriptModuleMinecraft::ScriptFacing face);
199
200 MCAPI bool simulateJump();
201
202 MCAPI void simulateLookAt(::BlockPos const& blockPos, ::sim::LookDuration lookType = sim::LookDuration::Instant);
203
204 MCAPI void simulateLookAt(::Vec3 const& pos, ::sim::LookDuration lookType = sim::LookDuration::Instant);
205
206 MCAPI ::ScriptModuleGameTest::ScriptNavigationResult simulateNavigateToEntity(::Actor& actor, float speed);
207
208 MCAPI ::ScriptModuleGameTest::ScriptNavigationResult
209 simulateNavigateToLocation(::Vec3 const& position, float speed);
210
211 MCAPI void simulateNavigateToLocations(::std::vector<::Vec3>&& positions, float speed);
212
213 MCAPI void simulateSetBodyRotation(float degY);
214
215 MCAPI void simulateStopDestroyingBlock();
216
217 MCAPI bool simulateUseItemInSlot(int slot);
218
219 MCAPI bool simulateUseItemOnBlock(
220 ::ItemStack& item,
221 ::BlockPos const& pos,
222 ::ScriptModuleMinecraft::ScriptFacing face,
223 ::Vec3 const& facePos
224 );
225 // NOLINTEND
226
227public:
228 // static functions
229 // NOLINTBEGIN
230 MCAPI static ::SimulatedPlayer* create(
231 ::std::string const& name,
232 ::Vec3 const& spawnPos,
233 ::Vec3 const& spawnPosDelta,
234 ::Vec2 const& spawnRotation,
235 bool spawnLoadedFromSave,
236 ::DimensionType dimensionId,
237 ::Bedrock::NotNullNonOwnerPtr<::ServerNetworkHandler> serverNetworkHandler,
238 ::std::string const& xuid,
239 ::std::optional<::ActorUniqueID> idOverride
240 );
241 // NOLINTEND
242
243public:
244 // constructor thunks
245 // NOLINTBEGIN
246 MCAPI void* $ctor(
247 ::Level& level,
248 ::PacketSender& packetSender,
249 ::ServerNetworkSystem& network,
251 ::GameType playerGameType,
252 ::NetworkIdentifier const& owner,
253 ::SubClientId subid,
254 ::std::function<void(::ServerPlayer&)> playerLoadedCallback,
255 ::mce::UUID uuid,
256 ::std::string const& deviceId,
257 ::PlayerAuthenticationType authType,
258 ::PlayerAuthenticationInfo const& authInfo,
259 int maxChunkRadius,
260 bool enableItemStackNetManager,
261 ::EntityContext& entityContext
262 );
263 // NOLINTEND
264
265public:
266 // destructor thunk
267 // NOLINTBEGIN
268 MCAPI void $dtor();
269 // NOLINTEND
270
271public:
272 // virtual function thunks
273 // NOLINTBEGIN
274 MCAPI void $initializeComponents(::ActorInitializationMethod method, ::VariantParameterList const& params);
275
276 MCAPI void $aiStep();
277
278 MCFOLD bool $isSimulated() const;
279
280 MCAPI ::std::string $getXuid() const;
281
282 MCAPI ::PlayerMovementSettings const& $getMovementSettings() const;
283
284 MCAPI void
285 $teleportTo(::Vec3 const& pos, bool shouldStopRiding, int cause, int sourceEntityType, bool keepVelocity);
286
287 MCFOLD int $_getSpawnChunkLimit() const;
288
289 MCAPI ::std::shared_ptr<::ChunkViewSource> $_createChunkSource(::ChunkSource& mainChunkSource);
290
291 MCFOLD void $_updateChunkPublisherView(::Vec3 const& position, float minDistance);
292 // NOLINTEND
293
294public:
295 // vftables
296 // NOLINTBEGIN
297 MCNAPI static void** $vftable();
298 // NOLINTEND
299};
Definition Actor.h:102
Definition AutomaticID.h:6
Definition NonOwnerPointer.h:9
Definition BlockPos.h:17
Definition BlockSource.h:66
Definition ChunkSource.h:34
Definition ChunkViewSource.h:22
Definition ActiveTransfersManager.h:17
Definition Dimension.h:83
Definition EntityContext.h:16
Definition ItemStack.h:23
Definition Level.h:243
Definition NavigationComponent.h:22
Definition NetworkIdentifier.h:10
Definition PacketSender.h:17
Definition ServerNetworkHandler.h:166
Definition ServerNetworkSystem.h:31
Definition ServerPlayer.h:65
Definition SimulatedPlayer.h:52
static MCAPI void ** $vftable()
Definition Vec2.h:5
Definition Vec3.h:10
Definition UUID.h:7
Definition optional_ref.h:10
Definition ActorUniqueID.h:5
Definition PlayerAuthenticationInfo.h:8
Definition VariantParameterList.h:13