Skip to content

Commit

Permalink
refactor: replace SimulatedPlayer::create
Browse files Browse the repository at this point in the history
  • Loading branch information
ShrBox committed May 2, 2024
1 parent 4cc6262 commit 957ccdf
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/legacy/api/SimulatedPlayerAPI.cpp
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
#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 <algorithm>
#include <ll/api/utils/RandomUtils.h>
#include <mc/external/scripting/gametest/ScriptNavigationResult.h>
#include <mc/nbt/CompoundTag.h>
#include <mc/network/ServerNetworkHandler.h>
#include <mc/server/sim/LookDuration.h>
#include <mc/world/Container.h>
#include <mc/world/Minecraft.h>
#include <mc/world/SimpleContainer.h>
#include <mc/world/actor/Actor.h>
#include <mc/world/actor/player/Player.h>
#include <mc/world/level/BlockSource.h>
#include <mc/world/level/block/Block.h>
#include <mc/world/scores/Objective.h>
#include <string>
#include <unordered_map>
#include <vector>

Local<Value> McClass::spawnSimulatedPlayer(const Arguments& args) {
Expand Down Expand Up @@ -59,7 +58,14 @@ Local<Value> 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>(INT64_MIN, -1))
))
return PlayerClass::newPlayer(sp);
else return Local<Value>();
}
CATCH("Fail in " __FUNCTION__ "!")
Expand Down

0 comments on commit 957ccdf

Please sign in to comment.