From e0038359750e28419e589930ce1ab6e3556e82b6 Mon Sep 17 00:00:00 2001 From: Justin Aquadro Date: Mon, 28 Mar 2011 08:47:21 +0000 Subject: [PATCH] NBT cleanup / refactoring --- NBToolkit/NBToolkit/Chunk.cs | 23 +- NBToolkit/NBToolkit/Makefile | 2 +- NBToolkit/NBToolkit/NBT.cs | 801 --------------------------- NBToolkit/NBToolkit/NBT/NBT.cs | 471 ++++++++++++++++ NBToolkit/NBToolkit/NBT/NBTTag.cs | 86 +++ NBToolkit/NBToolkit/NBT/NBTValues.cs | 373 +++++++++++++ NBToolkit/NBToolkit/NBToolkit.csproj | 8 +- NBToolkit/NBToolkit/Oregen.cs | 3 +- NBToolkit/NBToolkit/Program.cs | 3 +- NBToolkit/NBToolkit/Purge.cs | 3 +- NBToolkit/NBToolkit/Region.cs | 3 +- NBToolkit/NBToolkit/Replace.cs | 3 +- NBToolkit/NBToolkit/TKFilter.cs | 1 - 13 files changed, 960 insertions(+), 820 deletions(-) delete mode 100644 NBToolkit/NBToolkit/NBT.cs create mode 100644 NBToolkit/NBToolkit/NBT/NBT.cs create mode 100644 NBToolkit/NBToolkit/NBT/NBTTag.cs create mode 100644 NBToolkit/NBToolkit/NBT/NBTValues.cs diff --git a/NBToolkit/NBToolkit/Chunk.cs b/NBToolkit/NBToolkit/Chunk.cs index 3ad2736..03dcda9 100644 --- a/NBToolkit/NBToolkit/Chunk.cs +++ b/NBToolkit/NBToolkit/Chunk.cs @@ -1,10 +1,11 @@ using System; using System.Collections.Generic; using System.Text; -using NBT; namespace NBToolkit { + using NBT; + public class Chunk { protected int _cx; @@ -118,7 +119,7 @@ namespace NBToolkit public int GetBlockID (int x, int y, int z) { if (_blocks == null) { - _blocks = GetTree().Root.FindTagByName("Level").FindTagByName("Blocks").value.toByteArray(); + _blocks = GetTree().Root.FindTagByName("Level").FindTagByName("Blocks").Value.ToNBTByteArray(); } return _blocks.Data[x << 11 | z << 7 | y]; @@ -127,7 +128,7 @@ namespace NBToolkit public bool SetBlockID (int x, int y, int z, int id) { if (_blocks == null) { - _blocks = GetTree().Root.FindTagByName("Level").FindTagByName("Blocks").value.toByteArray(); + _blocks = GetTree().Root.FindTagByName("Level").FindTagByName("Blocks").Value.ToNBTByteArray(); } int index = x << 11 | z << 7 | y; @@ -144,7 +145,7 @@ namespace NBToolkit public int CountBlockID (int id) { if (_blocks == null) { - _blocks = GetTree().Root.FindTagByName("Level").FindTagByName("Blocks").value.toByteArray(); + _blocks = GetTree().Root.FindTagByName("Level").FindTagByName("Blocks").Value.ToNBTByteArray(); } int c = 0; @@ -160,7 +161,7 @@ namespace NBToolkit public int GetBlockData (int x, int y, int z) { if (_data == null) { - _data = new NibbleArray(GetTree().Root.FindTagByName("Level").FindTagByName("Data").value.toByteArray().Data); + _data = new NibbleArray(GetTree().Root.FindTagByName("Level").FindTagByName("Data").Value.ToNBTByteArray().Data); } return _data[x << 11 | z << 7 | y]; @@ -169,7 +170,7 @@ namespace NBToolkit public bool SetBlockData (int x, int y, int z, int data) { if (_data == null) { - _data = new NibbleArray(GetTree().Root.FindTagByName("Level").FindTagByName("Data").value.toByteArray().Data); + _data = new NibbleArray(GetTree().Root.FindTagByName("Level").FindTagByName("Data").Value.ToNBTByteArray().Data); } int index = x << 11 | z << 7 | y; @@ -186,7 +187,7 @@ namespace NBToolkit public int GetBlockLight (int x, int y, int z) { if (_blockLight == null) { - _blockLight = new NibbleArray(GetTree().Root.FindTagByName("Level").FindTagByName("BlockLight").value.toByteArray().Data); + _blockLight = new NibbleArray(GetTree().Root.FindTagByName("Level").FindTagByName("BlockLight").Value.ToNBTByteArray().Data); } return _blockLight[x << 11 | z << 7 | y]; @@ -195,7 +196,7 @@ namespace NBToolkit public bool SetBlockLight (int x, int y, int z, int light) { if (_blockLight == null) { - _blockLight = new NibbleArray(GetTree().Root.FindTagByName("Level").FindTagByName("BlockLight").value.toByteArray().Data); + _blockLight = new NibbleArray(GetTree().Root.FindTagByName("Level").FindTagByName("BlockLight").Value.ToNBTByteArray().Data); } int index = x << 11 | z << 7 | y; @@ -212,7 +213,7 @@ namespace NBToolkit public int GetSkyLight (int x, int y, int z) { if (_skyLight == null) { - _skyLight = new NibbleArray(GetTree().Root.FindTagByName("Level").FindTagByName("SkyLight").value.toByteArray().Data); + _skyLight = new NibbleArray(GetTree().Root.FindTagByName("Level").FindTagByName("SkyLight").Value.ToNBTByteArray().Data); } return _skyLight[x << 11 | z << 7 | y]; @@ -221,7 +222,7 @@ namespace NBToolkit public bool SetSkyLight (int x, int y, int z, int light) { if (_skyLight == null) { - _skyLight = new NibbleArray(GetTree().Root.FindTagByName("Level").FindTagByName("SkyLight").value.toByteArray().Data); + _skyLight = new NibbleArray(GetTree().Root.FindTagByName("Level").FindTagByName("SkyLight").Value.ToNBTByteArray().Data); } int index = x << 11 | z << 7 | y; @@ -237,7 +238,7 @@ namespace NBToolkit public bool IsPopulated () { - return GetTree().Root.FindTagByName("Level").FindTagByName("TerrainPopulated").value.toByte().Data == 1; + return GetTree().Root.FindTagByName("Level").FindTagByName("TerrainPopulated").Value.ToNBTByte().Data == 1; } protected bool MarkDirty () diff --git a/NBToolkit/NBToolkit/Makefile b/NBToolkit/NBToolkit/Makefile index 064454e..b0a856d 100644 --- a/NBToolkit/NBToolkit/Makefile +++ b/NBToolkit/NBToolkit/Makefile @@ -1,2 +1,2 @@ all: - gmcs -out:nbtoolkit.exe BlockRef.cs BlockManager.cs Chunk.cs ChunkEnumerator.cs ChunkFilter.cs ChunkKey.cs ChunkManager.cs FilteredChunkEnumerator.cs GenOres.cs MathHelper.cs NBT.cs NibbleArray.cs Oregen.cs Program.cs Purge.cs Region.cs RegionEnumerator.cs RegionFile.cs RegionKey.cs RegionManager.cs Replace.cs TKFilter.cs TKOptions.cs World.cs NDesk/Options.cs Zlib/Zlib.cs Zlib/ZlibStream.cs Zlib/ZlibConstants.cs Zlib/ZlibCodec.cs Zlib/ZlibBaseStream.cs Zlib/Tree.cs Zlib/InfTree.cs Zlib/Inflate.cs Zlib/GZipStream.cs Zlib/DeflateStream.cs Zlib/Deflate.cs Zlib/Crc32.cs \ No newline at end of file + gmcs -out:nbtoolkit.exe BlockRef.cs BlockManager.cs Chunk.cs ChunkEnumerator.cs ChunkFilter.cs ChunkKey.cs ChunkManager.cs FilteredChunkEnumerator.cs GenOres.cs MathHelper.cs NBT/NBT.cs NBT/NBTTag.cs NBT/NBTValues.cs NibbleArray.cs Oregen.cs Program.cs Purge.cs Region.cs RegionEnumerator.cs RegionFile.cs RegionKey.cs RegionManager.cs Replace.cs TKFilter.cs TKOptions.cs World.cs NDesk/Options.cs Zlib/Zlib.cs Zlib/ZlibStream.cs Zlib/ZlibConstants.cs Zlib/ZlibCodec.cs Zlib/ZlibBaseStream.cs Zlib/Tree.cs Zlib/InfTree.cs Zlib/Inflate.cs Zlib/GZipStream.cs Zlib/DeflateStream.cs Zlib/Deflate.cs Zlib/Crc32.cs \ No newline at end of file diff --git a/NBToolkit/NBToolkit/NBT.cs b/NBToolkit/NBToolkit/NBT.cs deleted file mode 100644 index 7bc619c..0000000 --- a/NBToolkit/NBToolkit/NBT.cs +++ /dev/null @@ -1,801 +0,0 @@ -using System; -using System.Collections.Generic; -//using System.Linq; -using System.Text; -using System.IO; -using System.IO.Compression; - -namespace NBT -{ - public enum NBT_Type - { - TAG_END = 0, - TAG_BYTE = 1, // 8 bits signed - TAG_SHORT = 2, // 16 bits signed - TAG_INT = 3, // 32 buts signed - TAG_LONG = 4, // 64 bits signed - TAG_FLOAT = 5, - TAG_DOUBLE = 6, - TAG_BYTE_ARRAY = 7, - TAG_STRING = 8, - TAG_LIST = 9, - TAG_COMPOUND = 10 - } - - public abstract class NBT_Value - { - virtual public NBT_Byte toByte () { throw new InvalidCastException(); } - virtual public NBT_Short toShort () { throw new InvalidCastException(); } - virtual public NBT_Int toInt () { throw new InvalidCastException(); } - virtual public NBT_Long toLong () { throw new InvalidCastException(); } - virtual public NBT_Float toFloat () { throw new InvalidCastException(); } - virtual public NBT_Double toDouble () { throw new InvalidCastException(); } - virtual public NBT_ByteArray toByteArray () { throw new InvalidCastException(); } - virtual public NBT_String toString () { throw new InvalidCastException(); } - virtual public NBT_List toList () { throw new InvalidCastException(); } - virtual public NBT_Compound toCompound () { throw new InvalidCastException(); } - - virtual public NBT_Type getType () { return NBT_Type.TAG_END; } - } - - public abstract class NBT_NumericValue : NBT_Value - { - - } - - public class NBT_Byte : NBT_Value - { - protected byte _data = 0; - - override public NBT_Byte toByte () { return this; } - override public NBT_Type getType () { return NBT_Type.TAG_BYTE; } - - public byte Data - { - get { return _data; } - set { _data = value; } - } - - public NBT_Byte () { } - - public NBT_Byte (byte d) - { - _data = d; - } - } - - public class NBT_Short : NBT_Value - { - protected short _data = 0; - - override public NBT_Short toShort () { return this; } - override public NBT_Type getType () { return NBT_Type.TAG_SHORT; } - - public short Data - { - get { return _data; } - set { _data = value; } - } - - public NBT_Short () { } - - public NBT_Short (short d) - { - _data = d; - } - } - - public class NBT_Int : NBT_Value - { - protected int _data = 0; - - override public NBT_Int toInt () { return this; } - override public NBT_Type getType () { return NBT_Type.TAG_INT; } - - public int Data - { - get { return _data; } - set { _data = value; } - } - - public NBT_Int () { } - - public NBT_Int (int d) - { - _data = d; - } - } - - public class NBT_Long : NBT_Value - { - protected long _data = 0; - - override public NBT_Long toLong () { return this; } - override public NBT_Type getType () { return NBT_Type.TAG_LONG; } - - public long Data - { - get { return _data; } - set { _data = value; } - } - - public NBT_Long () { } - - public NBT_Long (long d) - { - _data = d; - } - } - - public class NBT_Float : NBT_Value - { - protected float _data = 0; - - override public NBT_Float toFloat () { return this; } - override public NBT_Type getType () { return NBT_Type.TAG_FLOAT; } - - public float Data - { - get { return _data; } - set { _data = value; } - } - - public NBT_Float () { } - - public NBT_Float (float d) - { - _data = d; - } - } - - public class NBT_Double : NBT_Value - { - protected double _data = 0; - - override public NBT_Double toDouble () { return this; } - override public NBT_Type getType () { return NBT_Type.TAG_DOUBLE; } - - public double Data - { - get { return _data; } - set { _data = value; } - } - - public NBT_Double () { } - - public NBT_Double (double d) - { - _data = d; - } - } - - public class NBT_ByteArray : NBT_Value - { - protected byte[] _data = null; - - override public NBT_ByteArray toByteArray () { return this; } - override public NBT_Type getType () { return NBT_Type.TAG_BYTE_ARRAY; } - - public byte[] Data - { - get { return _data; } - set { _data = value; } - } - - public int Length - { - get { return _data.Length; } - } - - public NBT_ByteArray () { } - - public NBT_ByteArray (byte[] d) - { - _data = d; - } - } - - public class NBT_String : NBT_Value - { - protected string _data = null; - - override public NBT_String toString () { return this; } - override public NBT_Type getType () { return NBT_Type.TAG_STRING; } - - public string Data - { - get { return _data; } - set { _data = value; } - } - - public int Length - { - get { return _data.Length; } - } - - public NBT_String () { } - - public NBT_String (string d) - { - _data = d; - } - } - - public class NBT_List : NBT_Value - { - protected NBT_Type _type = NBT_Type.TAG_END; - - protected List _items = null; - - override public NBT_List toList () { return this; } - override public NBT_Type getType () { return NBT_Type.TAG_LIST; } - - public int Count - { - get { return _items.Count; } - } - - public List Items - { - get { return _items; } - } - - public NBT_Type ValueType - { - get { return _type; } - } - - public NBT_List (NBT_Type type) { - _type = type; - _items = new List(); - } - - public NBT_List (NBT_Type type, List items) - { - _type = type; - _items = items; - } - - public void AddItem (NBT_Value val) - { - if (_type != val.getType()) { - throw new InvalidValueException(); - } - - _items.Add(val); - } - - public bool RemoveItem (NBT_Value val) - { - return _items.Remove(val); - } - } - - public class NBT_Compound : NBT_Value - { - protected List _tags = null; - - override public NBT_Compound toCompound () { return this; } - override public NBT_Type getType () { return NBT_Type.TAG_COMPOUND; } - - public int Count - { - get { return _tags.Count; } - } - - public List Tags - { - get { return _tags; } - } - - public NBT_Compound () { - _tags = new List(); - } - - public NBT_Compound (List tags) - { - _tags = tags; - } - - public void AddTag (NBT_Tag sub) - { - _tags.Add(sub); - } - - public bool RemoveTag (NBT_Tag sub) - { - return _tags.Remove(sub); - } - - public NBT_Tag FindTagByName (string name) - { - foreach (NBT_Tag tag in _tags) { - if (tag.name.Data == name) { - return tag; - } - } - - return null; - } - } - - public class NBT_Tag - { - public NBT_Type type; - public NBT_String name; - - public NBT_Value value; - - public NBT_Tag FindTagByName (string name) - { - if (type != NBT_Type.TAG_COMPOUND) { - throw new InvalidTagException(); - } - - return value.toCompound().FindTagByName(name); - } - } - - public class NBT_Tree - { - private Stream stream = null; - - protected NBT_Tag _root = null; - - public NBT_Tree (Stream s) - { - ReadFrom(s); - } - - public void ReadFrom (Stream s) - { - if (s != null) { - stream = s; - _root = ReadTag(); - stream = null; - } - } - - public void WriteTo (Stream s) - { - if (s != null) { - stream = s; - - if (_root != null) { - WriteTag(_root); - } - - stream = null; - } - } - - public NBT_Tag Root - { - get { return _root; } - } - - private NBT_Value ReadValue (NBT_Type type) - { - switch (type) { - case NBT_Type.TAG_END: - return null; - - case NBT_Type.TAG_BYTE: - return ReadByte(); - - case NBT_Type.TAG_SHORT: - return ReadShort(); - - case NBT_Type.TAG_INT: - return ReadInt(); - - case NBT_Type.TAG_LONG: - return ReadLong(); - - case NBT_Type.TAG_FLOAT: - return ReadFloat(); - - case NBT_Type.TAG_DOUBLE: - return ReadDouble(); - - case NBT_Type.TAG_BYTE_ARRAY: - return ReadByteArray(); - - case NBT_Type.TAG_STRING: - return ReadString(); - - case NBT_Type.TAG_LIST: - return ReadList(); - - case NBT_Type.TAG_COMPOUND: - return ReadCompound(); - } - - throw new Exception(); - } - - private NBT_Value ReadByte () - { - int gzByte = stream.ReadByte(); - if (gzByte == -1) { - throw new NBTException(NBTException.MSG_GZIP_ENDOFSTREAM); - } - - NBT_Byte val = new NBT_Byte((byte)gzByte); - - return val; - } - - private NBT_Value ReadShort () - { - byte[] gzBytes = new byte[2]; - stream.Read(gzBytes, 0, 2); - - if (BitConverter.IsLittleEndian) { - Array.Reverse(gzBytes); - } - - NBT_Short val = new NBT_Short(BitConverter.ToInt16(gzBytes, 0)); - - return val; - } - - private NBT_Value ReadInt () - { - byte[] gzBytes = new byte[4]; - stream.Read(gzBytes, 0, 4); - - if (BitConverter.IsLittleEndian) { - Array.Reverse(gzBytes); - } - - NBT_Int val = new NBT_Int(BitConverter.ToInt32(gzBytes, 0)); - - return val; - } - - private NBT_Value ReadLong () - { - byte[] gzBytes = new byte[8]; - stream.Read(gzBytes, 0, 8); - - if (BitConverter.IsLittleEndian) { - Array.Reverse(gzBytes); - } - - NBT_Long val = new NBT_Long(BitConverter.ToInt64(gzBytes, 0)); - - return val; - } - - private NBT_Value ReadFloat () - { - byte[] gzBytes = new byte[4]; - stream.Read(gzBytes, 0, 4); - - if (BitConverter.IsLittleEndian) { - Array.Reverse(gzBytes); - } - - NBT_Float val = new NBT_Float(BitConverter.ToSingle(gzBytes, 0)); - - return val; - } - - private NBT_Value ReadDouble () - { - byte[] gzBytes = new byte[8]; - stream.Read(gzBytes, 0, 8); - - if (BitConverter.IsLittleEndian) { - Array.Reverse(gzBytes); - } - - NBT_Double val = new NBT_Double(BitConverter.ToDouble(gzBytes, 0)); - - return val; - } - - private NBT_Value ReadByteArray () - { - byte[] lenBytes = new byte[4]; - stream.Read(lenBytes, 0, 4); - - if (BitConverter.IsLittleEndian) { - Array.Reverse(lenBytes); - } - - int length = BitConverter.ToInt32(lenBytes, 0); - if (length < 0) { - throw new NBTException(NBTException.MSG_READ_NEG); - } - - byte[] data = new byte[length]; - stream.Read(data, 0, length); - - NBT_ByteArray val = new NBT_ByteArray(data); - - return val; - } - - private NBT_Value ReadString () - { - byte[] lenBytes = new byte[2]; - stream.Read(lenBytes, 0, 2); - - if (BitConverter.IsLittleEndian) { - Array.Reverse(lenBytes); - } - - short len = BitConverter.ToInt16(lenBytes, 0); - if (len < 0) { - throw new NBTException(NBTException.MSG_READ_NEG); - } - - byte[] strBytes = new byte[len]; - stream.Read(strBytes, 0, len); - - System.Text.Encoding str = Encoding.GetEncoding(28591); - - NBT_String val = new NBT_String(str.GetString(strBytes)); - - return val; - } - - private NBT_Value ReadList () - { - int gzByte = stream.ReadByte(); - if (gzByte == -1) { - throw new NBTException(NBTException.MSG_GZIP_ENDOFSTREAM); - } - - NBT_List val = new NBT_List((NBT_Type)gzByte); - if (val.ValueType > (NBT_Type)Enum.GetValues(typeof(NBT_Type)).GetUpperBound(0)) { - throw new NBTException(NBTException.MSG_READ_TYPE); - } - - byte[] lenBytes = new byte[4]; - stream.Read(lenBytes, 0, 4); - - if (BitConverter.IsLittleEndian) { - Array.Reverse(lenBytes); - } - - int length = BitConverter.ToInt32(lenBytes, 0); - if (length < 0) { - throw new NBTException(NBTException.MSG_READ_NEG); - } - - for (int i = 0; i < length; i++) { - val.AddItem(ReadValue(val.ValueType)); - } - - return val; - } - - private NBT_Value ReadCompound () - { - NBT_Compound val = new NBT_Compound(); - - while (true) { - NBT_Tag tag = ReadTag(); - if (tag.type == NBT_Type.TAG_END) { - break; - } - - val.AddTag(tag); - } - - return val; - } - - private NBT_Tag ReadTag () - { - NBT_Tag tag = new NBT_Tag(); - - tag.type = (NBT_Type)stream.ReadByte(); - tag.name = null; - tag.value = null; - - if (tag.type != NBT_Type.TAG_END) { - tag.name = ReadString().toString(); - } - - tag.value = ReadValue(tag.type); - - return tag; - } - - private void WriteValue (NBT_Value val) - { - switch (val.getType()) { - case NBT_Type.TAG_END: - break; - - case NBT_Type.TAG_BYTE: - WriteByte(val.toByte()); - break; - - case NBT_Type.TAG_SHORT: - WriteShort(val.toShort()); - break; - - case NBT_Type.TAG_INT: - WriteInt(val.toInt()); - break; - - case NBT_Type.TAG_LONG: - WriteLong(val.toLong()); - break; - - case NBT_Type.TAG_FLOAT: - WriteFloat(val.toFloat()); - break; - - case NBT_Type.TAG_DOUBLE: - WriteDouble(val.toDouble()); - break; - - case NBT_Type.TAG_BYTE_ARRAY: - WriteByteArray(val.toByteArray()); - break; - - case NBT_Type.TAG_STRING: - WriteString(val.toString()); - break; - - case NBT_Type.TAG_LIST: - WriteList(val.toList()); - break; - - case NBT_Type.TAG_COMPOUND: - WriteCompound(val.toCompound()); - break; - } - } - - private void WriteByte (NBT_Byte val) - { - stream.WriteByte(val.Data); - } - - private void WriteShort (NBT_Short val) - { - byte[] gzBytes = BitConverter.GetBytes(val.Data); - - if (BitConverter.IsLittleEndian) { - Array.Reverse(gzBytes); - } - - stream.Write(gzBytes, 0, 2); - } - - private void WriteInt (NBT_Int val) - { - byte[] gzBytes = BitConverter.GetBytes(val.Data); - - if (BitConverter.IsLittleEndian) { - Array.Reverse(gzBytes); - } - - stream.Write(gzBytes, 0, 4); - } - - private void WriteLong (NBT_Long val) - { - byte[] gzBytes = BitConverter.GetBytes(val.Data); - - if (BitConverter.IsLittleEndian) { - Array.Reverse(gzBytes); - } - - stream.Write(gzBytes, 0, 8); - } - - private void WriteFloat (NBT_Float val) - { - byte[] gzBytes = BitConverter.GetBytes(val.Data); - - if (BitConverter.IsLittleEndian) { - Array.Reverse(gzBytes); - } - - stream.Write(gzBytes, 0, 4); - } - - private void WriteDouble (NBT_Double val) - { - byte[] gzBytes = BitConverter.GetBytes(val.Data); - - if (BitConverter.IsLittleEndian) { - Array.Reverse(gzBytes); - } - - stream.Write(gzBytes, 0, 8); - } - - private void WriteByteArray (NBT_ByteArray val) - { - byte[] lenBytes = BitConverter.GetBytes(val.Length); - - if (BitConverter.IsLittleEndian) { - Array.Reverse(lenBytes); - } - - stream.Write(lenBytes, 0, 4); - stream.Write(val.Data, 0, val.Length); - } - - private void WriteString (NBT_String val) - { - byte[] lenBytes = BitConverter.GetBytes((short)val.Length); - - if (BitConverter.IsLittleEndian) { - Array.Reverse(lenBytes); - } - - stream.Write(lenBytes, 0, 2); - - System.Text.Encoding str = Encoding.GetEncoding(28591); - byte[] gzBytes = str.GetBytes(val.Data); - - stream.Write(gzBytes, 0, gzBytes.Length); - } - - private void WriteList (NBT_List val) - { - byte[] lenBytes = BitConverter.GetBytes(val.Count); - - if (BitConverter.IsLittleEndian) { - Array.Reverse(lenBytes); - } - - stream.WriteByte((byte)val.ValueType); - stream.Write(lenBytes, 0, 4); - - foreach (NBT_Value v in val.Items) { - WriteValue(v); - } - } - - private void WriteCompound (NBT_Compound val) - { - foreach (NBT_Tag t in val.Tags) { - WriteTag(t); - } - - NBT_Tag e = new NBT_Tag(); - e.type = NBT_Type.TAG_END; - - WriteTag(e); - } - - private void WriteTag (NBT_Tag tag) - { - stream.WriteByte((byte)tag.type); - - if (tag.type != NBT_Type.TAG_END) { - WriteString(tag.name); - WriteValue(tag.value); - } - } - } - - public class NBTException : Exception - { - public const String MSG_GZIP_ENDOFSTREAM = "Gzip Error: Unexpected end of stream"; - - public const String MSG_READ_NEG = "Read Error: Negative length"; - public const String MSG_READ_TYPE = "Read Error: Invalid value type"; - - public NBTException () { } - - public NBTException (String msg) : base(msg) { } - - public NBTException (String msg, Exception innerException) : base(msg, innerException) { } - } - - public class InvalidTagException : Exception { } - - public class InvalidValueException : Exception { } -} diff --git a/NBToolkit/NBToolkit/NBT/NBT.cs b/NBToolkit/NBToolkit/NBT/NBT.cs new file mode 100644 index 0000000..e91fbcf --- /dev/null +++ b/NBToolkit/NBToolkit/NBT/NBT.cs @@ -0,0 +1,471 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using System.IO.Compression; + +namespace NBToolkit.NBT +{ + + public class NBT_Tree + { + private Stream _stream = null; + private NBT_Tag _root = null; + + public NBT_Tag Root + { + get { return _root; } + } + + public NBT_Tree () + { + _root = new NBT_Tag("", new NBT_Compound()); + } + + public NBT_Tree (Stream s) + { + ReadFrom(s); + } + + public void ReadFrom (Stream s) + { + if (s != null) { + _stream = s; + _root = ReadTag(); + _stream = null; + } + } + + public void WriteTo (Stream s) + { + if (s != null) { + _stream = s; + + if (_root != null) { + WriteTag(_root); + } + + _stream = null; + } + } + + private NBT_Value ReadValue (NBT_Type type) + { + switch (type) { + case NBT_Type.TAG_END: + return null; + + case NBT_Type.TAG_BYTE: + return ReadByte(); + + case NBT_Type.TAG_SHORT: + return ReadShort(); + + case NBT_Type.TAG_INT: + return ReadInt(); + + case NBT_Type.TAG_LONG: + return ReadLong(); + + case NBT_Type.TAG_FLOAT: + return ReadFloat(); + + case NBT_Type.TAG_DOUBLE: + return ReadDouble(); + + case NBT_Type.TAG_BYTE_ARRAY: + return ReadByteArray(); + + case NBT_Type.TAG_STRING: + return ReadString(); + + case NBT_Type.TAG_LIST: + return ReadList(); + + case NBT_Type.TAG_COMPOUND: + return ReadCompound(); + } + + throw new Exception(); + } + + private NBT_Value ReadByte () + { + int gzByte = _stream.ReadByte(); + if (gzByte == -1) { + throw new NBTException(NBTException.MSG_GZIP_ENDOFSTREAM); + } + + NBT_Byte val = new NBT_Byte((byte)gzByte); + + return val; + } + + private NBT_Value ReadShort () + { + byte[] gzBytes = new byte[2]; + _stream.Read(gzBytes, 0, 2); + + if (BitConverter.IsLittleEndian) { + Array.Reverse(gzBytes); + } + + NBT_Short val = new NBT_Short(BitConverter.ToInt16(gzBytes, 0)); + + return val; + } + + private NBT_Value ReadInt () + { + byte[] gzBytes = new byte[4]; + _stream.Read(gzBytes, 0, 4); + + if (BitConverter.IsLittleEndian) { + Array.Reverse(gzBytes); + } + + NBT_Int val = new NBT_Int(BitConverter.ToInt32(gzBytes, 0)); + + return val; + } + + private NBT_Value ReadLong () + { + byte[] gzBytes = new byte[8]; + _stream.Read(gzBytes, 0, 8); + + if (BitConverter.IsLittleEndian) { + Array.Reverse(gzBytes); + } + + NBT_Long val = new NBT_Long(BitConverter.ToInt64(gzBytes, 0)); + + return val; + } + + private NBT_Value ReadFloat () + { + byte[] gzBytes = new byte[4]; + _stream.Read(gzBytes, 0, 4); + + if (BitConverter.IsLittleEndian) { + Array.Reverse(gzBytes); + } + + NBT_Float val = new NBT_Float(BitConverter.ToSingle(gzBytes, 0)); + + return val; + } + + private NBT_Value ReadDouble () + { + byte[] gzBytes = new byte[8]; + _stream.Read(gzBytes, 0, 8); + + if (BitConverter.IsLittleEndian) { + Array.Reverse(gzBytes); + } + + NBT_Double val = new NBT_Double(BitConverter.ToDouble(gzBytes, 0)); + + return val; + } + + private NBT_Value ReadByteArray () + { + byte[] lenBytes = new byte[4]; + _stream.Read(lenBytes, 0, 4); + + if (BitConverter.IsLittleEndian) { + Array.Reverse(lenBytes); + } + + int length = BitConverter.ToInt32(lenBytes, 0); + if (length < 0) { + throw new NBTException(NBTException.MSG_READ_NEG); + } + + byte[] data = new byte[length]; + _stream.Read(data, 0, length); + + NBT_ByteArray val = new NBT_ByteArray(data); + + return val; + } + + private NBT_Value ReadString () + { + byte[] lenBytes = new byte[2]; + _stream.Read(lenBytes, 0, 2); + + if (BitConverter.IsLittleEndian) { + Array.Reverse(lenBytes); + } + + short len = BitConverter.ToInt16(lenBytes, 0); + if (len < 0) { + throw new NBTException(NBTException.MSG_READ_NEG); + } + + byte[] strBytes = new byte[len]; + _stream.Read(strBytes, 0, len); + + System.Text.Encoding str = Encoding.GetEncoding(28591); + + NBT_String val = new NBT_String(str.GetString(strBytes)); + + return val; + } + + private NBT_Value ReadList () + { + int gzByte = _stream.ReadByte(); + if (gzByte == -1) { + throw new NBTException(NBTException.MSG_GZIP_ENDOFSTREAM); + } + + NBT_List val = new NBT_List((NBT_Type)gzByte); + if (val.ValueType > (NBT_Type)Enum.GetValues(typeof(NBT_Type)).GetUpperBound(0)) { + throw new NBTException(NBTException.MSG_READ_TYPE); + } + + byte[] lenBytes = new byte[4]; + _stream.Read(lenBytes, 0, 4); + + if (BitConverter.IsLittleEndian) { + Array.Reverse(lenBytes); + } + + int length = BitConverter.ToInt32(lenBytes, 0); + if (length < 0) { + throw new NBTException(NBTException.MSG_READ_NEG); + } + + for (int i = 0; i < length; i++) { + val.AddItem(ReadValue(val.ValueType)); + } + + return val; + } + + private NBT_Value ReadCompound () + { + NBT_Compound val = new NBT_Compound(); + + while (true) { + NBT_Tag tag = ReadTag(); + if (tag.Type == NBT_Type.TAG_END) { + break; + } + + val.AddTag(tag); + } + + return val; + } + + private NBT_Tag ReadTag () + { + NBT_Tag tag = new NBT_Tag(); + + NBT_Type type = (NBT_Type)_stream.ReadByte(); + if (type != NBT_Type.TAG_END) { + tag.Name = ReadString().ToNBTString(); + } + + tag.Value = ReadValue(type); + + return tag; + } + + private void WriteValue (NBT_Value val) + { + switch (val.GetNBTType()) { + case NBT_Type.TAG_END: + break; + + case NBT_Type.TAG_BYTE: + WriteByte(val.ToNBTByte()); + break; + + case NBT_Type.TAG_SHORT: + WriteShort(val.ToNBTShort()); + break; + + case NBT_Type.TAG_INT: + WriteInt(val.ToNBTInt()); + break; + + case NBT_Type.TAG_LONG: + WriteLong(val.ToNBTLong()); + break; + + case NBT_Type.TAG_FLOAT: + WriteFloat(val.ToNBTFloat()); + break; + + case NBT_Type.TAG_DOUBLE: + WriteDouble(val.ToNBTDouble()); + break; + + case NBT_Type.TAG_BYTE_ARRAY: + WriteByteArray(val.ToNBTByteArray()); + break; + + case NBT_Type.TAG_STRING: + WriteString(val.ToNBTString()); + break; + + case NBT_Type.TAG_LIST: + WriteList(val.ToNBTList()); + break; + + case NBT_Type.TAG_COMPOUND: + WriteCompound(val.ToNBTCompound()); + break; + } + } + + private void WriteByte (NBT_Byte val) + { + _stream.WriteByte(val.Data); + } + + private void WriteShort (NBT_Short val) + { + byte[] gzBytes = BitConverter.GetBytes(val.Data); + + if (BitConverter.IsLittleEndian) { + Array.Reverse(gzBytes); + } + + _stream.Write(gzBytes, 0, 2); + } + + private void WriteInt (NBT_Int val) + { + byte[] gzBytes = BitConverter.GetBytes(val.Data); + + if (BitConverter.IsLittleEndian) { + Array.Reverse(gzBytes); + } + + _stream.Write(gzBytes, 0, 4); + } + + private void WriteLong (NBT_Long val) + { + byte[] gzBytes = BitConverter.GetBytes(val.Data); + + if (BitConverter.IsLittleEndian) { + Array.Reverse(gzBytes); + } + + _stream.Write(gzBytes, 0, 8); + } + + private void WriteFloat (NBT_Float val) + { + byte[] gzBytes = BitConverter.GetBytes(val.Data); + + if (BitConverter.IsLittleEndian) { + Array.Reverse(gzBytes); + } + + _stream.Write(gzBytes, 0, 4); + } + + private void WriteDouble (NBT_Double val) + { + byte[] gzBytes = BitConverter.GetBytes(val.Data); + + if (BitConverter.IsLittleEndian) { + Array.Reverse(gzBytes); + } + + _stream.Write(gzBytes, 0, 8); + } + + private void WriteByteArray (NBT_ByteArray val) + { + byte[] lenBytes = BitConverter.GetBytes(val.Length); + + if (BitConverter.IsLittleEndian) { + Array.Reverse(lenBytes); + } + + _stream.Write(lenBytes, 0, 4); + _stream.Write(val.Data, 0, val.Length); + } + + private void WriteString (NBT_String val) + { + byte[] lenBytes = BitConverter.GetBytes((short)val.Length); + + if (BitConverter.IsLittleEndian) { + Array.Reverse(lenBytes); + } + + _stream.Write(lenBytes, 0, 2); + + System.Text.Encoding str = Encoding.GetEncoding(28591); + byte[] gzBytes = str.GetBytes(val.Data); + + _stream.Write(gzBytes, 0, gzBytes.Length); + } + + private void WriteList (NBT_List val) + { + byte[] lenBytes = BitConverter.GetBytes(val.Count); + + if (BitConverter.IsLittleEndian) { + Array.Reverse(lenBytes); + } + + _stream.WriteByte((byte)val.ValueType); + _stream.Write(lenBytes, 0, 4); + + foreach (NBT_Value v in val.Items) { + WriteValue(v); + } + } + + private void WriteCompound (NBT_Compound val) + { + foreach (NBT_Tag t in val.Tags) { + WriteTag(t); + } + + NBT_Tag e = new NBT_Tag(); + WriteTag(e); + } + + private void WriteTag (NBT_Tag tag) + { + _stream.WriteByte((byte)tag.Type); + + if (tag.Type != NBT_Type.TAG_END) { + WriteString(tag.Name); + WriteValue(tag.Value); + } + } + } + + public class NBTException : Exception + { + public const String MSG_GZIP_ENDOFSTREAM = "Gzip Error: Unexpected end of stream"; + + public const String MSG_READ_NEG = "Read Error: Negative length"; + public const String MSG_READ_TYPE = "Read Error: Invalid value type"; + + public NBTException () { } + + public NBTException (String msg) : base(msg) { } + + public NBTException (String msg, Exception innerException) : base(msg, innerException) { } + } + + public class InvalidTagException : Exception { } + + public class InvalidValueException : Exception { } +} diff --git a/NBToolkit/NBToolkit/NBT/NBTTag.cs b/NBToolkit/NBToolkit/NBT/NBTTag.cs new file mode 100644 index 0000000..63a7939 --- /dev/null +++ b/NBToolkit/NBToolkit/NBT/NBTTag.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NBToolkit.NBT +{ + public class NBT_Tag + { + private NBT_String _name; + private NBT_Value _value; + + public NBT_String Name + { + get { return _name; } + set { _name = value; } + } + + public NBT_Type Type + { + get { return (_value is NBT_Value) ? _value.GetNBTType() : NBT_Type.TAG_END; } + } + + public NBT_Value Value + { + get { return _value; } + set { _value = value; } + } + + public NBT_Tag () { } + + public NBT_Tag (NBT_String name) + { + _name = name; + } + + public NBT_Tag (NBT_String name, NBT_Value value) + { + _name = name; + _value = value; + } + + public NBT_Tag FindTagByName (string name) + { + NBT_Compound cval = _value as NBT_Compound; + if (cval == null) { + throw new InvalidTagException(); + } + + return cval.FindTagByName(name); + } + + public NBT_Tag AddTag (string name, NBT_Value value) + { + NBT_Compound cval = _value as NBT_Compound; + if (cval == null) { + throw new InvalidTagException(); + } + + NBT_Tag tag = new NBT_Tag(name, value); + + cval.AddTag(tag); + return tag; + } + + public NBT_Tag AddTag (NBT_Tag tag) + { + NBT_Compound cval = _value as NBT_Compound; + if (cval == null) { + throw new InvalidTagException(); + } + + tag.AddTag(tag); + return tag; + } + + public bool RemoveTag (string name) + { + NBT_Compound cval = _value as NBT_Compound; + if (cval == null) { + throw new InvalidTagException(); + } + + return cval.RemoveTag(name); + } + } +} diff --git a/NBToolkit/NBToolkit/NBT/NBTValues.cs b/NBToolkit/NBToolkit/NBT/NBTValues.cs new file mode 100644 index 0000000..686f215 --- /dev/null +++ b/NBToolkit/NBToolkit/NBT/NBTValues.cs @@ -0,0 +1,373 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NBToolkit.NBT { + + /// + /// Describes the type of value held by an NBT_Tag + /// + public enum NBT_Type + { + TAG_END = 0, + TAG_BYTE = 1, // 8 bits signed + TAG_SHORT = 2, // 16 bits signed + TAG_INT = 3, // 32 bits signed + TAG_LONG = 4, // 64 bits signed + TAG_FLOAT = 5, + TAG_DOUBLE = 6, + TAG_BYTE_ARRAY = 7, + TAG_STRING = 8, + TAG_LIST = 9, + TAG_COMPOUND = 10 + } + + public abstract class NBT_Value + { + virtual public NBT_Byte ToNBTByte () { throw new InvalidCastException(); } + virtual public NBT_Short ToNBTShort () { throw new InvalidCastException(); } + virtual public NBT_Int ToNBTInt () { throw new InvalidCastException(); } + virtual public NBT_Long ToNBTLong () { throw new InvalidCastException(); } + virtual public NBT_Float ToNBTFloat () { throw new InvalidCastException(); } + virtual public NBT_Double ToNBTDouble () { throw new InvalidCastException(); } + virtual public NBT_ByteArray ToNBTByteArray () { throw new InvalidCastException(); } + virtual public NBT_String ToNBTString () { throw new InvalidCastException(); } + virtual public NBT_List ToNBTList () { throw new InvalidCastException(); } + virtual public NBT_Compound ToNBTCompound () { throw new InvalidCastException(); } + + virtual public NBT_Type GetNBTType () { return NBT_Type.TAG_END; } + } + + public class NBT_Byte : NBT_Value + { + private byte _data = 0; + + override public NBT_Byte ToNBTByte () { return this; } + override public NBT_Type GetNBTType () { return NBT_Type.TAG_BYTE; } + + public byte Data + { + get { return _data; } + set { _data = value; } + } + + public NBT_Byte () { } + + public NBT_Byte (byte d) + { + _data = d; + } + + public static implicit operator NBT_Byte (byte b) + { + return new NBT_Byte(b); + } + } + + public class NBT_Short : NBT_Value + { + private short _data = 0; + + override public NBT_Short ToNBTShort () { return this; } + override public NBT_Type GetNBTType () { return NBT_Type.TAG_SHORT; } + + public short Data + { + get { return _data; } + set { _data = value; } + } + + public NBT_Short () { } + + public NBT_Short (short d) + { + _data = d; + } + + public static implicit operator NBT_Short (short s) + { + return new NBT_Short(s); + } + } + + public class NBT_Int : NBT_Value + { + private int _data = 0; + + override public NBT_Int ToNBTInt () { return this; } + override public NBT_Type GetNBTType () { return NBT_Type.TAG_INT; } + + public int Data + { + get { return _data; } + set { _data = value; } + } + + public NBT_Int () { } + + public NBT_Int (int d) + { + _data = d; + } + + public static implicit operator NBT_Int (int i) + { + return new NBT_Int(i); + } + } + + public class NBT_Long : NBT_Value + { + private long _data = 0; + + override public NBT_Long ToNBTLong () { return this; } + override public NBT_Type GetNBTType () { return NBT_Type.TAG_LONG; } + + public long Data + { + get { return _data; } + set { _data = value; } + } + + public NBT_Long () { } + + public NBT_Long (long d) + { + _data = d; + } + + public static implicit operator NBT_Long (long l) + { + return new NBT_Long(l); + } + } + + public class NBT_Float : NBT_Value + { + private float _data = 0; + + override public NBT_Float ToNBTFloat () { return this; } + override public NBT_Type GetNBTType () { return NBT_Type.TAG_FLOAT; } + + public float Data + { + get { return _data; } + set { _data = value; } + } + + public NBT_Float () { } + + public NBT_Float (float d) + { + _data = d; + } + + public static implicit operator NBT_Float (float f) + { + return new NBT_Float(f); + } + } + + public class NBT_Double : NBT_Value + { + private double _data = 0; + + override public NBT_Double ToNBTDouble () { return this; } + override public NBT_Type GetNBTType () { return NBT_Type.TAG_DOUBLE; } + + public double Data + { + get { return _data; } + set { _data = value; } + } + + public NBT_Double () { } + + public NBT_Double (double d) + { + _data = d; + } + + public static implicit operator NBT_Double (double d) + { + return new NBT_Double(d); + } + } + + public class NBT_ByteArray : NBT_Value + { + private byte[] _data = null; + + override public NBT_ByteArray ToNBTByteArray () { return this; } + override public NBT_Type GetNBTType () { return NBT_Type.TAG_BYTE_ARRAY; } + + public byte[] Data + { + get { return _data; } + set { _data = value; } + } + + public int Length + { + get { return _data.Length; } + } + + public NBT_ByteArray () { } + + public NBT_ByteArray (byte[] d) + { + _data = d; + } + + public static implicit operator NBT_ByteArray (byte[] b) + { + return new NBT_ByteArray(b); + } + } + + public class NBT_String : NBT_Value + { + private string _data = null; + + override public NBT_String ToNBTString () { return this; } + override public NBT_Type GetNBTType () { return NBT_Type.TAG_STRING; } + + public string Data + { + get { return _data; } + set { _data = value; } + } + + public int Length + { + get { return _data.Length; } + } + + public NBT_String () { } + + public NBT_String (string d) + { + _data = d; + } + + public static implicit operator NBT_String (string s) + { + return new NBT_String(s); + } + } + + public class NBT_List : NBT_Value + { + private NBT_Type _type = NBT_Type.TAG_END; + + private List _items = null; + + override public NBT_List ToNBTList () { return this; } + override public NBT_Type GetNBTType () { return NBT_Type.TAG_LIST; } + + public int Count + { + get { return _items.Count; } + } + + public List Items + { + get { return _items; } + } + + public NBT_Type ValueType + { + get { return _type; } + } + + public NBT_List (NBT_Type type) + { + _type = type; + _items = new List(); + } + + public NBT_List (NBT_Type type, List items) + { + _type = type; + _items = items; + } + + public void AddItem (NBT_Value val) + { + if (_type != val.GetNBTType()) { + throw new InvalidValueException(); + } + + _items.Add(val); + } + + public void RemoveItem (int index) + { + _items.RemoveAt(index); + } + + public bool RemoveItem (NBT_Value val) + { + return _items.Remove(val); + } + } + + public class NBT_Compound : NBT_Value + { + private List _tags = null; + + override public NBT_Compound ToNBTCompound () { return this; } + override public NBT_Type GetNBTType () { return NBT_Type.TAG_COMPOUND; } + + public int Count + { + get { return _tags.Count; } + } + + public List Tags + { + get { return _tags; } + } + + public NBT_Compound () + { + _tags = new List(); + } + + public NBT_Compound (List tags) + { + _tags = tags; + } + + public void AddTag (NBT_Tag sub) + { + _tags.Add(sub); + } + + public void RemoveTag (int index) + { + _tags.RemoveAt(index); + } + + public bool RemoveTag (NBT_Tag sub) + { + return _tags.Remove(sub); + } + + public bool RemoveTag (string name) + { + return _tags.Remove(_tags.Find(v => v.Name.Data == name)); + } + + public NBT_Tag FindTagByName (string name) + { + foreach (NBT_Tag tag in _tags) { + if (tag.Name.Data == name) { + return tag; + } + } + + return null; + } + } +} \ No newline at end of file diff --git a/NBToolkit/NBToolkit/NBToolkit.csproj b/NBToolkit/NBToolkit/NBToolkit.csproj index e800cdc..1758d47 100644 --- a/NBToolkit/NBToolkit/NBToolkit.csproj +++ b/NBToolkit/NBToolkit/NBToolkit.csproj @@ -38,6 +38,8 @@ DEBUG;TRACE prompt 4 + + pdbonly @@ -46,6 +48,8 @@ TRACE prompt 4 + + @@ -63,7 +67,9 @@ - + + + diff --git a/NBToolkit/NBToolkit/Oregen.cs b/NBToolkit/NBToolkit/Oregen.cs index d6e1ad9..c42cf8a 100644 --- a/NBToolkit/NBToolkit/Oregen.cs +++ b/NBToolkit/NBToolkit/Oregen.cs @@ -2,10 +2,11 @@ using System.Collections.Generic; using System.Text; using NDesk.Options; -using NBT; namespace NBToolkit { + using NBT; + public class OregenOptions : TKOptions, IChunkFilterable { private OptionSet _filterOpt = null; diff --git a/NBToolkit/NBToolkit/Program.cs b/NBToolkit/NBToolkit/Program.cs index 29fa19a..6aaa8e2 100644 --- a/NBToolkit/NBToolkit/Program.cs +++ b/NBToolkit/NBToolkit/Program.cs @@ -1,10 +1,11 @@ using System; using System.Collections.Generic; using System.Text; -using NBT; namespace NBToolkit { + using NBT; + class Program { static void Main (string[] args) diff --git a/NBToolkit/NBToolkit/Purge.cs b/NBToolkit/NBToolkit/Purge.cs index 5c86311..82365e0 100644 --- a/NBToolkit/NBToolkit/Purge.cs +++ b/NBToolkit/NBToolkit/Purge.cs @@ -2,10 +2,11 @@ using System.Collections.Generic; using System.Text; using NDesk.Options; -using NBT; namespace NBToolkit { + using NBT; + public class PurgeOptions : TKOptions, IChunkFilterable { private OptionSet _filterOpt = null; diff --git a/NBToolkit/NBToolkit/Region.cs b/NBToolkit/NBToolkit/Region.cs index f6f2f55..36a30e8 100644 --- a/NBToolkit/NBToolkit/Region.cs +++ b/NBToolkit/NBToolkit/Region.cs @@ -3,10 +3,11 @@ using System.Collections.Generic; using System.Text; using System.Text.RegularExpressions; using System.IO; -using NBT; namespace NBToolkit { + using NBT; + public class Region : IDisposable { protected int _rx; diff --git a/NBToolkit/NBToolkit/Replace.cs b/NBToolkit/NBToolkit/Replace.cs index 2af3b67..0f12c71 100644 --- a/NBToolkit/NBToolkit/Replace.cs +++ b/NBToolkit/NBToolkit/Replace.cs @@ -2,10 +2,11 @@ using System.Collections.Generic; using System.Text; using NDesk.Options; -using NBT; namespace NBToolkit { + using NBT; + public class ReplaceOptions : TKOptions, IChunkFilterable { private OptionSet _filterOpt = null; diff --git a/NBToolkit/NBToolkit/TKFilter.cs b/NBToolkit/NBToolkit/TKFilter.cs index 2f4e0cf..61b5de5 100644 --- a/NBToolkit/NBToolkit/TKFilter.cs +++ b/NBToolkit/NBToolkit/TKFilter.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Text; -using NBT; namespace NBToolkit {