Skip to content

Commit 4973963

Browse files
committed
fix: fix #31
1 parent 7f06050 commit 4973963

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/legacy/api/ItemAPI.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,13 @@ Local<Value> ItemClass::set(const Arguments& args) {
312312
auto itemNew = ItemClass::extract(args[0]);
313313
if (!itemNew) return Local<Value>(); // Null
314314

315+
auto tag = itemNew->save();
315316
if (std::holds_alternative<std::unique_ptr<ItemStack>>(item)) {
316-
std::get<std::unique_ptr<ItemStack>>(item).reset();
317+
std::get<std::unique_ptr<ItemStack>>(item)->load(*tag);
318+
} else {
319+
std::get<ItemStack*>(item)->load(*tag);
317320
}
318-
(item = itemNew);
321+
319322
return Boolean::newBoolean(true);
320323
}
321324
CATCH("Fail in set!");

0 commit comments

Comments
 (0)