Fix compile errors, begin to make NBT serialization binary compatible with other NBT libraries
This commit is contained in:
parent
246579f9d2
commit
724f9aaa8c
4 changed files with 88 additions and 12 deletions
74
Serialization/ZNIFile/ShortTag.cs
Normal file
74
Serialization/ZNIFile/ShortTag.cs
Normal file
|
@ -0,0 +1,74 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LibZNI.Serialization.ZNIFile
|
||||
{
|
||||
public class ShortTag : Tag
|
||||
{
|
||||
private short FloatVal;
|
||||
public short Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return FloatVal;
|
||||
}
|
||||
}
|
||||
|
||||
public ShortTag(string _Name, short val)
|
||||
{
|
||||
Name = _Name;
|
||||
FloatVal = val;
|
||||
}
|
||||
public ShortTag(short _FloatVal) : this(null, _FloatVal)
|
||||
{
|
||||
}
|
||||
public ShortTag() : this(null, 0) { }
|
||||
|
||||
public override TagType Type
|
||||
{
|
||||
get
|
||||
{
|
||||
return TagType.SHORT;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ReadTag(BinaryReader br)
|
||||
{
|
||||
Name = br.ReadString();
|
||||
FloatVal = br.ReadInt16();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Rename(string old, string newName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void SkipTag(BinaryReader br)
|
||||
{
|
||||
_ = new ShortTag().ReadTag(br);
|
||||
}
|
||||
|
||||
public override void WriteData(BinaryWriter bw)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void WriteTag(BinaryWriter bw)
|
||||
{
|
||||
bw.Write(((int)Type));
|
||||
bw.Write(Name);
|
||||
|
||||
bw.Write(Value);
|
||||
}
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
return new ShortTag(Name, Value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,19 +8,20 @@ namespace LibZNI.Serialization.ZNIFile
|
|||
{
|
||||
public enum TagType
|
||||
{
|
||||
FOLDER = 10,
|
||||
STRING = 8,
|
||||
INTEGER = 3,
|
||||
LIST = 9, // List can be any valid Tag Type
|
||||
END = 0, // Present at the end of a folder or list
|
||||
BOOL = 13,
|
||||
DOUBLE = 6,
|
||||
FLOAT = 5,
|
||||
LONG = 4,
|
||||
BYTE = 1,
|
||||
SHORT = 2,
|
||||
INTEGER = 3,
|
||||
LONG = 4,
|
||||
FLOAT = 5,
|
||||
DOUBLE = 6,
|
||||
BYTEARRAY = 7,
|
||||
STRING = 8,
|
||||
LIST = 9, // List can be any valid Tag Type
|
||||
FOLDER = 10,
|
||||
INTARRAY = 11,
|
||||
LONGARRAY=12,
|
||||
LONGARRAY = 12,
|
||||
BOOL = 13,
|
||||
ULONG=14,
|
||||
UUID=15,
|
||||
|
||||
|
|
|
@ -19,15 +19,15 @@ namespace LibZNI.Serialization.ZNIFile
|
|||
}
|
||||
public static UUIDTag Random(string sName)
|
||||
{
|
||||
UUIDTag rnd = new UUIDTag(sName, Guid.Random());
|
||||
UUIDTag rnd = new UUIDTag(sName, Guid.NewGuid());
|
||||
|
||||
return rnd;
|
||||
}
|
||||
|
||||
public static UUIDTag Empty(string sName)
|
||||
{
|
||||
UUIDTag z = new UUIDTag(sName, Guid.Empty());
|
||||
return rnd;
|
||||
UUIDTag z = new UUIDTag(sName, Guid.Empty);
|
||||
return z;
|
||||
}
|
||||
|
||||
public UUIDTag(string _Name, Guid val)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue