Esempio n. 1
0
        internal static void ReadContainers(BinaryReader reader)
        {
            byte[] flags = new byte[1];

            reader.Read(flags, 0, reader.ReadByte());

            if ((flags[0] & 1) == 1)
            {
                var tables = ContainerTables.Create();
                int count  = reader.ReadUInt16();

                for (int k = 0; k < count; k++)
                {
                    int    slot    = reader.ReadUInt16();
                    string modName = reader.ReadString();
                    string name    = reader.ReadString();
                    Mod    mod     = ModLoader.GetMod(modName);

                    tables.headSlots[slot] = mod?.GetItem(name).item.headSlot ?? 0;
                }

                count = reader.ReadUInt16();

                for (int k = 0; k < count; k++)
                {
                    int    slot    = reader.ReadUInt16();
                    string modName = reader.ReadString();
                    string name    = reader.ReadString();
                    Mod    mod     = ModLoader.GetMod(modName);

                    tables.bodySlots[slot] = mod?.GetItem(name).item.bodySlot ?? 0;
                }

                count = reader.ReadUInt16();

                for (int k = 0; k < count; k++)
                {
                    int    slot    = reader.ReadUInt16();
                    string modName = reader.ReadString();
                    string name    = reader.ReadString();
                    Mod    mod     = ModLoader.GetMod(modName);

                    tables.legSlots[slot] = mod?.GetItem(name).item.legSlot ?? 0;
                }

                ReadContainerData(reader, tables);
            }

            //legacy load //Let's not care anymore.

            /*if ((flags[0] & 2) == 2) {
             *      int count = reader.ReadInt32();
             *      for (int k = 0; k < count; k++) {
             *              int id = reader.ReadInt32();
             *              TEItemFrame itemFrame = TileEntity.ByID[id] as TEItemFrame;
             *              ItemIO.LoadLegacy(itemFrame.item, reader, true);
             *      }
             * }*/
        }
Esempio n. 2
0
 internal static void ReadContainers(BinaryReader reader)
 {
     byte[] flags = new byte[1];
     reader.Read(flags, 0, reader.ReadByte());
     if ((flags[0] & 1) == 1)
     {
         ContainerTables tables = ContainerTables.Create();
         int             count  = reader.ReadUInt16();
         for (int k = 0; k < count; k++)
         {
             int    slot    = reader.ReadUInt16();
             string modName = reader.ReadString();
             string name    = reader.ReadString();
             Mod    mod     = ModLoader.GetMod(modName);
             tables.headSlots[slot] = mod == null ? 0 : mod.GetItem(name).item.headSlot;
         }
         count = reader.ReadUInt16();
         for (int k = 0; k < count; k++)
         {
             int    slot    = reader.ReadUInt16();
             string modName = reader.ReadString();
             string name    = reader.ReadString();
             Mod    mod     = ModLoader.GetMod(modName);
             tables.bodySlots[slot] = mod == null ? 0 : mod.GetItem(name).item.bodySlot;
         }
         count = reader.ReadUInt16();
         for (int k = 0; k < count; k++)
         {
             int    slot    = reader.ReadUInt16();
             string modName = reader.ReadString();
             string name    = reader.ReadString();
             Mod    mod     = ModLoader.GetMod(modName);
             tables.legSlots[slot] = mod == null ? 0 : mod.GetItem(name).item.legSlot;
         }
         ReadContainerData(reader, tables);
     }
     if ((flags[0] & 2) == 2)
     {
         int count = reader.ReadInt32();
         for (int k = 0; k < count; k++)
         {
             int         id        = reader.ReadInt32();
             TEItemFrame itemFrame = TileEntity.ByID[id] as TEItemFrame;
             ItemIO.ReadModItem(itemFrame.item, reader);
             itemFrame.item.stack = reader.ReadInt32();
         }
     }
 }
Esempio n. 3
0
        internal static void ReadContainers(BinaryReader reader)
        {
            byte[] flags = new byte[1];

            reader.Read(flags, 0, reader.ReadByte());

            if ((flags[0] & 1) == 1)
            {
                var tables = ContainerTables.Create();
                int count  = reader.ReadUInt16();

                for (int k = 0; k < count; k++)
                {
                    tables.headSlots[reader.ReadUInt16()] = ModContent.TryFind(reader.ReadString(), reader.ReadString(), out ModItem item) ? item.item.headSlot : 0;
                }

                count = reader.ReadUInt16();

                for (int k = 0; k < count; k++)
                {
                    tables.bodySlots[reader.ReadUInt16()] = ModContent.TryFind(reader.ReadString(), reader.ReadString(), out ModItem item) ? item.item.bodySlot : 0;
                }

                count = reader.ReadUInt16();

                for (int k = 0; k < count; k++)
                {
                    tables.legSlots[reader.ReadUInt16()] = ModContent.TryFind(reader.ReadString(), reader.ReadString(), out ModItem item) ? item.item.legSlot : 0;
                }

                ReadContainerData(reader, tables);
            }

            //legacy load //Let's not care anymore.

            /*if ((flags[0] & 2) == 2) {
             *      int count = reader.ReadInt32();
             *      for (int k = 0; k < count; k++) {
             *              int id = reader.ReadInt32();
             *              TEItemFrame itemFrame = TileEntity.ByID[id] as TEItemFrame;
             *              ItemIO.LoadLegacy(itemFrame.item, reader, true);
             *      }
             * }*/
        }