From 957ccdf7d5e81c3f26975dce178ec666b52fd735 Mon Sep 17 00:00:00 2001 From: ShrBox Date: Thu, 2 May 2024 16:41:45 +0800 Subject: [PATCH] refactor: replace SimulatedPlayer::create --- src/legacy/api/SimulatedPlayerAPI.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/legacy/api/SimulatedPlayerAPI.cpp b/src/legacy/api/SimulatedPlayerAPI.cpp index f12a76e1..296c00b8 100644 --- a/src/legacy/api/SimulatedPlayerAPI.cpp +++ b/src/legacy/api/SimulatedPlayerAPI.cpp @@ -1,23 +1,23 @@ #include "api/APIHelp.h" #include "api/BaseAPI.h" #include "api/BlockAPI.h" -#include "api/ContainerAPI.h" #include "api/DeviceAPI.h" #include "api/EntityAPI.h" #include "api/ItemAPI.h" #include "api/McAPI.h" -#include "api/NbtAPI.h" #include "api/PlayerAPI.h" #include "engine/EngineOwnData.h" #include "engine/GlobalShareData.h" -#include "main/SafeGuardRecord.h" +#include "ll/api/service/Bedrock.h" #include "mc/server/SimulatedPlayer.h" -#include +#include #include #include +#include #include #include +#include #include #include #include @@ -25,7 +25,6 @@ #include #include #include -#include #include Local McClass::spawnSimulatedPlayer(const Arguments& args) { @@ -59,7 +58,14 @@ Local McClass::spawnSimulatedPlayer(const Arguments& args) { } bpos = BlockPos(args[1].toInt(), args[2].toInt(), args[3].toInt()).bottomCenter(); } - if (auto sp = SimulatedPlayer::create(name, bpos, dimid)) return PlayerClass::newPlayer(sp); + if (auto sp = SimulatedPlayer::create( + name, + bpos, + dimid, + ll::service::getMinecraft()->getServerNetworkHandler(), + std::to_string(ll::random_utils::rand(INT64_MIN, -1)) + )) + return PlayerClass::newPlayer(sp); else return Local(); } CATCH("Fail in " __FUNCTION__ "!")