internal static void LoadTiles(TagCompound tag) { if (!tag.HasTag("data")) return; var tables = TileTables.Create(); foreach (var tileTag in tag.GetList<TagCompound>("tileMap")) { ushort type = (ushort)tileTag.GetShort("value"); string modName = tileTag.GetString("mod"); string name = tileTag.GetString("name"); Mod mod = ModLoader.GetMod(modName); tables.tiles[type] = mod == null ? (ushort)0 : (ushort)mod.TileType(name); if (tables.tiles[type] == 0) { tables.tiles[type] = (ushort)ModLoader.GetMod("ModLoader").TileType("PendingMysteryTile"); tables.tileModNames[type] = modName; tables.tileNames[type] = name; } tables.frameImportant[type] = tileTag.GetBool("framed"); } foreach (var wallTag in tag.GetList<TagCompound>("wallMap")) { ushort wall = (ushort)wallTag.GetShort("value"); string modName = wallTag.GetString("mod"); string name = wallTag.GetString("name"); Mod mod = ModLoader.GetMod(modName); tables.walls[wall] = mod == null ? (ushort)0 : (ushort)mod.WallType(name); } ReadTileData(new BinaryReader(new MemoryStream(tag.GetByteArray("data"))), tables); }
internal static void LoadContainers(TagCompound tag) { if (tag.HasTag("data")) ReadContainers(new BinaryReader(new MemoryStream(tag.GetByteArray("data")))); foreach (var frameTag in tag.GetList<TagCompound>("itemFrames")) { TEItemFrame itemFrame = TileEntity.ByID[tag.GetInt("id")] as TEItemFrame; ItemIO.Load(itemFrame.item, frameTag.GetCompound("item")); } }
public override void Load(TagCompound tag) { Setup(tag); int type = ModLoader.GetMod(modName)?.ItemType(itemName) ?? 0; if (type > 0) { item.netDefaults(type); item.modItem.Load(tag.GetCompound("data")); ItemIO.LoadGlobals(item, tag.GetList<TagCompound>("globalData")); } }
public override void Load(TagCompound tag) { if (tag.ContainsKey("unlocks")) { List <bool> unlocks = (List <bool>)tag.GetList <bool>("unlocks"); for (int i = 0; i < unlocks.Count; i++) { mechEffectUnlocks[(CannonEffects)i] = unlocks[i]; } } else { mechEffectUnlocks = new Dictionary <CannonEffects, bool>(); foreach (CannonEffects cf in typeof(CannonEffects).GetEnumValues()) { mechEffectUnlocks[cf] = cf == CannonEffects.Base ? true : false; } } base.Load(tag); }
public override void Load(TagCompound tag) { foundItems = tag.GetList <TagCompound>("FoundItems").Select(ItemIO.Load).ToList(); //sortModePreference = (SortModes)tag.GetInt("SortMode"); announcePreference = tag.GetBool("Announce"); if (tag.ContainsKey("CollectChestItems")) // Missing tags get defaultvalue, which would be false, which isn't what we want. { findChestItemsPreference = tag.GetBool("CollectChestItems"); } showCompletedPreference = tag.GetInt("ShowCompleted"); foreach (var item in foundItems) { if (item.Name != "Unloaded Item") { foundItem[item.type] = true; totalItemsFound++; } } }
public override void Load(TagCompound tag) { base.Load(tag); ClearItemsData(); foreach (TagCompound tagItem in tag.GetList <TagCompound>("Items")) { Item item = ItemIO.Load(tagItem); items.Add(item); ItemData data = new ItemData(item); if (item.stack < item.maxStack) { hasSpaceInStack.Add(data); } hasItem.Add(data); } if (Main.netMode == NetmodeID.Server) { netQueue.Enqueue(UnitOperation.FullSync.Create()); } }
// Returns -1 for missing recipe, index of recipe otherwise public static int Load(TagCompound tag) { Item createItem = ItemIO.Load(tag.Get <TagCompound>("createItem")); List <Item> requiredItems = tag.GetList <TagCompound>("requiredItem").Select(ItemIO.Load).ToList(); for (int i = 0; i < Recipe.numRecipes; i++) { Recipe recipe = Main.recipe[i]; if (recipe.createItem.type == createItem.type) { HashSet <int> tagIngredients = new HashSet <int>(requiredItems.Where(x => !x.IsAir).Select(x => x.type)); HashSet <int> recipeIngredients = new HashSet <int>(recipe.requiredItem.Where(x => !x.IsAir).Select(x => x.type)); if (tagIngredients.SetEquals(recipeIngredients)) { return(i); } } } return(-1); }
public override void Load(TagCompound tag) { List <TagCompound> npcTags = tag.GetList <TagCompound>(nameof(ISaveableEntity)) as List <TagCompound>; foreach (TagCompound currentTag in npcTags) { Vector2 position = currentTag.Get <Vector2>(nameof(NPC.position)); int npcInstanceId = NPC.NewNPC((int)position.X, (int)position.Y, ModLoader.GetMod(currentTag.GetString(nameof(NPC.modNPC.mod))).BuffType(currentTag.GetString(nameof(NPC.modNPC.Name)))); if (Main.npc[npcInstanceId].modNPC is ISaveableEntity saveable) { saveable.Load(currentTag); } if (currentTag.ContainsKey(nameof(NPC.life))) { Main.npc[npcInstanceId].life = tag.GetAsInt(nameof(NPC.life)); } } }
public override void Load(TagCompound tag) { var downed = tag.GetList <string>("downed"); downedAnnihilator = downed.Contains("annihilator"); downedSlybertron = downed.Contains("slybertron"); downedSteamTrain = downed.Contains("steamtrain"); downedDuneSharkron = downed.Contains("dunesharkron"); downedHypothema = downed.Contains("hypothema"); downedRagnar = downed.Contains("ragnar"); downedRocks = downed.Contains("rocks"); downedTrueEtheria = downed.Contains("trueetheria"); downedDioritus = downed.Contains("dioritus"); downedAndesia = downed.Contains("andesia"); downedAnDio = downed.Contains("andio"); obEnf = tag.GetBool("obsidium"); downedEtheria = tag.GetBool("etherial"); obsidiumHeart = tag.GetBool("obsidiumHeart"); bysmal = tag.GetBool("bysmal"); power = tag.GetInt("power"); }
/// <summary> /// This method generates a structure you select from a multistructure file within your mod. Useful if you want to do your own weighted randomization or want additional logic based on dimensions gotten from GetMultistructureDimensions. /// </summary> /// <param name="path">The path to your multistructure file within your mod - this should not include your mod's folder, only the path beyond it.</param> /// <param name="pos">The position in the world in which you want your structure to generate, in tile coordinates.</param> /// <param name="mod">The instance of your mod to grab the file from.</param> /// <param name="index">The index of the structure you want to generate out of the multistructure file, structure indicies are 0-based and match the order they were saved in.</param> ///<param name="fullPath">Indicates if you want to use a fully qualified path to get the structure file instead of one from your mod - generally should only be used for debugging.</param> ///<param name="ignoreNull">If the structure should repsect the normal behavior of null tiles or not. This should never be true if you're using the mod as a dll refference.</param> public static bool GenerateMultistructureSpecific(string path, Point16 pos, Mod mod, int index, bool fullPath = false, bool ignoreNull = false) { TagCompound tag = GetTag(path, mod, fullPath); if (!tag.ContainsKey("Version") || tag.GetString("Version")[0] <= 1) { throw new Exception("Legacy structures from 1.3 versions of this mod are not supported."); } var structures = (List <TagCompound>)tag.GetList <TagCompound>("Structures"); if (index >= structures.Count || index < 0) { StructureHelper.Instance.Logger.Warn($"Attempted to generate structure {index} in mutistructure containing {structures.Count - 1} structures."); return(false); } TagCompound targetStructure = structures[index]; return(Generate(targetStructure, pos, ignoreNull)); }
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")); }
public override void Load(TagCompound tag) { kiBeacons = tag.ContainsKey("KiBeacons") ? (List <Vector2>)tag.GetList <Vector2>("KiBeacons") : new List <Vector2>(); // cleanup ki beacon list, not sure why this is necessary. CleanupKiBeaconList(); for (var i = 0; i < 7; i++) { var cacheKeyNameX = $"DragonBall{i + 1}LocationX"; var cacheKeyNameY = $"DragonBall{i + 1}LocationY"; if (tag.ContainsKey(cacheKeyNameX) && tag.ContainsKey(cacheKeyNameY)) { var dbX = tag.GetInt(cacheKeyNameX); var dbY = tag.GetInt(cacheKeyNameY); var dbLocation = new Point(dbX, dbY); CacheDragonBallLocation(i + 1, dbLocation); } } base.Load(tag); }
public override void Load(TagCompound tag) { foreach (var device in tag.Get <List <Device> >("devices")) { mod.Logger.Info($"Loading device \"{device.Name}\": X {device.LocationRect.X}, Y: {device.LocationRect.Y}"); WireMod.PlaceDevice(device, device.LocationRect.X, device.LocationRect.Y); } foreach (var conn in tag.GetList <TagCompound>("wires")) { var src = WireMod.GetDevicePin(conn.Get <Point16>("src")); var dest = WireMod.GetDevicePin(conn.Get <Point16>("dest")); if (src == null || dest == null) { continue; } src.Connect(dest); dest.Connect(src); } }
public void GetList_returns_existing_tag() { // arrange TagCompound target; Tag actual; string name; name = "alpha"; target = new TagCompound(); target.Value.Add(name, new TagCollection(TagType.Int) { 2, 4, 8, 16, 32, 64, 128, 256 }); // act actual = target.GetList(name); // assert Assert.IsNotNull(actual); Assert.IsInstanceOf <TagList>(actual); }
public override void Load(TagCompound tag) { DebugText($"LoadCustomData AltDimWorld called: ded:{Main.dedServ}, myplayer:{Main.myPlayer}, mode:{Main.netMode}"); int version = tag.GetInt("saveVersion"); existsInWorldDimensions = new List <Dimension>(tag.GetList <TagCompound>("Dimensions").Select(Dimension.Load)); Dimension vanilla = existsInWorldDimensions.Find(x => x.modname == "vanilla"); if (vanilla != null) { if (!Main.dedServ) { SetSection(vanilla); // TODO, called before or after setworldsize? DebugText("Loading Vanilla: " + vanilla.ToString()); } } else { DebugText("Uhoh, no vanilla!"); } }
public override void Load(TagCompound tag) { var downed = tag.GetList <string>("downed"); //bosses Chairlol = downed.Contains("lol"); downedMonarch = downed.Contains("Monarch"); downedGrips = downed.Contains("Grips"); NPC.downedBoss3 = downed.Contains("Dynaskull"); downedRetriever = downed.Contains("Storm1"); downedOrthrus = downed.Contains("Storm2"); downedRaider = downed.Contains("Storm3"); NPC.downedMechBossAny = downed.Contains("MechBoss"); NPC.downedPlantBoss = downed.Contains("Evil"); NPC.downedMoonlord = downed.Contains("MoonLord"); downedDB = downed.Contains("DB"); downedNC = downed.Contains("NC"); downedEquinox = downed.Contains("Equinox"); downedAncient = downed.Contains("A"); downedSAncient = downed.Contains("SA"); downedAkuma = downed.Contains("Akuma"); downedYamata = downed.Contains("Yamata"); zeroUS = downed.Contains("0U"); downedZero = downed.Contains("0"); downedShen = downed.Contains("Shen"); downedIZ = downed.Contains("IZ"); downedAllAncients = downed.Contains("DAA"); Ancients = downed.Contains("AA"); ShenSummoned = downed.Contains("ShenS"); //World Changes Dynaskull = NPC.downedBoss3; FulguriteOre = downedRetriever; HallowedOre = NPC.downedMechBossAny; Evil = NPC.downedPlantBoss; Luminite = NPC.downedMoonlord; DarkMatter = downedNC; RadiumOre = downedDB; }
public sealed override void Load(TagCompound tag) { TagCompound info = tag.GetCompound("machineInfo"); ReactionSpeed = info.GetFloat(nameof(ReactionSpeed)); ReactionProgress = info.GetFloat(nameof(ReactionProgress)); ReactionInProgress = info.GetBool(nameof(ReactionInProgress)); TagCompound tagSlots = tag.GetCompound("slots"); List <TagCompound> items = tagSlots.GetList <TagCompound>("items") as List <TagCompound> ?? new List <TagCompound>(); foreach (var c in items) { slots.Add(ItemIO.Load(c)); } TagCompound extra = tag.GetCompound("extra"); if (extra != null) { ExtraLoad(extra); } }
public override void Load(TagCompound tag) { int ModVersion = tag.GetInt("AngelStatuesPlusVersion"); if (ModVersion == 1000) { var AngelTokensSacrifced = tag.GetList <int>("AngelTokensSacrifced"); AngelTokensSacrifced0 = AngelTokensSacrifced[0]; AngelTokensSacrifced1 = AngelTokensSacrifced[1]; AngelTokensSacrifced2 = AngelTokensSacrifced[2]; AngelTokensSacrifced3 = AngelTokensSacrifced[3]; AngelTokensSacrifced4 = AngelTokensSacrifced[4]; AngelTokensSacrifced5 = AngelTokensSacrifced[5]; AngelTokensSacrifced6 = AngelTokensSacrifced[6]; AngelTokensSacrifced7 = AngelTokensSacrifced[7]; AngelTokensSacrifced8 = AngelTokensSacrifced[8]; AngelTokensSacrifced9 = AngelTokensSacrifced[9]; AngelTokensSacrifced10 = AngelTokensSacrifced[10]; AngelTokensSacrifced11 = AngelTokensSacrifced[11]; BlessingAngelTokensSacrifced = AngelTokensSacrifced[12]; AngelTokensSacrificedTotal = AngelTokensSacrifced[13]; } }
private void LoadAbilities(TagCompound tag) { AcquiredAbilities.Clear(); IList <string> abilitiesInformationUnparsed = tag.GetList <string>(nameof(AcquiredAbilities)); for (int i = 0; i < abilitiesInformationUnparsed.Count; i++) { string[] splitInformation = abilitiesInformationUnparsed[i].Split('|'); string[] splitAbilityInformation = splitInformation[1].Split(':'); AbilityDefinition ability = AbilityDefinitionManager.Instance[splitInformation[0]]; AcquiredAbilities.Add(ability, new PlayerAbility(ability, int.Parse(splitAbilityInformation[0]), int.Parse(splitAbilityInformation[1]))); } foreach (AbilityDefinition ability in Hero.Abilities) { if (ability.UnlockableAtLevel == 0 && !HasAbility(ability)) { AcquireOrLevelUp(ability); // TODO Add a way to verify this. } } }
public override void Load(TagCompound tag) { try { var inventoryMap = tag.GetList <TagCompound>("playerDeathInventoryMap"); foreach (var inventory in inventoryMap) { Point position = new Point(inventory.GetInt("positionX"), inventory.GetInt("positionY")); mod.Logger.Debug($"Loading inventory at - {position}"); string playerID = inventory.GetString("playerID"); Item[] dInventory = new Item[Main.player[0].inventory.Length]; Item[] dArmor = new Item[Main.player[0].armor.Length]; Item[] dDye = new Item[Main.player[0].dye.Length]; Item[] dMiscEquips = new Item[Main.player[0].miscEquips.Length]; Item[] dMiscDyes = new Item[Main.player[0].miscDyes.Length]; LoadItemList(inventory.Get <List <Item> >("inventory"), dInventory); LoadItemList(inventory.Get <List <Item> >("armor"), dArmor); LoadItemList(inventory.Get <List <Item> >("dye"), dDye); LoadItemList(inventory.Get <List <Item> >("miscEquips"), dMiscEquips); LoadItemList(inventory.Get <List <Item> >("miscDyes"), dMiscDyes); playerDeathInventoryMap[position] = new PlayerDeathInventory(dInventory, dArmor, dDye, dMiscEquips, dMiscDyes, playerID); //Spawn NPC for each loaded inventory and pass the X and Y position to its ai NPC.NewNPC(position.X, position.Y, mod.NPCType("GhostInventory"), ai0: position.X, ai1: position.Y); } } catch (Exception e) { mod.Logger.Error("Error loading saved death inventories " + e.Message); } }
public override void Load(TagCompound tag) { var downed = tag.GetList <string>("downed"); downedRognir = downed.Contains("rognir"); }
public override void Load(Item item, TagCompound tag) { if (!Config.Instance.SaveReforges) { return; } //Old compatibility if (tag.ContainsKey("reforges")) { reforges = (List <int>)tag.GetList <int>("reforges"); return; } List <int> vanillaReforges = (List <int>)tag.GetList <int>("vanillaReforges"); List <int> modReforges = new List <int>(); TagCompound moddedReforges = tag.Get <TagCompound>("moddedReforges"); TagCompound orphanedModdedReforges = tag.Get <TagCompound>("orphanedModdedReforges"); //Merge previously loaded + orphaned together, and then filter through them at once foreach (var orphanedModTag in orphanedModdedReforges) { string modName = orphanedModTag.Key; var orphanNames = orphanedModTag.Value as List <string> ?? new List <string>(); if (moddedReforges.ContainsKey(modName)) { var reforgeNames = moddedReforges[modName] as List <string> ?? new List <string>(); moddedReforges[modName] = reforgeNames.Union(orphanNames).ToList(); } else { moddedReforges[modName] = orphanNames; } } orphanedModPrefixes = new Dictionary <string, List <string> >(); foreach (var modTag in moddedReforges) { string modName = modTag.Key; var reforgeNames = modTag.Value as List <string> ?? new List <string>(); Mod mod = ModLoader.GetMod(modName); if (mod == null) { if (!orphanedModPrefixes.ContainsKey(modName)) { //If mod is null (not currently loaded), all its prefixes are also not loaded, so save the entire list, and continue orphanedModPrefixes[modName] = reforgeNames; } continue; } foreach (var name in reforgeNames) { ModPrefix modPrefix = mod.GetPrefix(name); if (modPrefix == null) { //If loaded prefix does not exist, add it as orphaned if (!orphanedModPrefixes.ContainsKey(modName)) { orphanedModPrefixes[modName] = new List <string>(); } List <string> lists = orphanedModPrefixes[modName]; if (!lists.Contains(name)) { lists.Add(name); } continue; } modReforges.Add(modPrefix.Type); } } reforges = vanillaReforges.Union(modReforges).ToList(); }
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); }
public override void Load(TagCompound tag) { QEItemHandlers = tag.GetList <ItemPair>("QEItems").ToList(); QEFluidHandlers = tag.GetList <FluidPair>("QEFluids").ToList(); }
public void LoadLevels(TagCompound tag) { Level = tag.GetAsInt(nameof(Level)); _executedLevelingRuleNames = tag.GetList <string>(nameof(ExecutedNPCLevelingRuleNames)) as List <string>; }
public override void Load(TagCompound tag) { var generated = tag.GetList <string>("generated"); mercuryGenerated = generated.Contains("mercury"); }
public override void Load(TagCompound tag) { var Downed = tag.GetList <string>("Downed"); DownedCloudBoss = Downed.Contains("cloudBoss"); }
public override void Load(TagCompound tag) { Ingredients = (List <Item>)tag.GetList <Item>("Items"); Fullness = tag.GetInt("Fullness"); }
public override void Load(TagCompound tag) { var downed = tag.GetList<string>("downed"); downedAbomination = downed.Contains("abomination"); downedPuritySpirit = downed.Contains("puritySpirit"); }
public override void Load(TagCompound tag) { WorldIO.LoadModData(tag.GetList <TagCompound>("list")); WorldIO.LoadNPCs(tag.GetList <TagCompound>("mysteryNPCs")); WorldIO.LoadNPCKillCounts(tag.GetList <TagCompound>("mysteryKillCounts")); }
public override void Load(TagCompound tag) { items = tag.GetList<TagCompound>("items").Select(ItemIO.Load).ToList(); }
public override void Load(TagCompound tag) { PlayerIO.LoadModData(player, tag.GetList <TagCompound>("list")); }
public override void Load(TagCompound tag) { List<ushort> canRestore = new List<ushort>(); bool canRestoreFlag = false; foreach (var infoTag in tag.GetList<TagCompound>("list")) { if (!infoTag.HasTag("mod")) { infos.Add(null); canRestore.Add(0); continue; } string modName = infoTag.GetString("mod"); string name = infoTag.GetString("name"); bool frameImportant = infoTag.HasTag("frameX"); var info = frameImportant ? new MysteryTileInfo(modName, name, infoTag.GetShort("frameX"), infoTag.GetShort("frameY")) : new MysteryTileInfo(modName, name); infos.Add(info); int type = ModLoader.GetMod(modName)?.TileType(name) ?? 0; canRestore.Add((ushort) type); if (type != 0) canRestoreFlag = true; } if (canRestoreFlag) { RestoreTiles(canRestore); for (int k = 0; k < canRestore.Count; k++) { if (canRestore[k] > 0) { infos[k] = null; } } } if (pendingInfos.Count > 0) { ConfirmPendingInfo(); } }
public override void Load(TagCompound tag) { TerraFirma.Instance.TubeNetworkLayer.Load(tag.GetList <TagCompound>("TubularNetwork").ToList()); }
public override void Load(TagCompound tag) { bannerItems.AddRange(tag.GetList <TagCompound>("BannerItems").Select(ItemIO.Load)); unloadedBannerItems.AddRange(bannerItems.Where(x => x.type == ItemID.Count)); bannerItems.RemoveAll(x => x.type == ItemID.Count); }
public override void Load(TagCompound tag) { IList <string> downed = tag.GetList <string>("downed"); downedSky = downed.Contains("downedSky"); }
public override void Load(Item item, TagCompound tag) { ItemIO.LoadGlobals(item, tag.GetList<TagCompound>("list")); }
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]); }
public override void Load(TagCompound tag) { PlayerIO.LoadModData(player, tag.GetList<TagCompound>("list")); }