Skip to content

Commit

Permalink
Adding reading examples
Browse files Browse the repository at this point in the history
  • Loading branch information
DaanV2 committed Dec 24, 2023
1 parent 039a780 commit 44a0ad8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ An NBT library for reading and writing NBT files/data [Nuget package](https://ww

```cs
var Compound = NBTReader.ReadFile("Path to file", Endian.Little, NBTCompression.Auto);
var age = Compound.GetSubTag("Age");

//Retrieve value if you know what type it should be
Int32 item = SubTag.GetValue<Int32>();

//OR
if (SubTag is NBTTagInt a) {
Assert.IsTrue(a.Value == 256, "Hello set wrong")
}

//OR
var item = Compound.GetSubTag<Int32>("Age");
```

## Writes to a file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void TestBuild() {

Assert.IsTrue(Out.GetSubValue<Int32>("Hello") == 256, "Hello set wrong");

ITag SubTag = Out.GetSubTag("Me.Hello");
ITag SubTag = Out.GetSubTag("Hello");

Assert.IsTrue(SubTag.Type == NBTTagType.List, "List is wrong type");
Assert.IsTrue((NBTTagType)SubTag.GetInformation(NBTTagInformation.ListSubtype) == NBTTagType.String, "Wrong sub type");
Expand Down

0 comments on commit 44a0ad8

Please sign in to comment.