68 lines
1.8 KiB
C#
Executable File
68 lines
1.8 KiB
C#
Executable File
namespace Nbt.Tag;
|
|
|
|
public interface INbtTag : IEquatable<INbtTag>
|
|
{
|
|
NbtTagType Type { get; }
|
|
|
|
INbtTag this[string tagName] { get => throw new NotSupportedException(); set => throw new NotSupportedException(); }
|
|
|
|
INbtTag this[int tagIndex] { get => throw new NotSupportedException(); set => throw new NotSupportedException(); }
|
|
|
|
INbtTag this[INbtPathElement tagPath] { get => throw new NotSupportedException(); set => throw new NotSupportedException(); }
|
|
|
|
INbtTag this[INbtPath tagPath]
|
|
{
|
|
get
|
|
{
|
|
var count = tagPath.Count;
|
|
|
|
if (count == 0)
|
|
{
|
|
return this;
|
|
}
|
|
|
|
var pathElt = tagPath.PopFirst(out var pathRest);
|
|
var childTag = this[pathElt];
|
|
|
|
return childTag[pathRest];
|
|
}
|
|
|
|
set
|
|
{
|
|
var count = tagPath.Count;
|
|
|
|
if (count == 0)
|
|
{
|
|
throw new ArgumentException("Path cannot be empty", nameof(value));
|
|
}
|
|
|
|
var pathElt = tagPath.PopFirst(out var pathRest);
|
|
|
|
if (count == 1)
|
|
{
|
|
this[pathElt] = value;
|
|
}
|
|
else
|
|
{
|
|
var childTag = this[pathElt];
|
|
childTag[pathRest] = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
INbtList AsList() => (INbtList)this;
|
|
|
|
INbtCompound AsCompound() => (INbtCompound)this;
|
|
|
|
INbtValue AsValue() => (INbtValue)this;
|
|
|
|
INbtValue<T> AsValue<T>() where T : notnull => (INbtValue<T>)this;
|
|
|
|
INbtArray AsArray() => (INbtArray)this;
|
|
|
|
INbtArray<T> AsArray<T>() where T : notnull => (INbtArray<T>)this;
|
|
|
|
T As<T>() where T : INbtTag => (T)this;
|
|
|
|
INbtTag Copy();
|
|
} |