Example #1
0
        public Furnace(int CX, int CY, int CS, LibNbt.Tags.NbtCompound c)
            : base(CX, CY, CS, c)
        {
            BurnTime = (c["BurnTime"] as NbtShort).Value;
            CookTime = (c["CookTime"] as NbtShort).Value;

            for (int i = 0; i < Slots.Length; i++)
            {
                try
                {
                    if ((c["Items"] as NbtList).Tags[i] != null)
                    {
                        NbtCompound cc = (NbtCompound)(c["Items"] as NbtList).Tags[i];
                        Slots[i]        = new InventoryItem();
                        Slots[i].ID     = cc.Get <NbtShort>("id").Value;
                        Slots[i].Damage = cc.Get <NbtShort>("Damage").Value;
                        Slots[i].Slot   = 0;
                        Slots[i].Count  = cc.Get <NbtByte>("Count").Value;
                    }
                }
                catch (Exception)
                {
                }
            }
        }
Example #2
0
 public Chest(int CX, int CY, int CS, LibNbt.Tags.NbtCompound c)
     : base(CX, CY, CS, c)
 {
     foreach (NbtCompound item in (c["Items"] as NbtList).Tags)
     {
         //NbtCompound item = (NbtCompound)itm;
         Inventory.Add(item);
     }
 }
Example #3
0
 public Sign(LibNbt.Tags.NbtCompound c)
     : base(c)
 {
     for (int i = 0; i < 4; i++)
     {
         string tagID = string.Format("Text{0}", i + 1);
         Text[i] = c.Get <NbtString>(tagID).Value;
     }
 }
Example #4
0
 public Chest(LibNbt.Tags.NbtCompound c)
     : base(c)
 {
     for (int i = 0; i < 54; i++)
     {
         try
         {
             NbtCompound item = (NbtCompound)(c["Items"] as NbtList)[i];
             Inventory.Add(item);
         }
         catch (Exception)
         {
         }
     }
 }
Example #5
0
 public MobSpawner(int CX, int CY, int CS, LibNbt.Tags.NbtCompound c)
     : base(CX, CY, CS, c)
 {
     EntityId = (c["EntityId"] as NbtString).Value;
     Delay    = (c["Delay"] as NbtShort).Value;
 }
Example #6
0
 public MobSpawner(LibNbt.Tags.NbtCompound c)
     : base(c)
 {
     EntityId = (c["EntityId"] as NbtString).Value;
     Delay    = (c["Delay"] as NbtShort).Value;
 }
Example #7
0
        internal override void ReadTag(Stream readStream, bool readName)
        {
            // First read the name of this tag
            Name = "";
            if (readName)
            {
                var name = new NbtString();
                name.ReadTag(readStream, false);

                Name = name.Value;
            }

            var tagId = new NbtByte();

            tagId.ReadTag(readStream, false);
            Type     = (NbtTagType)tagId.Value;
            ListType = Type;

            var length = new NbtInt();

            length.ReadTag(readStream, false);

            Tags.Clear();
            for (int idx = 0; idx < length.Value; idx++)
            {
                switch ((NbtTagType)tagId.Value)
                {
                case NbtTagType.TAG_Byte:
                    var nextByte = new NbtByte();
                    nextByte.ReadTag(readStream, false);
                    Tags.Add(nextByte);
                    break;

                case NbtTagType.TAG_Short:
                    var nextShort = new NbtShort();
                    nextShort.ReadTag(readStream, false);
                    Tags.Add(nextShort);
                    break;

                case NbtTagType.TAG_Int:
                    var nextInt = new NbtInt();
                    nextInt.ReadTag(readStream, false);
                    Tags.Add(nextInt);
                    break;

                case NbtTagType.TAG_Long:
                    var nextLong = new NbtLong();
                    nextLong.ReadTag(readStream, false);
                    Tags.Add(nextLong);
                    break;

                case NbtTagType.TAG_Float:
                    var nextFloat = new NbtFloat();
                    nextFloat.ReadTag(readStream, false);
                    Tags.Add(nextFloat);
                    break;

                case NbtTagType.TAG_Double:
                    var nextDouble = new NbtDouble();
                    nextDouble.ReadTag(readStream, false);
                    Tags.Add(nextDouble);
                    break;

                case NbtTagType.TAG_Byte_Array:
                    var nextByteArray = new NbtByteArray();
                    nextByteArray.ReadTag(readStream, false);
                    Tags.Add(nextByteArray);
                    break;

                case NbtTagType.TAG_String:
                    var nextString = new NbtString();
                    nextString.ReadTag(readStream, false);
                    Tags.Add(nextString);
                    break;

                case NbtTagType.TAG_List:
                    var nextList = new NbtList();
                    nextList.ReadTag(readStream, false);
                    Tags.Add(nextList);
                    break;

                case NbtTagType.TAG_Compound:
                    var nextCompound = new NbtCompound();
                    nextCompound.ReadTag(readStream, false);
                    Tags.Add(nextCompound);
                    break;
                }
            }
        }
Example #8
0
        internal override void ReadTag(Stream readStream, bool readName)
        {
            // First read the name of this tag
            Name = "";
            if (readName)
            {
                var name = new NbtString();
                name.ReadTag(readStream, false);

                Name = name.Value;
            }

            mTags.Clear();
            bool          foundEnd = false;
            List <NbtTag> buffer   = new List <NbtTag>();

            while (!foundEnd)
            {
                int nextTag = readStream.ReadByte();
                switch ((NbtTagType)nextTag)
                {
                case NbtTagType.TAG_End:
                    foundEnd = true;
                    break;

                case NbtTagType.TAG_Byte:
                    var nextByte = new NbtByte();
                    nextByte.ReadTag(readStream);
                    Add(nextByte.Name, nextByte);
                    break;

                case NbtTagType.TAG_Short:
                    var nextShort = new NbtShort();
                    nextShort.ReadTag(readStream);
                    Add(nextShort.Name, nextShort);
                    break;

                case NbtTagType.TAG_Int:
                    var nextInt = new NbtInt();
                    nextInt.ReadTag(readStream);
                    Add(nextInt.Name, nextInt);
                    break;

                case NbtTagType.TAG_Long:
                    var nextLong = new NbtLong();
                    nextLong.ReadTag(readStream);
                    Add(nextLong.Name, nextLong);
                    break;

                case NbtTagType.TAG_Float:
                    var nextFloat = new NbtFloat();
                    nextFloat.ReadTag(readStream);
                    Add(nextFloat.Name, nextFloat);
                    break;

                case NbtTagType.TAG_Double:
                    var nextDouble = new NbtDouble();
                    nextDouble.ReadTag(readStream);
                    Add(nextDouble.Name, nextDouble);
                    break;

                case NbtTagType.TAG_Byte_Array:
                    var nextByteArray = new NbtByteArray();
                    nextByteArray.ReadTag(readStream);
                    Add(nextByteArray.Name, nextByteArray);
                    break;

                case NbtTagType.TAG_String:
                    var nextString = new NbtString();
                    nextString.ReadTag(readStream);
                    Add(nextString.Name, nextString);
                    break;

                case NbtTagType.TAG_List:
                    var nextList = new NbtList();
                    nextList.ReadTag(readStream);
                    Add(nextList.Name, nextList);
                    break;

                case NbtTagType.TAG_Compound:
                    var nextCompound = new NbtCompound();
                    nextCompound.ReadTag(readStream);
                    Add(nextCompound.Name, nextCompound);
                    break;

                default:
                    Console.WriteLine(string.Format("Unsupported Tag Found: {0}", nextTag));
                    break;
                }
            }
        }