Port NBT impl from LibAC Dart
This commit is contained in:
parent
0a022634c1
commit
ad7b619706
55 changed files with 3226 additions and 2983 deletions
32
NBT/API/NBTAccountant.cs
Normal file
32
NBT/API/NBTAccountant.cs
Normal 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--;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue