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