Skip to content

Commit 5a882fb

Browse files
committed
fix: fix isEnchanted
1 parent f83bd51 commit 5a882fb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/legacy/api/ItemAPI.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ Local<Value> ItemClass::isDamaged() {
224224

225225
Local<Value> ItemClass::isEnchanted() {
226226
try {
227-
return Boolean::newBoolean(get()->mUserData->contains(ItemStackBase::TAG_ENCHANTS(), Tag::List));
227+
return Boolean::newBoolean(
228+
get()->mUserData && get()->mUserData->contains(ItemStackBase::TAG_ENCHANTS(), Tag::List)
229+
);
228230
}
229231
CATCH("Fail in isEnchanted!");
230232
}
@@ -312,7 +314,6 @@ Local<Value> ItemClass::isStackable() {
312314
if (get()->getMaxStackSize() > 1u && get()->getDamageValue() <= 0) {
313315
return Boolean::newBoolean(true);
314316
}
315-
316317
return Boolean::newBoolean(false);
317318
}
318319
CATCH("Fail in isStackable!");

0 commit comments

Comments
 (0)