Skip to content

Commit

Permalink
Fixed list tag setitem
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlegiantJGC committed Jul 15, 2024
1 parent d3d02e9 commit c368ea6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/amulet_nbt/pybind/tag/py_list_tag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,14 +429,19 @@ void init_list(py::module& m) {
#define CASE(ID, TAG_NAME, TAG, TAG_STORAGE, LIST_TAG)\
case ID:{\
/* Cast to C++ objects. Also validate that they are all the same type. */\
std::vector<TAG_STORAGE> vec = list.cast<std::vector<TAG_STORAGE>>();\
std::vector<TAG_STORAGE> vec;\
vec.push_back(std::get<Amulet::TagWrapper<TAG_STORAGE>>(first).tag);\
for (size_t i = 1; i < list.size(); i++){\
Amulet::WrapperNode tag = list[i].cast<Amulet::WrapperNode>();\
vec.push_back(std::get<Amulet::TagWrapper<TAG_STORAGE>>(tag).tag);\
}\
ListTag_set_slice<TAG_STORAGE>(self.tag, slice, vec);\
break;\
}
FOR_EACH_LIST_TAG(CASE)
#undef CASE
default:
throw py::type_error("Values must all be the same NBT tag.");
throw py::type_error("Cannot set a null tag.");
}
} else {
// The value is empty
Expand Down

0 comments on commit c368ea6

Please sign in to comment.