Port NBT impl from LibAC Dart

This commit is contained in:
zontreck 2024-12-16 04:25:24 -07:00
parent 0a022634c1
commit ad7b619706
55 changed files with 3226 additions and 2983 deletions

32
NBT/API/NBTAccountant.cs Normal file
View file

@ -0,0 +1,32 @@
namespace LibAC.NBT.API;
using System;
public class NBTAccountant
{
private static int _prettyIndex = 0;
public static void PrintRead(Tag tag)
{
tag.PrettyPrint(_prettyIndex, false);
}
public static void VisitTag()
{
_prettyIndex++;
}
public static void LeaveTag(Tag tag)
{
if (tag is CompoundTag ct)
{
ct.EndPrettyPrint(_prettyIndex);
}
else if (tag is ListTag lt)
{
lt.EndPrettyPrint(_prettyIndex);
}
_prettyIndex--;
}
}