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