Skip to content

Commit cacd581

Browse files
committed
fix: fix EntityClass::getAllTag
1 parent 89d8d28 commit cacd581

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/legacy/api/EntityAPI.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818
#include "mc/entity/components/ActorRotationComponent.h"
1919
#include "mc/entity/components/InsideBlockComponent.h"
2020
#include "mc/entity/components/IsOnHotBlockFlagComponent.h"
21+
#include "mc/entity/components/TagsComponent.h"
2122
#include "mc/entity/utilities/ActorMobilityUtils.h"
2223
#include "mc/legacy/ActorRuntimeID.h"
2324
#include "mc/legacy/ActorUniqueID.h"
2425
#include "mc/nbt/CompoundTag.h"
2526
#include "mc/server/commands/CommandUtils.h"
27+
#include "mc/util/IDType.h"
2628
#include "mc/world/SimpleContainer.h"
2729
#include "mc/world/actor/ActorDamageByActorSource.h"
2830
#include "mc/world/actor/ActorDamageSource.h"
@@ -1333,11 +1335,15 @@ Local<Value> EntityClass::getAllTags(const Arguments&) {
13331335
Actor* entity = get();
13341336
if (!entity) return Local<Value>();
13351337

1336-
Local<Array> arr = Array::newArray();
1337-
for (auto& tag : entity->getTags()) {
1338-
arr.add(String::newString(tag));
1338+
Local<Array> arr = Array::newArray();
1339+
auto component = entity->getEntityContext().tryGetComponent<TagsComponent<IDType<LevelTagSetIDType>>>();
1340+
if (component) {
1341+
for (auto& tag : ll::service::getLevel()->getTagRegistry().getTagsInSet(component->mTagSetID)) {
1342+
arr.add(String::newString(tag));
1343+
}
1344+
return arr;
13391345
}
1340-
return arr;
1346+
return Local<Value>();
13411347
}
13421348
CATCH("Fail in getAllTags!");
13431349
}

xmake.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ add_rules("mode.debug", "mode.release")
33
add_repositories("liteldev-repo https://github.com/LiteLDev/xmake-repo.git")
44

55
if is_config("target_type", "server") then
6-
add_requires("levilamina bc7d1ce00a68c34f7db9d9a276ed648608d2546a", {configs = {target_type = "server"}})
6+
add_requires("levilamina 1854f0518474ba4d01d9ecffa428565f10b3d26f", {configs = {target_type = "server"}})
77
else
8-
add_requires("levilamina bc7d1ce00a68c34f7db9d9a276ed648608d2546a", {configs = {target_type = "client"}})
8+
add_requires("levilamina 1854f0518474ba4d01d9ecffa428565f10b3d26f", {configs = {target_type = "client"}})
99
end
1010

1111
add_requires("levibuildscript")

0 commit comments

Comments
 (0)