diff --git a/.gitignore b/.gitignore index 013fcec7..791191dc 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ SubstrateCS/Release/ *.sdf *.user +**/UserPrefs.xml diff --git a/SubstrateCS/Source/Nbt/NbtTree.cs b/SubstrateCS/Source/Nbt/NbtTree.cs index eff53ab6..bd15a772 100644 --- a/SubstrateCS/Source/Nbt/NbtTree.cs +++ b/SubstrateCS/Source/Nbt/NbtTree.cs @@ -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); @@ -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);