Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
SubstrateCS/Release/
*.sdf
*.user
**/UserPrefs.xml
7 changes: 2 additions & 5 deletions SubstrateCS/Source/Nbt/NbtTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,7 @@ private TagNode ReadString ()
Array.Reverse(lenBytes);
}

short len = BitConverter.ToInt16(lenBytes, 0);
if (len < 0) {
throw new NBTException(NBTException.MSG_READ_NEG);
}
ushort len = BitConverter.ToUInt16(lenBytes, 0);

byte[] strBytes = new byte[len];
_stream.Read(strBytes, 0, len);
Expand Down Expand Up @@ -574,7 +571,7 @@ private void WriteString (TagNodeString val)
System.Text.Encoding str = Encoding.UTF8;
byte[] gzBytes = str.GetBytes(val.Data);

byte[] lenBytes = BitConverter.GetBytes((short)gzBytes.Length);
byte[] lenBytes = BitConverter.GetBytes((ushort)gzBytes.Length);

if (BitConverter.IsLittleEndian) {
Array.Reverse(lenBytes);
Expand Down