Esempio n. 1
0
            public override void CustomLoadQuest(string QuestKey, TagCompound Reader, int ModVersion)
            {
                byte questver = Reader.GetByte(QuestKey + "qver");

                QuestStep   = Reader.GetByte(QuestKey + "qstep");
                SardineFell = Reader.GetBool(QuestKey + "sardinefell");
            }
Esempio n. 2
0
        public override void Load(TagCompound tag)
        {
            if (!tag.ContainsKey("EmitterMode"))
            {
                return;
            }

            try {
                this.SetDefinition(new EmitterDefinition(
                                       isGoreMode: tag.GetBool("EmitterMode"),
                                       type: tag.GetInt("EmitterType"),
                                       scale: tag.GetFloat("EmitterScale"),
                                       delay: tag.GetInt("EmitterDelay"),
                                       speedX: tag.GetFloat("EmitterSpeedX"),
                                       speedY: tag.GetFloat("EmitterSpeedY"),
                                       color: new Color(
                                           tag.GetByte("EmitterColorR"),
                                           tag.GetByte("EmitterColorG"),
                                           tag.GetByte("EmitterColorB")
                                           ),
                                       transparency: tag.GetByte("EmitterAlpha"),
                                       scatter: tag.GetFloat("EmitterScatter"),
                                       hasGravity: tag.GetBool("EmitterHasGrav"),
                                       hasLight: tag.GetBool("EmitterHasLight"),
                                       isActivated: tag.GetBool("EmitterIsActivated")
                                       ));
            } catch { }
        }
Esempio n. 3
0
            public override void CustomLoadQuest(string QuestKey, TagCompound Reader, int ModVersion)
            {
                byte LastVer = Reader.GetByte(QuestKey + "questver");

                QuestStep       = Reader.GetByte(QuestKey + "qstep");
                FishGiven       = Reader.GetByte(QuestKey + "qfish");
                ConclusionState = Reader.GetByte(QuestKey + "qconc");
            }
Esempio n. 4
0
            public override void CustomLoadQuest(string QuestKey, TagCompound Reader, int ModVersion)
            {
                int Version = Reader.GetInt(QuestKey + "_Version");

                LunaTalkedAboutTutorial = Reader.GetBool(QuestKey + "_TalkedAboutTuto");
                CallingStep             = Reader.GetByte(QuestKey + "_CallTutoStep");
                OrderTutorialStep       = Reader.GetByte(QuestKey + "_OrderTutoStep");
                TalkedAboutTentants     = Reader.GetBool(QuestKey + "_TenantTutoStep");
            }
Esempio n. 5
0
            public override void CustomLoadQuest(string QuestKey, TagCompound Reader, int ModVersion)
            {
                short Version = Reader.GetShort(QuestKey + "_Version");

                QuestStep = Reader.GetByte(QuestKey + "_Step");
                if (Version > 0)
                {
                    ZacksKnowsWhoPickedShirt = Reader.GetByte(QuestKey + "_ZacksKnowOfShirt");
                }
            }
Esempio n. 6
0
 public TileData(TagCompound tag)
 {
     id     = tag.Get <ushort>("id");
     wall   = tag.Get <ushort>("wall");
     active = tag.GetBool("active");
     liq    = tag.GetByte("liq");
     ltype  = tag.GetByte("ltype");
     slope  = tag.GetByte("slope");
     frameX = tag.GetShort("frameX");
     frameY = tag.GetShort("frameY");
 }
            public override void CustomLoadQuest(string QuestKey, TagCompound Reader, int ModVersion)
            {
                int Version = Reader.GetInt("Version");

                if (Version > 0)
                {
                    BlueDialogueStep    = Reader.GetByte("BlueDialogueStep");
                    BlueWasPresent      = Reader.GetBool("BlueWasPresent");
                    SpokeToBluePosQuest = Reader.GetBool("SpokeToBluePosQuest");
                    SpottedZacksOnce    = Reader.GetByte("SpottedZacksonce");
                }
            }
Esempio n. 8
0
        ////////////////

        internal void Load(BetterPaintMod mymod, TagCompound tags, string prefix)
        {
            var myworld = ModContent.GetInstance <BetterPaintWorld>();

            this.Colors.Clear();
            this.Glows.Clear();

            if (tags.ContainsKey(prefix + "_x"))
            {
                int[] fgX = tags.GetIntArray(prefix + "_x");

                for (int i = 0; i < fgX.Length; i++)
                {
                    ushort tileX = (ushort)fgX[i];
                    int[]  fgY   = tags.GetIntArray(prefix + "_" + tileX + "_y");

                    for (int j = 0; j < fgY.Length; j++)
                    {
                        ushort tileY = (ushort)fgY[j];

                        byte[] clrArr = tags.GetByteArray(prefix + "_" + tileX + "_" + tileY);
                        Color  color  = new Color(clrArr[0], clrArr[1], clrArr[2], clrArr[3]);

                        Tile tile = Main.tile[tileX, tileY];

                        if (this.CanPaintAt(tile))
                        {
                            this.SetRawColorAt(color, tileX, tileY);
                        }
                    }
                }
            }

            if (tags.ContainsKey(prefix + "_g_x"))
            {
                int[] fgX = tags.GetIntArray(prefix + "_g_x");

                for (int i = 0; i < fgX.Length; i++)
                {
                    ushort tileX = (ushort)fgX[i];
                    int[]  fgY   = tags.GetIntArray(prefix + "_g_" + tileX + "_y");

                    for (int j = 0; j < fgY.Length; j++)
                    {
                        ushort tileY = (ushort)fgY[j];

                        byte glow = tags.GetByte(prefix + "_g_" + tileX + "_" + tileY);

                        Tile tile = Main.tile[tileX, tileY];

                        if (this.CanPaintAt(tile))
                        {
                            this.SetGlowAt(glow, tileX, tileY);
                        }
                    }
                }
            }
        }
Esempio n. 9
0
            public override void CustomLoadQuest(string QuestKey, TagCompound Reader, int ModVersion)
            {
                int Version = Reader.GetInt("Version");

                if (Version > 0)
                {
                    QuestStep  = Reader.GetByte("Step");
                    TimePassed = Reader.GetFloat("Time");
                }
            }
Esempio n. 10
0
 public static TurtleInfo Load(TagCompound tag)
 {
     return(new TurtleInfo(
                tag.Get <ushort>("Width"),
                tag.Get <ushort>("Height"),
                tag.GetByte("Direction"),
                tag.GetInt("PickaxeType"),
                tag.GetInt("PickaxePower"),
                tag.GetInt("PickaxeSpeed")
                ));
 }
Esempio n. 11
0
        public static ItemModel Load(TagCompound tag)
        {
            var item = tag.Get <Item>("item");

            return(new ItemModel {
                ItemType = item.type,
                Name = item.Name,
                InventoryIndex = tag.GetInt(nameof(InventoryIndex)),
                SummonCount = tag.GetByte(nameof(SummonCount)),
                Active = tag.GetBool(nameof(Active))
            });
        }
Esempio n. 12
0
            public override void CustomLoadQuest(string QuestKey, TagCompound Reader, int ModVersion)
            {
                byte Version = Reader.GetByte(QuestKey + "_Version");

                for (int i = 0; i < 4; i++)
                {
                    SolidificationRequestGiven[i] = Reader.GetBool(QuestKey + "_SolReq_" + i);
                    SolidificationUnlocked[i]     = Reader.GetBool(QuestKey + "_SolUnlock_" + 1);
                }
                SpokeToLeopoldAboutTheEmotionalPigs = Reader.GetBool(QuestKey + "_LeopoldKnows");
                UnlockedBland = Reader.GetBool(QuestKey + "_BlandUnlocked");
            }
Esempio n. 13
0
 public static TileSaveData DeserializeData(TagCompound tag)
 {
     return(new TileSaveData(
                tag.GetBool("Active"),
                tag.GetString("Tile"),
                tag.GetString("Wall"),
                tag.GetShort("FrameX"),
                tag.GetShort("FrameY"),
                tag.GetShort("WFrameX"),
                tag.GetShort("WFrameY"),
                tag.GetByte("Slope"),
                tag.GetBool("HalfSlab"),
                tag.GetBool("HasActuator"),
                tag.GetBool("Actuated"),
                tag.GetByte("Liquid"),
                tag.GetByte("LiquidType"),
                tag.GetByte("Color"),
                tag.GetByte("WallColor"),
                tag.GetByteArray("Wire"),
                tag.GetString("TEType"),
                tag.Get <TagCompound>("TEData")
                ));
 }
Esempio n. 14
0
        private void LoadPartySlot(Item modItem, TagCompound value)
        {
            //var modItem = ((TerramonMod)mod).PartySlots.partyslot1.Item.modItem;
            var en = (TerramonMod.PokeballFactory.Pokebals)value.GetByte(BaseCaughtClass.POKEBAL_PROPERTY);

            if (en == 0)
            {
                modItem.TurnToAir();
            }
            else
            {
                modItem.SetDefaults(TerramonMod.PokeballFactory.GetPokeballType(en));
                modItem.modItem.Load(value);
            }
        }
Esempio n. 15
0
        public void GetByte_returns_null_item()
        {
            // arrange
            TagCompound target;
            Tag         actual;
            string      name;

            name = "alpha";

            target = new TagCompound();

            // act
            actual = target.GetByte(name);

            // assert
            Assert.IsNull(actual);
        }
Esempio n. 16
0
        public static PlayerPreset LoadTag(TagCompound tag)
        {
            var pre = new PlayerPreset
            {
                //preview = tag.Get<Player>("preview"),
                hairDye   = tag.GetByte("hairDye"),
                variant   = tag.GetInt("variant"),
                colors    = tag.Get <List <Color> >("colors"),
                armor     = tag.Get <List <Item> >("armor"),
                dye       = tag.Get <List <Item> >("dye"),
                hairStyle = tag.GetInt("hairStyle"),
                male      = tag.GetBool("male"),
                made      = tag.GetBool("made"),
                name      = tag.GetString("name")
            };

            return(pre);
        }
Esempio n. 17
0
        public void GetByte_returns_existing_tag()
        {
            // arrange
            TagCompound target;
            Tag         actual;
            string      name;

            name = "alpha";

            target = new TagCompound();
            target.Value.Add(name, (byte)(byte.MaxValue >> 1));

            // act
            actual = target.GetByte(name);

            // assert
            Assert.IsNotNull(actual);
            Assert.IsInstanceOf <TagByte>(actual);
        }
Esempio n. 18
0
        public override void Load(TagCompound tag)
        {
            peatSold  = tag.GetAsInt("peatSold");
            worldEvil = tag.GetByte("worldEvil");
            if (tag.ContainsKey("worldSurfaceLow"))
            {
                _worldSurfaceLow = tag.GetDouble("worldSurfaceLow");
            }
            if (tag.ContainsKey("defiledHearts"))
            {
                Defiled_Hearts = tag.Get <List <Vector2> >("defiledHearts").Select(Utils.ToPoint).ToList();
            }

            defiledResurgenceTiles = new List <(int, int)>()
            {
            };
            defiledAltResurgenceTiles = new List <(int, int, ushort)>()
            {
            };
        }
Esempio n. 19
0
        public static void Load(Item item, TagCompound tag)
        {
            if (tag.Count == 0)
            {
                item.netDefaults(0);
                return;
            }

            string modName = tag.GetString("mod");
            if (modName == "Terraria")
            {
                item.netDefaults(tag.GetInt("id"));
                if (tag.HasTag("legacyData"))
                    LoadLegacyModData(item, tag.GetByteArray("legacyData"), tag.GetBool("hasGlobalSaving"));
            }
            else
            {
                int type = ModLoader.GetMod(modName)?.ItemType(tag.GetString("name")) ?? 0;
                if (type > 0)
                {
                    item.netDefaults(type);
                    if (tag.HasTag("legacyData"))
                        LoadLegacyModData(item, tag.GetByteArray("legacyData"), tag.GetBool("hasGlobalSaving"));
                    else
                        item.modItem.Load(tag.GetCompound("data"));
                }
                else
                {
                    item.netDefaults(ModLoader.GetMod("ModLoader").ItemType("MysteryItem"));
                    ((MysteryItem)item.modItem).Setup(tag);
                }
            }

            item.Prefix(tag.GetByte("prefix"));
            item.stack = tag.GetTag<int?>("stack") ?? 1;
            item.favorited = tag.GetBool("fav");

            if (!(item.modItem is MysteryItem))
                LoadGlobals(item, tag.GetList<TagCompound>("globalData"));
        }
Esempio n. 20
0
        ////////////////

        public override void Load(TagCompound tags)
        {
            try {
                if (tags.ContainsKey("lives"))
                {
                    this.IsLoaded = true;

                    this.IsImmortal         = tags.GetBool("is_immortal");
                    this.Lives              = tags.GetInt("lives");
                    this.Deaths             = tags.GetInt("lives_lost");
                    this.OriginalDifficulty = tags.GetByte("difficulty");
                }
                if (tags.ContainsKey("continues"))
                {
                    this.ContinuesUsed = tags.GetInt("continues");
                }

                this.UpdateMortality();
            } catch (Exception e) {
                LogHelpers.Log(e.ToString());
            }
        }
        public override void LoadData(TagCompound tag)
        {
            var  items      = tag.GetList <TagCompound>("items").Select(ItemIO.Load).ToArray();
            var  dyes       = tag.GetList <TagCompound>("dyes").Select(ItemIO.Load).ToArray();
            byte hideVisual = tag.GetByte("hideVisual");

            var slots = ContentInstance <UtilitySlot> .Instances;

            for (int i = 0; i < Player.SupportedSlotsAccs; i++)
            {
                var slot = slots[i];
                if (i < items.Length)
                {
                    slot.FunctionalItem = items[i];
                }
                if (i < dyes.Length)
                {
                    slot.DyeItem = dyes[i];
                }
                slot.HideVisuals |= (hideVisual & (1 << i)) != 0;
            }
        }
Esempio n. 22
0
        public void TestAnvilRegion()
        {
            string     filename = this.AnvilRegionFileName;
            FileStream input    = File.OpenRead(filename);

            int[]  locations = new int[1024];
            byte[] buffer    = new byte[4096];
            input.Read(buffer, 0, 4096);
            for (int i = 0; i < 1024; i++)
            {
                locations[i] = BitConverter.ToInt32(buffer, i * 4);
            }

            int[] timestamps = new int[1024];
            input.Read(buffer, 0, 4096);
            for (int i = 0; i < 1024; i++)
            {
                timestamps[i] = BitConverter.ToInt32(buffer, i * 4);
            }

            input.Read(buffer, 0, 4);
            if (BitConverter.IsLittleEndian)
            {
                BitHelper.SwapBytes(buffer, 0, 4);
            }
            int sizeOfChunkData = BitConverter.ToInt32(buffer, 0) - 1;

            int compressionType = input.ReadByte();

            buffer = new byte[sizeOfChunkData];
            input.Read(buffer, 0, sizeOfChunkData);

            Stream inputStream = null;

            if (compressionType == 1)
            {
                inputStream = new GZipStream(new MemoryStream(buffer), CompressionMode.Decompress);
            }
            else if (compressionType == 2)
            {
                inputStream = new DeflateStream(new MemoryStream(buffer, 2, buffer.Length - 6), CompressionMode.Decompress);
            }

            TagReader reader;

            reader = new BinaryTagReader(inputStream);
            TagCompound tag    = (TagCompound)reader.ReadTag();
            string      strTag = tag.ToString();

            Assert.IsNotNull(tag);

            Assert.AreEqual(TagType.Compound, tag.GetTag("Level").Type);
            TagCompound levelTag = tag.GetCompound("Level");

            Tag aTag = levelTag.GetTag("Entities");

            Assert.AreEqual(TagType.List, aTag.Type);
            TagList entitiesTag = aTag as TagList;

            Assert.AreEqual(0, entitiesTag.Value.Count);

            aTag = levelTag.GetTag("Biomes");
            Assert.AreEqual(TagType.ByteArray, aTag.Type);
            TagByteArray biomesTag = aTag as TagByteArray;

            Assert.AreEqual(256, biomesTag.Value.Length);

            aTag = levelTag.GetTag("LastUpdate");
            Assert.AreEqual(TagType.Long, aTag.Type);
            TagLong lastUpdateTag = aTag as TagLong;

            Assert.AreEqual(2861877, lastUpdateTag.Value);

            aTag = levelTag.GetTag("xPos");
            Assert.AreEqual(TagType.Int, aTag.Type);
            TagInt xPosTag = aTag as TagInt;

            Assert.AreEqual(10, xPosTag.Value);

            aTag = levelTag.GetTag("zPos");
            Assert.AreEqual(TagType.Int, aTag.Type);
            TagInt zPosTag = aTag as TagInt;

            Assert.AreEqual(0, zPosTag.Value);

            aTag = levelTag.GetTag("TileEntities");
            Assert.AreEqual(TagType.List, aTag.Type);
            TagList tileEntitiesTag = aTag as TagList;

            Assert.AreEqual(0, tileEntitiesTag.Value.Count);

            aTag = levelTag.GetTag("TerrainPopulated");
            Assert.AreEqual(TagType.Byte, aTag.Type);
            TagByte terrainPopulatedTag = aTag as TagByte;

            Assert.AreEqual(1, terrainPopulatedTag.Value);

            aTag = levelTag.GetTag("HeightMap");
            Assert.AreEqual(TagType.IntArray, aTag.Type);
            TagIntArray heightmapTag = aTag as TagIntArray;

            Assert.AreEqual(256, heightmapTag.Value.Length);

            aTag = levelTag.GetTag("Sections");
            Assert.AreEqual(TagType.List, aTag.Type);
            TagList sectionsTag = aTag as TagList;

            Assert.AreEqual(4, sectionsTag.Value.Count);

            TagCompound section_0 = sectionsTag.Value[0] as TagCompound;

            Assert.IsNotNull(section_0);
            TagByteArray section_0_data = section_0.GetByteArray("Data");

            Assert.IsNotNull(section_0_data);
            Assert.AreEqual(2048, section_0_data.Value.Length);
            TagByteArray section_0_skyLight = section_0.GetByteArray("SkyLight");

            Assert.IsNotNull(section_0_skyLight);
            Assert.AreEqual(2048, section_0_skyLight.Value.Length);
            TagByteArray section_0_blockLight = section_0.GetByteArray("BlockLight");

            Assert.IsNotNull(section_0_blockLight);
            Assert.AreEqual(2048, section_0_blockLight.Value.Length);
            TagByte section_0_y = section_0.GetByte("Y");

            Assert.IsNotNull(section_0_y);
            Assert.AreEqual(0, section_0_y.Value);
            TagByteArray section_0_blocks = section_0.GetByteArray("Blocks");

            Assert.IsNotNull(section_0_blocks);
            Assert.AreEqual(4096, section_0_blocks.Value.Length);

            TagCompound section_1 = sectionsTag.Value[1] as TagCompound;

            Assert.IsNotNull(section_1);
            TagByteArray section_1_data = section_1.GetByteArray("Data");

            Assert.IsNotNull(section_1_data);
            Assert.AreEqual(2048, section_1_data.Value.Length);
            TagByteArray section_1_skyLight = section_1.GetByteArray("SkyLight");

            Assert.IsNotNull(section_1_skyLight);
            Assert.AreEqual(2048, section_1_skyLight.Value.Length);
            TagByteArray section_1_blockLight = section_1.GetByteArray("BlockLight");

            Assert.IsNotNull(section_1_blockLight);
            Assert.AreEqual(2048, section_1_blockLight.Value.Length);
            TagByte section_1_y = section_1.GetByte("Y");

            Assert.IsNotNull(section_1_y);
            Assert.AreEqual(1, section_1_y.Value);
            TagByteArray section_1_blocks = section_1.GetByteArray("Blocks");

            Assert.IsNotNull(section_1_blocks);
            Assert.AreEqual(4096, section_1_blocks.Value.Length);

            TagCompound section_2 = sectionsTag.Value[2] as TagCompound;

            Assert.IsNotNull(section_2);
            TagByteArray section_2_data = section_2.GetByteArray("Data");

            Assert.IsNotNull(section_2_data);
            Assert.AreEqual(2048, section_2_data.Value.Length);
            TagByteArray section_2_skyLight = section_2.GetByteArray("SkyLight");

            Assert.IsNotNull(section_2_skyLight);
            Assert.AreEqual(2048, section_2_skyLight.Value.Length);
            TagByteArray section_2_blockLight = section_2.GetByteArray("BlockLight");

            Assert.IsNotNull(section_2_blockLight);
            Assert.AreEqual(2048, section_2_blockLight.Value.Length);
            TagByte section_2_y = section_2.GetByte("Y");

            Assert.IsNotNull(section_2_y);
            Assert.AreEqual(2, section_2_y.Value);
            TagByteArray section_2_blocks = section_2.GetByteArray("Blocks");

            Assert.IsNotNull(section_2_blocks);
            Assert.AreEqual(4096, section_2_blocks.Value.Length);

            TagCompound section_3 = sectionsTag.Value[3] as TagCompound;

            Assert.IsNotNull(section_3);
            TagByteArray section_3_data = section_3.GetByteArray("Data");

            Assert.IsNotNull(section_3_data);
            Assert.AreEqual(2048, section_3_data.Value.Length);
            TagByteArray section_3_skyLight = section_3.GetByteArray("SkyLight");

            Assert.IsNotNull(section_3_skyLight);
            Assert.AreEqual(2048, section_3_skyLight.Value.Length);
            TagByteArray section_3_blockLight = section_3.GetByteArray("BlockLight");

            Assert.IsNotNull(section_3_blockLight);
            Assert.AreEqual(2048, section_3_blockLight.Value.Length);
            TagByte section_3_y = section_3.GetByte("Y");

            Assert.IsNotNull(section_3_y);
            Assert.AreEqual(3, section_3_y.Value);
            TagByteArray section_3_blocks = section_3.GetByteArray("Blocks");

            Assert.IsNotNull(section_3_blocks);
            Assert.AreEqual(4096, section_3_blocks.Value.Length);
        }
Esempio n. 23
0
 public override void Load(TagCompound tag)
 {
     lureCount = tag.GetByte(LURE_COUNT);
 }
Esempio n. 24
0
        private void TestNbt(TagCompound compoundTag)
        {
            var byteMin = compoundTag.GetByte("byte_min");

            Assert.AreEqual(-128, byteMin.Value);
            var byteMax = compoundTag.GetByte("byte_max");

            Assert.AreEqual(127, byteMax.Value);

            var shortMin = compoundTag.GetShort("short_min");

            Assert.AreEqual(-32768, shortMin.Value);
            var shortMax = compoundTag.GetShort("short_max");

            Assert.AreEqual(32767, shortMax.Value);

            var intMin = compoundTag.GetInt("int_min");

            Assert.AreEqual(-2147483648, intMin.Value);
            var intMax = compoundTag.GetInt("int_max");

            Assert.AreEqual(2147483647, intMax.Value);

            var longMin = compoundTag.GetLong("long_min");

            Assert.AreEqual(-9223372036854775808, longMin.Value);
            var longMax = compoundTag.GetLong("long_max");

            Assert.AreEqual(9223372036854775807, longMax.Value);

            var floatTag = compoundTag.GetFloat("float");

            Assert.AreEqual(12345.6f, floatTag.Value);

            var doubleTag = compoundTag.GetDouble("double");

            Assert.AreEqual(12345.6, doubleTag.Value);

            var byteArray = compoundTag.GetByteArray("byte_array");

            Assert.AreEqual(3, byteArray.Value.Length);
            Assert.AreEqual(0x12, byteArray.Value[0]);
            Assert.AreEqual(0x34, byteArray.Value[1]);
            Assert.AreEqual(0x56, byteArray.Value[2]);

            var stringTag = compoundTag.GetString("string");

            Assert.AreEqual("hello!", stringTag.Value);

            var list      = compoundTag.GetList("string_list");
            var listValue = list.GetArrayString();

            Assert.AreEqual(3, listValue.Length);
            Assert.AreEqual("i'm in an array!", listValue[0].Value);
            Assert.AreEqual("i am also in an array!", listValue[1].Value);
            Assert.AreEqual("walter", listValue[2].Value);

            var emptyList      = compoundTag.GetList("empty_list");
            var emptyListValue = emptyList.GetArrayByte();

            Assert.AreEqual(0, emptyListValue.Length);

            var listList      = compoundTag.GetList("list_list");
            var listListValue = listList.GetArrayList();

            Assert.AreEqual(3, listListValue.Length);
            var listListValue0 = listListValue[0].GetArrayFloat();

            Assert.AreEqual(3, listListValue0.Length);
            Assert.AreEqual(1.1f, listListValue0[0].Value);
            Assert.AreEqual(2.2f, listListValue0[1].Value);
            Assert.AreEqual(3.3f, listListValue0[2].Value);
            var listListValue1 = listListValue[1].GetArrayDouble();

            Assert.AreEqual(3, listListValue1.Length);
            Assert.AreEqual(4.4, listListValue1[0].Value);
            Assert.AreEqual(5.5, listListValue1[1].Value);
            Assert.AreEqual(6.6, listListValue1[2].Value);
            var listListValue2 = listListValue[2].GetArrayString();

            Assert.AreEqual(3, listListValue2.Length);
            Assert.AreEqual("wa", listListValue2[0].Value);
            Assert.AreEqual("ta", listListValue2[1].Value);
            Assert.AreEqual("shi", listListValue2[2].Value);

            var compound = compoundTag.GetCompound("compound");

            Assert.AreEqual(3, compound.Count);
            Assert.AreEqual(123, compound.GetByte("compound_byte").Value);
            Assert.AreEqual(694201337, compound.GetInt("compound_int").Value);
            Assert.AreEqual("*holds a gun to your temple*", compound.GetString("compound_string").Value);

            var emptyCompound = compoundTag.GetCompound("empty_compound");

            Assert.AreEqual(0, emptyCompound.Count);

            var intArray = compoundTag.GetIntArray("int_array");

            Assert.AreEqual(4, intArray.Value.Length);
            Assert.AreEqual(69, intArray.Value[0]);
            Assert.AreEqual(420, intArray.Value[1]);
            Assert.AreEqual(1337, intArray.Value[2]);
            Assert.AreEqual(117, intArray.Value[3]);

            var longArray = compoundTag.GetLongArray("long_array");

            Assert.AreEqual(4, longArray.Value.Length);
            Assert.AreEqual(69, longArray.Value[0]);
            Assert.AreEqual(420, longArray.Value[1]);
            Assert.AreEqual(1337, longArray.Value[2]);
            Assert.AreEqual(117, longArray.Value[3]);
        }
Esempio n. 25
0
 public override void Load(Item item, TagCompound tag)
 {
     if (tag.ContainsKey("AutoReuse"))
     {
         item.autoReuse = tag.GetBool("AutoReuse");
     }
     if (tag.ContainsKey("Consumable"))
     {
         item.consumable = tag.GetBool("Consumable");
     }
     if (tag.ContainsKey("Potion"))
     {
         item.potion = tag.GetBool("Potion");
     }
     if (tag.ContainsKey("Accessory"))
     {
         item.accessory = tag.GetBool("Accessory");
     }
     if (tag.ContainsKey("DamageType"))
     {
         item.SetDamageType(tag.GetByte("DamageType"));
     }
     if (tag.ContainsKey("Damage"))
     {
         item.damage = tag.GetInt("Damage");
     }
     if (tag.ContainsKey("KnockBack"))
     {
         item.knockBack = tag.GetFloat("KnockBack");
     }
     if (tag.ContainsKey("Crit"))
     {
         item.crit = tag.Get <ushort>("Crit");
     }
     if (tag.ContainsKey("Shoot"))
     {
         item.shoot = tag.Get <ushort>("Shoot");
     }
     if (tag.ContainsKey("ShootSpeed"))
     {
         item.shootSpeed = tag.GetFloat("ShootSpeed");
     }
     if (tag.ContainsKey("CreateTile"))
     {
         item.createTile = tag.Get <ushort>("CreateTile");
     }
     if (tag.ContainsKey("TileBoost"))
     {
         item.tileBoost = (sbyte)tag.Get <byte>("TileBoost");
     }
     if (tag.ContainsKey("BuffType"))
     {
         item.buffType = tag.Get <ushort>("BuffType");
     }
     if (tag.ContainsKey("BuffTime"))
     {
         item.buffTime = tag.GetInt("BuffTime");
     }
     if (tag.ContainsKey("HealLife"))
     {
         item.healLife = tag.Get <ushort>("HealLife");
     }
     if (tag.ContainsKey("HealMana"))
     {
         item.healMana = tag.Get <ushort>("HealMana");
     }
     if (tag.ContainsKey("Axe"))
     {
         item.axe = tag.Get <ushort>("Axe");
     }
     if (tag.ContainsKey("Pickaxe"))
     {
         item.pick = tag.Get <ushort>("Pickaxe");
     }
     if (tag.ContainsKey("Hammer"))
     {
         item.hammer = tag.Get <ushort>("Hammer");
     }
     if (tag.ContainsKey("MaxStack"))
     {
         item.maxStack = tag.GetInt("MaxStack");
     }
     if (tag.ContainsKey("UseAnimation"))
     {
         item.useAnimation = tag.Get <ushort>("UseAnimation");
     }
     if (tag.ContainsKey("UseTime"))
     {
         item.useTime = tag.Get <ushort>("UseTime");
     }
     if (tag.ContainsKey("Defense"))
     {
         item.defense = tag.GetInt("Defense");
     }
     if (tag.ContainsKey("FishingPole"))
     {
         item.fishingPole = tag.Get <ushort>("FishingPole");
     }
     if (tag.ContainsKey("Scale"))
     {
         item.scale = tag.GetFloat("Scale");
     }
     if (tag.ContainsKey("UseStyle"))
     {
         item.useStyle = tag.GetByte("UseStyle");
     }
     if (tag.ContainsKey("CostMP"))
     {
         item.mana = tag.Get <ushort>("CostMP");
     }
     if (tag.ContainsKey("BuffTypes"))
     {
         CustomProperties cItem     = item.GetGlobalItem <CustomProperties>();
         int[]            buffTypes = tag.GetIntArray("BuffTypes");
         int[]            buffTimes = tag.GetIntArray("BuffTimes");
         for (int i = 0; i < cItem.BuffTypes.Length; i++)
         {
             cItem.BuffTypes[i] = buffTypes[i];
             cItem.BuffTimes[i] = buffTimes[i];
         }
     }
 }
Esempio n. 26
0
 public override void Load(TagCompound tag)
 {
     Uses = tag.GetByte("U");
 }
Esempio n. 27
0
        public void TestLoadComplexNbt()
        {
            Tag tag;

            tag = this.CreateComplexData();

            Assert.IsNotNull(tag);
            Assert.IsInstanceOf <TagCompound>(tag);
            TagCompound level = tag as TagCompound;

            Assert.AreEqual("Level", level.Name);

            TagShort shortTest = level.GetShort("shortTest");

            Assert.IsNotNull(shortTest);
            Assert.AreEqual("shortTest", shortTest.Name);
            Assert.AreEqual(32767, shortTest.Value);

            TagLong longTest = level.GetLong("longTest");

            Assert.IsNotNull(longTest);
            Assert.AreEqual("longTest", longTest.Name);
            Assert.AreEqual(9223372036854775807, longTest.Value);

            TagFloat floatTest = level.GetFloat("floatTest");

            Assert.IsNotNull(floatTest);
            Assert.AreEqual("floatTest", floatTest.Name);
            Assert.AreEqual(0.49823147f, floatTest.Value);

            TagString stringTest = level.GetString("stringTest");

            Assert.IsNotNull(stringTest);
            Assert.AreEqual("stringTest", stringTest.Name);
            Assert.AreEqual("HELLO WORLD THIS IS A TEST STRING едж!", stringTest.Value);

            TagInt intTest = level.GetInt("intTest");

            Assert.IsNotNull(intTest);
            Assert.AreEqual("intTest", intTest.Name);
            Assert.AreEqual(2147483647, intTest.Value);

            TagCompound nestedCompoundTest = level.GetCompound("nested compound test");

            Assert.IsNotNull(nestedCompoundTest);
            Assert.AreEqual("nested compound test", nestedCompoundTest.Name);

            TagCompound ham = nestedCompoundTest.GetCompound("ham");

            Assert.IsNotNull(ham);
            Assert.AreEqual("ham", ham.Name);

            TagString ham_name = ham.GetString("name");

            Assert.IsNotNull(ham_name);
            Assert.AreEqual("name", ham_name.Name);
            Assert.AreEqual("Hampus", ham_name.Value);

            TagFloat ham_value = ham.GetFloat("value");

            Assert.IsNotNull(ham_value);
            Assert.AreEqual("value", ham_value.Name);
            Assert.AreEqual(0.75f, ham_value.Value);

            TagCompound egg = nestedCompoundTest.GetCompound("egg");

            Assert.IsNotNull(egg);
            Assert.AreEqual("egg", egg.Name);

            TagString egg_name = egg.GetString("name");

            Assert.IsNotNull(egg_name);
            Assert.AreEqual("name", egg_name.Name);
            Assert.AreEqual("Eggbert", egg_name.Value);

            TagFloat egg_value = egg.GetFloat("value");

            Assert.IsNotNull(egg_value);
            Assert.AreEqual("value", egg_value.Name);
            Assert.AreEqual(0.5f, egg_value.Value);

            TagByte byteTest = level.GetByte("byteTest");

            Assert.IsNotNull(byteTest);
            Assert.AreEqual("byteTest", byteTest.Name);
            Assert.AreEqual(0x7f, byteTest.Value);

            TagDouble doubleTest = level.GetDouble("doubleTest");

            Assert.IsNotNull(doubleTest);
            Assert.AreEqual("doubleTest", doubleTest.Name);
            Assert.AreEqual(0.4931287132182315, doubleTest.Value);

            TagList listTest_long = level.GetList("listTest (long)");

            Assert.IsNotNull(listTest_long);
            Assert.AreEqual("listTest (long)", listTest_long.Name);
            Assert.IsNotNull(listTest_long.Value);
            Assert.AreEqual(5, listTest_long.Value.Count);
            Assert.AreEqual(11, (listTest_long.Value[0] as TagLong).Value);
            Assert.AreEqual(12, (listTest_long.Value[1] as TagLong).Value);
            Assert.AreEqual(13, (listTest_long.Value[2] as TagLong).Value);
            Assert.AreEqual(14, (listTest_long.Value[3] as TagLong).Value);
            Assert.AreEqual(15, (listTest_long.Value[4] as TagLong).Value);

            TagList listTest_compound = level.GetList("listTest (compound)");

            Assert.IsNotNull(listTest_compound);
            Assert.AreEqual("listTest (compound)", listTest_compound.Name);
            Assert.IsNotNull(listTest_compound.Value);
            Assert.AreEqual(2, listTest_compound.Value.Count);
            TagCompound listTest_compound_tag0 = listTest_compound.Value[0] as TagCompound;

            Assert.IsNotNull(listTest_compound_tag0);
            TagString listTest_compound_tag0_name = listTest_compound_tag0.GetString("name");

            Assert.IsNotNull(listTest_compound_tag0_name);
            Assert.AreEqual("name", listTest_compound_tag0_name.Name);
            Assert.AreEqual("Compound tag #0", listTest_compound_tag0_name.Value);
            TagLong listTest_compound_tag0_createdOn = listTest_compound_tag0.GetLong("created-on");

            Assert.IsNotNull(listTest_compound_tag0_createdOn);
            Assert.AreEqual("created-on", listTest_compound_tag0_createdOn.Name);
            Assert.AreEqual(1264099775885, listTest_compound_tag0_createdOn.Value);

            TagCompound listTest_compound_tag1 = listTest_compound.Value[1] as TagCompound;

            Assert.IsNotNull(listTest_compound_tag1);
            TagString listTest_compound_tag1_name = listTest_compound_tag1.GetString("name");

            Assert.IsNotNull(listTest_compound_tag1_name);
            Assert.AreEqual("name", listTest_compound_tag1_name.Name);
            Assert.AreEqual("Compound tag #1", listTest_compound_tag1_name.Value);
            TagLong listTest_compound_tag1_createdOn = listTest_compound_tag1.GetLong("created-on");

            Assert.IsNotNull(listTest_compound_tag1_createdOn);
            Assert.AreEqual("created-on", listTest_compound_tag1_createdOn.Name);
            Assert.AreEqual(1264099775885, listTest_compound_tag1_createdOn.Value);

            TagByteArray byteArrayTest = level.GetByteArray("byteArrayTest (the first 1000 values of (n*n*255+n*7)%100, starting with n=0 (0, 62, 34, 16, 8, ...))");

            Assert.IsNotNull(byteArrayTest);
            Assert.AreEqual("byteArrayTest (the first 1000 values of (n*n*255+n*7)%100, starting with n=0 (0, 62, 34, 16, 8, ...))", byteArrayTest.Name);
            Assert.IsNotNull(byteArrayTest.Value);
            Assert.AreEqual(1000, byteArrayTest.Value.Length);
        }
Esempio n. 28
0
 public override void Load(Item item, TagCompound tag) => tweak = (TweakType)tag.GetByte("Tweak");
Esempio n. 29
0
 public override void Load(TagCompound tag)
 {
     ammo = tag.GetByte("ammoLeft");
 }
Esempio n. 30
0
 public override void Load(TagCompound tag)
 {
     CurrentState = (State)tag.GetByte("s");
 }
Esempio n. 31
0
 public override void Load(TagCompound tag)
 {
     this.uses = tag.GetByte("u");
 }