Make NBT Serialization binary compatible with NBT GUI editors
This commit is contained in:
parent
724f9aaa8c
commit
60ced631ba
23 changed files with 1101 additions and 279 deletions
|
@ -36,11 +36,9 @@ namespace LibZNI.Serialization.ZNIFile
|
|||
}
|
||||
}
|
||||
|
||||
public override bool ReadTag(BinaryReader br)
|
||||
public override bool ReadTag(NBTReader br)
|
||||
{
|
||||
Name = br.ReadString();
|
||||
LongVal = br.ReadUInt64();
|
||||
return true;
|
||||
throw new Exception("Not allowed"); // This type must be virtual casted
|
||||
}
|
||||
|
||||
public override void Rename(string old, string newName)
|
||||
|
@ -48,27 +46,43 @@ namespace LibZNI.Serialization.ZNIFile
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void SkipTag(BinaryReader br)
|
||||
public override void SkipTag(NBTReader br)
|
||||
{
|
||||
_ = new uLongTag().ReadTag(br);
|
||||
}
|
||||
|
||||
public override void WriteData(BinaryWriter bw)
|
||||
public override void WriteData(NBTWriter bw)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
Folder vCast = new Folder(Name);
|
||||
vCast.Add(new ByteTag("_virtcast_", (byte)Type));
|
||||
vCast.Add(new StringTag("val", Value.ToString()));
|
||||
if (Parent != null)
|
||||
{
|
||||
if (Parent.Type == TagType.LIST)
|
||||
{
|
||||
vCast.Add(new StringTag("name", Name));
|
||||
}
|
||||
}
|
||||
vCast.WriteTag(bw);
|
||||
vCast.WriteData(bw);
|
||||
}
|
||||
|
||||
public override void WriteTag(BinaryWriter bw)
|
||||
public override void WriteTag(NBTWriter bw)
|
||||
{
|
||||
bw.Write(((int)Type));
|
||||
bw.Write(Name);
|
||||
|
||||
bw.Write(Value);
|
||||
}
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
return new uLongTag(Name, Value);
|
||||
}
|
||||
|
||||
public override void CastFrom(Folder F)
|
||||
{
|
||||
if (!F.HasNamedTag("name"))
|
||||
Name = F.Name;
|
||||
else Name = F["name"].StringValue;
|
||||
LongVal = ulong.Parse(F["val"].StringValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue