using System; using LibAC.NBT.API; namespace LibAC.NBT { public class ByteTag : Tag { public byte Value { get; private set; } = 0; public ByteTag() { } private ByteTag(byte value) { Value = value; } public static ByteTag ValueOf(byte value) { return new ByteTag(value); } public override void ReadValue(ByteLayer data) { Value = data.ReadByte(); } public override void WriteValue(ByteLayer data) { data.WriteByte(Value); } public override TagType GetTagType() { return TagType.Byte; } public override dynamic GetValue() { return Value; } public override void SetValue(dynamic val) { if (val is byte) { Value = (byte)val; } } 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($"{Value}b"); } public override void ReadStringifiedValue(StringReader reader) { string val = reader.ReadNumber(); Value = byte.Parse(val); reader.Expect('b'); } } }