ForeverZer0 / SharpNBT

A pure CLS-compliant C# implementation of the Named Binary Tag (NBT) format specification commonly used with Minecraft applications, allowing easy reading/writing streams and serialization to other formats.
MIT License
25 stars 9 forks source link

Problems with ListTags #12

Closed NingLiu1998 closed 11 months ago

NingLiu1998 commented 11 months ago

image

I found some strange things. When parsing, it traverses a ListTag whose type is SharpNBT.TagType.List. Their child item Type is SharpNBT.TagType.Compound, but when I build ListTag

If I

ListTag listTag = new ListTag(NBTEnchants, TagType.List);

Then

   CompoundTag? dicJarrTag = DicToTag(dicJArryItem);

   listTag.Add(dicJarrTag); //An error will be reported here

Exception:

System.ArrayTypeMismatchException: "Incorrect tag type added to this collection."

why is that? Or should my ListTag TagType be set to CompoundTag? So can it still be the same as the original one?

NingLiu1998 commented 11 months ago

image

NingLiu1998 commented 11 months ago

I was wrong! ! !

This is childType, I thought it was the type of ListTag, so I should set it to CompoundTag

sorry! I am stupid to write code, I will try it now 😭😭😭😭

NingLiu1998 commented 11 months ago

Is there any communication tool like discord that can chat with you in real time? i have a question 😟

NingLiu1998 commented 11 months ago

image