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