Port NBT impl from LibAC Dart
This commit is contained in:
parent
0a022634c1
commit
ad7b619706
55 changed files with 3226 additions and 2983 deletions
65
NBT/LongTag.cs
Normal file
65
NBT/LongTag.cs
Normal file
|
@ -0,0 +1,65 @@
|
|||
using System;
|
||||
using LibAC.NBT.API;
|
||||
|
||||
namespace LibAC.NBT
|
||||
{
|
||||
public class LongTag : Tag
|
||||
{
|
||||
public long value { get; private set; } = 0;
|
||||
|
||||
public LongTag() { }
|
||||
|
||||
public LongTag(long value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static LongTag ValueOf(long value)
|
||||
{
|
||||
return new LongTag(value);
|
||||
}
|
||||
|
||||
public override void ReadValue(ByteLayer data)
|
||||
{
|
||||
value = data.ReadLong();
|
||||
}
|
||||
|
||||
public override void WriteValue(ByteLayer data)
|
||||
{
|
||||
data.WriteLong(value);
|
||||
}
|
||||
|
||||
public override TagType GetTagType()
|
||||
{
|
||||
return TagType.Long;
|
||||
}
|
||||
|
||||
public override void SetValue(dynamic val)
|
||||
{
|
||||
if (val is long) value = val;
|
||||
}
|
||||
|
||||
public override dynamic GetValue()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
public override void PrettyPrint(int indent, bool recurse)
|
||||
{
|
||||
Console.WriteLine($"{new string('\t', indent)}{Tag.GetCanonicalName(GetTagType())}: {value}");
|
||||
}
|
||||
|
||||
public override void WriteStringifiedValue(StringBuilder builder, int indent, bool isList)
|
||||
{
|
||||
builder.Append($"{(isList ? new string('\t', indent) : "")}{value}L");
|
||||
}
|
||||
|
||||
public override void ReadStringifiedValue(StringReader reader)
|
||||
{
|
||||
long val = long.Parse(reader.ReadNumber());
|
||||
value = val;
|
||||
|
||||
reader.Expect('l');
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue