forked from jaquadro/NBTExplorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSubstrateHelper.cs
67 lines (55 loc) · 1.82 KB
/
SubstrateHelper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using Substrate;
using Substrate.Nbt;
namespace NBTExplorer
{
public class SubstrateHelper
{
public static void LoadWorld(string path)
{
NbtWorld world = NbtWorld.Open(path);
BetaWorld beta = world as BetaWorld;
if (beta != null)
{
LoadBetaWorld(beta);
}
}
private static void LoadBetaWorld(BetaWorld world)
{
RegionManager rm = world.GetRegionManager();
}
public static string GetNodeText(string name, string value)
{
name = String.IsNullOrEmpty(name) ? "" : name + ": ";
value = value ?? "";
return name + value;
}
public static string GetNodeText(string name, TagNode tag)
{
return GetNodeText(name,SubstrateHelper. GetTagNodeText(tag));
}
public static string GetTagNodeText(TagNode tag)
{
if (tag == null)
return null;
switch (tag.GetTagType())
{
case TagType.TAG_BYTE:
case TagType.TAG_SHORT:
case TagType.TAG_INT:
case TagType.TAG_LONG:
case TagType.TAG_FLOAT:
case TagType.TAG_DOUBLE:
case TagType.TAG_STRING:
return tag.ToString();
case TagType.TAG_BYTE_ARRAY:
return tag.ToTagByteArray().Length + " bytes";
case TagType.TAG_LIST:
return tag.ToTagList().Count + " entries";
case TagType.TAG_COMPOUND:
return tag.ToTagCompound().Count + " entries";
}
return null;
}
}
}