Skip to content

Commit 957ccdf

Browse files
committed
refactor: replace SimulatedPlayer::create
1 parent 4cc6262 commit 957ccdf

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/legacy/api/SimulatedPlayerAPI.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
#include "api/APIHelp.h"
22
#include "api/BaseAPI.h"
33
#include "api/BlockAPI.h"
4-
#include "api/ContainerAPI.h"
54
#include "api/DeviceAPI.h"
65
#include "api/EntityAPI.h"
76
#include "api/ItemAPI.h"
87
#include "api/McAPI.h"
9-
#include "api/NbtAPI.h"
108
#include "api/PlayerAPI.h"
119
#include "engine/EngineOwnData.h"
1210
#include "engine/GlobalShareData.h"
13-
#include "main/SafeGuardRecord.h"
11+
#include "ll/api/service/Bedrock.h"
1412
#include "mc/server/SimulatedPlayer.h"
1513

16-
#include <algorithm>
14+
#include <ll/api/utils/RandomUtils.h>
1715
#include <mc/external/scripting/gametest/ScriptNavigationResult.h>
1816
#include <mc/nbt/CompoundTag.h>
17+
#include <mc/network/ServerNetworkHandler.h>
1918
#include <mc/server/sim/LookDuration.h>
2019
#include <mc/world/Container.h>
20+
#include <mc/world/Minecraft.h>
2121
#include <mc/world/SimpleContainer.h>
2222
#include <mc/world/actor/Actor.h>
2323
#include <mc/world/actor/player/Player.h>
2424
#include <mc/world/level/BlockSource.h>
2525
#include <mc/world/level/block/Block.h>
2626
#include <mc/world/scores/Objective.h>
2727
#include <string>
28-
#include <unordered_map>
2928
#include <vector>
3029

3130
Local<Value> McClass::spawnSimulatedPlayer(const Arguments& args) {
@@ -59,7 +58,14 @@ Local<Value> McClass::spawnSimulatedPlayer(const Arguments& args) {
5958
}
6059
bpos = BlockPos(args[1].toInt(), args[2].toInt(), args[3].toInt()).bottomCenter();
6160
}
62-
if (auto sp = SimulatedPlayer::create(name, bpos, dimid)) return PlayerClass::newPlayer(sp);
61+
if (auto sp = SimulatedPlayer::create(
62+
name,
63+
bpos,
64+
dimid,
65+
ll::service::getMinecraft()->getServerNetworkHandler(),
66+
std::to_string(ll::random_utils::rand<int64>(INT64_MIN, -1))
67+
))
68+
return PlayerClass::newPlayer(sp);
6369
else return Local<Value>();
6470
}
6571
CATCH("Fail in " __FUNCTION__ "!")

0 commit comments

Comments
 (0)