Skip to content

Commit ac584f5

Browse files
committed
fix: fix npc cmd crash
1 parent 1fbd62a commit ac584f5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/lse/events/EntityEvents.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "ll/api/service/Bedrock.h"
99
#include "ll/api/service/GamingStatus.h"
1010
#include "mc/common/Globals.h"
11+
#include "mc/deps/ecs/gamerefs_entity/EntityContext.h"
1112
#include "mc/deps/shared_types/legacy/actor/ActorDamageCause.h"
1213
#include "mc/entity/components_json_legacy/NpcComponent.h"
1314
#include "mc/entity/components_json_legacy/ProjectileComponent.h"
@@ -280,7 +281,6 @@ LL_TYPE_INSTANCE_HOOK(
280281
return origin(source, damage);
281282
}
282283

283-
// TODO: fix this event, can't get correct vector via mUnke14f11
284284
LL_TYPE_INSTANCE_HOOK(
285285
NpcCommandHook,
286286
HookPriority::Normal,
@@ -294,9 +294,10 @@ LL_TYPE_INSTANCE_HOOK(
294294
) {
295295
IF_LISTENED(EVENT_TYPES::onNpcCmd) {
296296
auto& action =
297-
mActionsContainer->mUnke14f11.as<std::vector<std::variant<npc::CommandAction, npc::UrlAction>>>().at(
298-
actionIndex
299-
);
297+
owner.getEntityContext()
298+
.tryGetComponent<NpcComponent>()
299+
->mActionsContainer->mUnke14f11.as<std::vector<std::variant<npc::CommandAction, npc::UrlAction>>>()
300+
.at(actionIndex);
300301
if (std::holds_alternative<npc::CommandAction>(action)) {
301302
auto& commands = std::get<npc::CommandAction>(action).commands;
302303
std::string command;

0 commit comments

Comments
 (0)