Make NBT Serialization binary compatible with NBT GUI editors

This commit is contained in:
Tara 2023-01-03 15:46:38 -07:00
parent 724f9aaa8c
commit 60ced631ba
23 changed files with 1101 additions and 279 deletions

View file

@ -36,16 +36,18 @@ namespace LibZNI.Serialization.ZNIFile
}
}
public override bool ReadTag(BinaryReader br)
public override bool ReadTag(NBTReader br)
{
Name = br.ReadString();
if (!(Parent != null && Parent.Type == TagType.LIST))
Name = br.ReadString();
int count = br.ReadInt32();
BArrVal = new int[count];
for(int i = 0; i < count; i++)
for (int i = 0; i < count; i++)
{
BArrVal[i] = br.ReadInt32();
}
return true;
}
@ -54,31 +56,38 @@ namespace LibZNI.Serialization.ZNIFile
throw new NotImplementedException();
}
public override void SkipTag(BinaryReader br)
public override void SkipTag(NBTReader br)
{
_ = new IntArrayTag().ReadTag(br);
}
public override void WriteData(BinaryWriter bw)
public override void WriteData(NBTWriter bw)
{
throw new NotImplementedException();
}
public override void WriteTag(BinaryWriter bw)
{
bw.Write(((int)Type));
bw.Write(Name);
if (!(Parent != null && Parent.Type == TagType.LIST))
bw.Write(Name);
bw.Write(Value.Length);
foreach(int i in Value)
foreach (int i in Value)
{
bw.Write(i);
}
}
public override void WriteTag(NBTWriter bw)
{
bw.Write(Type);
}
public override object Clone()
{
return new IntArrayTag(Name, Value);
}
public override void CastFrom(Folder F)
{
throw new NotImplementedException();
}
}
}