Skip to content

Commit ccc1435

Browse files
Fix ListTag type swapping issue (#66)
This code used behaviour from a very old version of the NBT library that no longer exists.
1 parent a972c41 commit ccc1435

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

PyMCTranslate/py3/api/version/translate.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,10 @@ def nbt_from_list(
222222
_int_to_datatype[int(nbt_temp.list_data_type)] != nbt_type
223223
and len(nbt_temp) > 0
224224
):
225-
nbt_temp.list_data_type = datatype_to_nbt(nbt_type).tag_id
226-
for index in range(len(nbt_temp)):
227-
nbt_temp[index] = datatype_to_nbt(nbt_type)()
225+
size = len(nbt_temp)
226+
nbt_temp.clear()
227+
for index in range(size):
228+
nbt_temp.append(datatype_to_nbt(nbt_type)())
228229

229230
# pad out the list to the length of path
230231
if path + 1 > len(nbt_temp):
@@ -241,9 +242,10 @@ def nbt_from_list(
241242
elif isinstance(nbt_temp, TAG_List):
242243
# if the list is a different type to data replace it with type(data)
243244
if nbt_temp.list_data_type != data.tag_id and len(nbt_temp) > 0:
244-
nbt_temp.list_data_type = data.tag_id
245-
for index in range(len(nbt_temp)):
246-
nbt_temp[index] = data.__class__()
245+
size = len(nbt_temp)
246+
nbt_temp.clear()
247+
for index in range(size):
248+
nbt_temp.append(data.__class__())
247249

248250
# pad out the list to the length of path
249251
if data_path + 1 > len(nbt_temp):

0 commit comments

Comments
 (0)