public bool AddTag(TagNode tag, string name) { if (_tag.ContainsKey(name)) { return(false); } _tag.Add(name, tag); return(true); }
public override TypedEntity LoadTree(TagNode tree) { TagNodeCompound ctree = tree as TagNodeCompound; if (ctree == null || base.LoadTree(tree) == null) { return(null); } _attackTime = ctree["AttackTime"].ToTagShort(); _deathTime = ctree["DeathTime"].ToTagShort(); _health = ctree["Health"].ToTagShort(); _hurtTime = ctree["HurtTime"].ToTagShort(); if (ctree.ContainsKey("ActiveEffects")) { TagNodeCompound ae = ctree["ActiveEffects"].ToTagCompound(); _activeEffects = new ActiveEffects(); _activeEffects.Id = ae["Id"].ToTagByte(); _activeEffects.Amplifier = ae["Amplifier"].ToTagByte(); _activeEffects.Duration = ae["Duration"].ToTagInt(); } return(this); }
public AnvilSection LoadTree(TagNode tree) { TagNodeCompound ctree = tree as TagNodeCompound; if (ctree == null) { return(null); } _y = ctree["Y"] as TagNodeByte; _blocks = new YZXByteArray(XDIM, YDIM, ZDIM, ctree["Blocks"] as TagNodeByteArray); _data = new YZXNibbleArray(XDIM, YDIM, ZDIM, ctree["Data"] as TagNodeByteArray); _skyLight = new YZXNibbleArray(XDIM, YDIM, ZDIM, ctree["SkyLight"] as TagNodeByteArray); _blockLight = new YZXNibbleArray(XDIM, YDIM, ZDIM, ctree["BlockLight"] as TagNodeByteArray); if (!ctree.ContainsKey("AddBlocks")) { ctree["AddBlocks"] = new TagNodeByteArray(new byte[2048]); } _addBlocks = new YZXNibbleArray(XDIM, YDIM, ZDIM, ctree["AddBlocks"] as TagNodeByteArray); _tree = ctree; return(this); }
/// <inheritdoc/> public Item LoadTree(TagNode tree) { TagNodeCompound ctree = tree as TagNodeCompound; if (ctree == null) { return(null); } _enchantments.Clear(); _id = ctree["id"].ToTagString(); _count = ctree["Count"].ToTagByte(); _damage = ctree["Damage"].ToTagShort(); if (ctree.ContainsKey("tag")) { TagNodeCompound tagtree = ctree["tag"].ToTagCompound(); if (tagtree.ContainsKey("ench")) { TagNodeList enchList = tagtree["ench"].ToTagList(); foreach (TagNode tag in enchList) { _enchantments.Add(new Enchantment().LoadTree(tag)); } } } _source = ctree.Copy() as TagNodeCompound; return(this); }
/// <inheritdoc/> public TagNode BuildTree() { TagNodeCompound tree = new TagNodeCompound(); tree["id"] = new TagNodeString(_id); tree["Count"] = new TagNodeByte(_count); tree["Damage"] = new TagNodeShort(_damage); if (_enchantments.Count > 0) { TagNodeList enchList = new TagNodeList(TagType.TAG_COMPOUND); foreach (Enchantment e in _enchantments) { enchList.Add(e.BuildTree()); } TagNodeCompound tagtree = new TagNodeCompound(); tagtree["ench"] = enchList; if (_source != null && _source.ContainsKey("tag")) { tagtree.MergeFrom(_source["tag"].ToTagCompound()); } tree["tag"] = tagtree; } if (_source != null) { tree.MergeFrom(_source); } return(tree); }
public static BlockState Load(TagNodeCompound tag) { var name = tag["Name"].ToTagString().Data; var props = tag.ContainsKey("Properties") ? tag["Properties"].ToTagCompound() : null; return(new BlockState(name, props)); }
public Item(TagNodeCompound item) { if (!item.ContainsKey("tag")) { return; } TagNodeCompound tag = item["tag"].ToTagCompound(); if (!tag.ContainsKey("display")) { return; } TagNodeCompound display = tag["display"].ToTagCompound(); if (display.Keys.Contains("Name")) { Name = display["Name"].ToTagString().Data; } if (display.Keys.Contains("Lore")) { TagNodeList l = display["Lore"].ToTagList(); for (int k = 0; k < l.Count; k++) { Lore += l[k].ToTagString().Data.Replace("Line" + (k + 1) + ":", "") + "\n"; } if (Lore.Length > 0) { Lore = Lore.Substring(0, Lore.Length - 1); } } }
public static bool ContainerTranslator(TagNodeCompound Target, List <LanguageItem> Source) { LanguageItem target = null; bool flag = false; foreach (LanguageItem c in Source) { if (c.Info == Target["x"].ToTagInt().Data + "," + Target["y"].ToTagInt().Data + "," + Target["z"].ToTagInt().Data) { target = c; break; } } if (target == null) { return(false); } Container o = target.Original as Container; Container t = target.Translated as Container; if (Target.ContainsKey("RecordItem")) { return(ItemTranslator(Target["RecordItem"].ToTagCompound(), o.Items[0], t.Items[0])); } else { TagNodeList Items = Target["Items"].ToTagList(); foreach (TagNode item in Items) { for (int i = 0; i < o.Items.Count; i++) { if (ItemTranslator(item.ToTagCompound(), o.Items[i], t.Items[i])) { flag = true; goto Next; } } } Next: if (Target.ContainsKey("CustomName") && t.CustomName != "") { Target["CustomName"] = new TagNodeString(t.CustomName); flag = true; } if (Target.ContainsKey("Lock") && t.Lock != "") { Target["Lock"] = new TagNodeString(t.Lock); flag = true; } } return(flag); }
/// <summary> /// Loads the Chunk from an NBT tree rooted at the given TagValue node. /// </summary> /// <param name="tree">Root node of an NBT tree.</param> /// <returns>A reference to the current Chunk, or null if the tree is unparsable.</returns> public Chunk LoadTree(TagNode tree) { TagNodeCompound ctree = tree as TagNodeCompound; if (ctree == null) { return(null); } _tree = new NbtTree(ctree); TagNodeCompound level = _tree.Root["Level"] as TagNodeCompound; _blocks = new XZYByteArray(XDIM, YDIM, ZDIM, level["Blocks"] as TagNodeByteArray); _data = new XZYNibbleArray(XDIM, YDIM, ZDIM, level["Data"] as TagNodeByteArray); _blockLight = new XZYNibbleArray(XDIM, YDIM, ZDIM, level["BlockLight"] as TagNodeByteArray); _skyLight = new XZYNibbleArray(XDIM, YDIM, ZDIM, level["SkyLight"] as TagNodeByteArray); _heightMap = new ZXByteArray(XDIM, ZDIM, level["HeightMap"] as TagNodeByteArray); _entities = level["Entities"] as TagNodeList; _tileEntities = level["TileEntities"] as TagNodeList; if (level.ContainsKey("TileTicks")) { _tileTicks = level["TileTicks"] as TagNodeList; } else { _tileTicks = new TagNodeList(TagType.TAG_COMPOUND); } // List-type patch up if (_entities.Count == 0) { level["Entities"] = new TagNodeList(TagType.TAG_COMPOUND); _entities = level["Entities"] as TagNodeList; } if (_tileEntities.Count == 0) { level["TileEntities"] = new TagNodeList(TagType.TAG_COMPOUND); _tileEntities = level["TileEntities"] as TagNodeList; } if (_tileTicks.Count == 0) { level["TileTicks"] = new TagNodeList(TagType.TAG_COMPOUND); _tileTicks = level["TileTicks"] as TagNodeList; } _cx = level["xPos"].ToTagInt(); _cz = level["zPos"].ToTagInt(); _blockManager = new AlphaBlockCollection(_blocks, _data, _blockLight, _skyLight, _heightMap, _tileEntities, _tileTicks); _entityManager = new EntityCollection(_entities); return(this); }
/// <summary> /// Attempt to load a Level subtree into the <see cref="Level"/> without validation. /// </summary> /// <param name="tree">The root node of a Level subtree.</param> /// <returns>The <see cref="Level"/> returns itself on success, or null if the tree was unparsable.</returns> public virtual Level LoadTree(TagNode tree) { TagNodeCompound dtree = tree as TagNodeCompound; if (dtree == null) { return(null); } _version = null; _raining = null; _rainTime = null; _thundering = null; _thunderTime = null; TagNodeCompound ctree = dtree["Data"].ToTagCompound(); _time = ctree["Time"].ToTagLong(); _lastPlayed = ctree["LastPlayed"].ToTagLong(); if (ctree.ContainsKey("Player")) { _player = new Player().LoadTree(ctree["Player"]); } _spawnX = ctree["SpawnX"].ToTagInt(); _spawnY = ctree["SpawnY"].ToTagInt(); _spawnZ = ctree["SpawnZ"].ToTagInt(); _sizeOnDisk = ctree["SizeOnDisk"].ToTagLong(); _randomSeed = ctree["RandomSeed"].ToTagLong(); if (ctree.ContainsKey("version")) { _version = ctree["version"].ToTagInt(); } if (ctree.ContainsKey("LevelName")) { _name = ctree["LevelName"].ToTagString(); } if (ctree.ContainsKey("raining")) { _raining = ctree["raining"].ToTagByte(); } if (ctree.ContainsKey("thundering")) { _thundering = ctree["thundering"].ToTagByte(); } if (ctree.ContainsKey("rainTime")) { _rainTime = ctree["rainTime"].ToTagInt(); } if (ctree.ContainsKey("thunderTime")) { _thunderTime = ctree["thunderTime"].ToTagInt(); } return(this); }
/// <inheritdoc/> public Item LoadTree(TagNode tree) { TagNodeCompound ctree = tree as TagNodeCompound; if (ctree == null) { return(null); } _enchantments.Clear(); _id = ctree["id"].ToTagShort(); _count = ctree["Count"].ToTagByte(); _damage = ctree["Damage"].ToTagShort(); if (ctree.ContainsKey("tag")) { TagNodeCompound tagtree = ctree["tag"].ToTagCompound(); if (tagtree.ContainsKey("ench")) { TagNodeList enchList = tagtree["ench"].ToTagList(); foreach (TagNode tag in enchList) { _enchantments.Add(new Enchantment().LoadTree(tag)); } } if (tagtree.ContainsKey("StoredEnchantments")) { TagNodeList storedEnchList = tagtree["StoredEnchantments"].ToTagList(); foreach (TagNode tag in storedEnchList) { _storedEnchantments.Add(new Enchantment().LoadTree(tag)); } } if (tagtree.ContainsKey("display")) { TagNodeCompound displaytree = tagtree["display"].ToTagCompound(); _color = displaytree["color"].ToTagInt(); _name = displaytree["Name"].ToTagString(); TagNodeList loreList = displaytree["Lore"].ToTagList(); string str = ""; foreach (TagNode tag in loreList) { str += tag.ToTagString() + "\n"; } str = str.Substring(0, str.Length - 1); // get rid of last \n _lore = str; } } _source = ctree.Copy() as TagNodeCompound; return(this); }
public Book(TagNodeCompound item) { if (!item.ContainsKey("tag")) { return; } TagNodeCompound tag = item["tag"].ToTagCompound(); if (!tag.ContainsKey("display")) { goto Next; } TagNodeCompound display = tag["display"].ToTagCompound(); if (display.Keys.Contains("Lore")) { TagNodeList l = display["Lore"].ToTagList(); for (int k = 0; k < l.Count; k++) { Lore += l[k].ToTagString().Data.Replace("Line" + (k + 1) + ":", "") + "\n"; } if (Lore.Length > 0) { Lore = Lore.Substring(0, Lore.Length - 1); } } Next :; if (tag.ContainsKey("title")) { Title = tag["title"].ToTagString().Data; } if (tag.ContainsKey("pages")) { foreach (TagNode node in tag["pages"].ToTagList()) { Pages += node.ToTagString().Data + "\n"; } } if (Pages.Length != 0) { Pages = Pages.Substring(0, Pages.Length - 1); } }
private static TranslationMap LoadPalette(TagNodeCompound tag) { var map = TranslationMap.Minecraft12; if (tag.ContainsKey("SchematicaMapping")) // Schematica { foreach (var entry in tag["SchematicaMapping"].ToTagCompound()) { map[entry.Value.ToTagShort().Data] = entry.Key; } } else if (tag.ContainsKey("BlockIDs")) // MCEdit2 { foreach (var entry in tag["BlockIDs"].ToTagCompound()) { map[short.Parse(entry.Key)] = entry.Value.ToTagString().Data; } } return(map); }
/// <summary> /// Attempt to load a Player subtree into the <see cref="Player"/> without validation. /// </summary> /// <param name="tree">The root node of a Player subtree.</param> /// <returns>The <see cref="Player"/> returns itself on success, or null if the tree was unparsable.</returns> public virtual new Player LoadTree(TagNode tree) { TagNodeCompound ctree = tree as TagNodeCompound; if (ctree == null || base.LoadTree(tree) == null) { return(null); } _attackTime = ctree["AttackTime"].ToTagShort(); _deathTime = ctree["DeathTime"].ToTagShort(); _health = ctree["Health"].ToTagShort(); _hurtTime = ctree["HurtTime"].ToTagShort(); _dimension = ctree["Dimension"].ToTagInt(); _sleeping = ctree["Sleeping"].ToTagByte(); _sleepTimer = ctree["SleepTimer"].ToTagShort(); if (ctree.ContainsKey("SpawnX")) { _spawnX = ctree["SpawnX"].ToTagInt(); } if (ctree.ContainsKey("SpawnY")) { _spawnY = ctree["SpawnY"].ToTagInt(); } if (ctree.ContainsKey("SpawnZ")) { _spawnZ = ctree["SpawnZ"].ToTagInt(); } if (ctree.ContainsKey("World")) { _world = ctree["World"].ToTagString(); } _inventory.LoadTree(ctree["Inventory"].ToTagList()); return(this); }
public static ChunkSection Load(int dataVersion, Coord2 pos, TagNodeCompound tag) { var y = tag["Y"].ToTagByte().Data; if (!tag.ContainsKey("Palette")) { return(null); } var palette = tag["Palette"].ToTagList().Select(tagNode => BlockState.Load(tagNode.ToTagCompound())).ToArray(); var blockStates = tag["BlockStates"].ToTagLongArray().Data; return(new ChunkSection(dataVersion, pos, y, blockStates, palette)); }
public override TypedEntity LoadTree(TagNode tree) { TagNodeCompound ctree = tree as TagNodeCompound; if (ctree == null || base.LoadTree(tree) == null) { return(null); } if (ctree.ContainsKey("powered")) { _powered = ctree["powered"].ToTagByte() == 1; } return(this); }
public override TileEntity LoadTree(TagNode tree) { TagNodeCompound ctree = tree as TagNodeCompound; if (ctree == null || base.LoadTree(tree) == null) { return(null); } if (ctree.ContainsKey("Record")) { _record = ctree["Record"].ToTagInt(); } return(this); }
public static TagNode DeserializeNode(byte[] data) { NbtTree tree = new NbtTree(); using (MemoryStream ms = new MemoryStream(data)) { tree.ReadFrom(ms); } TagNodeCompound root = tree.Root; if (root == null || !root.ContainsKey("root")) { return(null); } return(root["root"]); }
/// <summary> /// Attempt to load a Level subtree into the <see cref="Level"/> without validation. /// </summary> /// <param name="tree">The root node of a Level subtree.</param> /// <returns>The <see cref="Level"/> returns itself on success, or null if the tree was unparsable.</returns> public virtual Level LoadTree(TagNode tree) { TagNodeCompound dtree = tree as TagNodeCompound; if (dtree == null) { return(null); } _version = null; _raining = null; _rainTime = null; _thundering = null; _thunderTime = null; _gameType = null; _mapFeatures = null; _generatorOptions = null; _generatorVersion = null; _allowCommands = null; _initialized = null; _DayTime = null; TagNodeCompound ctree = dtree["Data"].ToTagCompound(); _time = ctree["Time"].ToTagLong(); _lastPlayed = ctree["LastPlayed"].ToTagLong(); if (ctree.ContainsKey("Player")) { _player = new Player().LoadTree(ctree["Player"]); } _spawnX = ctree["SpawnX"].ToTagInt(); _spawnY = ctree["SpawnY"].ToTagInt(); _spawnZ = ctree["SpawnZ"].ToTagInt(); _sizeOnDisk = ctree["SizeOnDisk"].ToTagLong(); _randomSeed = ctree["RandomSeed"].ToTagLong(); if (ctree.ContainsKey("version")) { _version = ctree["version"].ToTagInt(); } if (ctree.ContainsKey("LevelName")) { _name = ctree["LevelName"].ToTagString(); } if (ctree.ContainsKey("generatorName")) { _generator = ctree["generatorName"].ToTagString(); } if (ctree.ContainsKey("raining")) { _raining = ctree["raining"].ToTagByte(); } if (ctree.ContainsKey("thundering")) { _thundering = ctree["thundering"].ToTagByte(); } if (ctree.ContainsKey("rainTime")) { _rainTime = ctree["rainTime"].ToTagInt(); } if (ctree.ContainsKey("thunderTime")) { _thunderTime = ctree["thunderTime"].ToTagInt(); } if (ctree.ContainsKey("GameType")) { _gameType = ctree["GameType"].ToTagInt(); } if (ctree.ContainsKey("MapFeatures")) { _mapFeatures = ctree["MapFeatures"].ToTagByte(); } if (ctree.ContainsKey("hardcore")) { _hardcore = ctree["hardcore"].ToTagByte(); } if (ctree.ContainsKey("generatorVersion")) { _generatorVersion = ctree["generatorVersion"].ToTagInt(); } if (ctree.ContainsKey("generatorOptions")) { _generatorOptions = ctree["generatorOptions"].ToTagString(); } if (ctree.ContainsKey("allowCommands")) { _allowCommands = ctree["allowCommands"].ToTagByte(); } if (ctree.ContainsKey("initialized")) { _initialized = ctree["initialized"].ToTagByte(); } if (ctree.ContainsKey("DayTime")) { _DayTime = ctree["DayTime"].ToTagLong(); } if (ctree.ContainsKey("GameRules")) { TagNodeCompound gr = ctree["GameRules"].ToTagCompound(); _gameRules = new GameRules(); _gameRules.CommandBlockOutput = gr["commandBlockOutput"].ToTagString().Data == "true"; _gameRules.DoFireTick = gr["doFireTick"].ToTagString().Data == "true"; _gameRules.DoMobLoot = gr["doMobLoot"].ToTagString().Data == "true"; _gameRules.DoMobSpawning = gr["doMobSpawning"].ToTagString().Data == "true"; _gameRules.DoTileDrops = gr["doTileDrops"].ToTagString().Data == "true"; _gameRules.KeepInventory = gr["keepInventory"].ToTagString().Data == "true"; _gameRules.MobGriefing = gr["mobGriefing"].ToTagString().Data == "true"; } _source = ctree.Copy() as TagNodeCompound; return(this); }
/// <summary> /// Attempt to load a Player subtree into the <see cref="Player"/> without validation. /// </summary> /// <param name="tree">The root node of a Player subtree.</param> /// <returns>The <see cref="Player"/> returns itself on success, or null if the tree was unparsable.</returns> public virtual new Player LoadTree(TagNode tree) { TagNodeCompound ctree = tree as TagNodeCompound; if (ctree == null || base.LoadTree(tree) == null) { return(null); } _attackTime = ctree["AttackTime"].ToTagShort(); _deathTime = ctree["DeathTime"].ToTagShort(); _health = ctree["Health"].ToTagShort(); _hurtTime = ctree["HurtTime"].ToTagShort(); _dimension = ctree["Dimension"].ToTagInt(); _sleeping = ctree["Sleeping"].ToTagByte(); _sleepTimer = ctree["SleepTimer"].ToTagShort(); if (ctree.ContainsKey("SpawnX")) { _spawnX = ctree["SpawnX"].ToTagInt(); } if (ctree.ContainsKey("SpawnY")) { _spawnY = ctree["SpawnY"].ToTagInt(); } if (ctree.ContainsKey("SpawnZ")) { _spawnZ = ctree["SpawnZ"].ToTagInt(); } if (ctree.ContainsKey("World")) { _world = ctree["World"].ToTagString(); } if (ctree.ContainsKey("foodLevel")) { _foodLevel = ctree["foodLevel"].ToTagInt(); } if (ctree.ContainsKey("foodTickTimer")) { _foodTickTimer = ctree["foodTickTimer"].ToTagInt(); } if (ctree.ContainsKey("foodExhaustionLevel")) { _foodExhaustion = ctree["foodExhaustionLevel"].ToTagFloat(); } if (ctree.ContainsKey("foodSaturationLevel")) { _foodSaturation = ctree["foodSaturationLevel"].ToTagFloat(); } if (ctree.ContainsKey("XpP")) { _xpP = ctree["XpP"].ToTagFloat(); } if (ctree.ContainsKey("XpLevel")) { _xpLevel = ctree["XpLevel"].ToTagInt(); } if (ctree.ContainsKey("XpTotal")) { _xpTotal = ctree["XpTotal"].ToTagInt(); } if (ctree.ContainsKey("Score")) { _score = ctree["Score"].ToTagInt(); } if (ctree.ContainsKey("abilities")) { TagNodeCompound pb = ctree["abilities"].ToTagCompound(); _abilities = new PlayerAbilities(); _abilities.Flying = pb["flying"].ToTagByte().Data == 1; _abilities.InstantBuild = pb["instabuild"].ToTagByte().Data == 1; _abilities.MayFly = pb["mayfly"].ToTagByte().Data == 1; _abilities.Invulnerable = pb["invulnerable"].ToTagByte().Data == 1; if (pb.ContainsKey("mayBuild")) { _abilities.MayBuild = pb["mayBuild"].ToTagByte().Data == 1; } if (pb.ContainsKey("walkSpeed")) { _abilities.WalkSpeed = pb["walkSpeed"].ToTagFloat(); } if (pb.ContainsKey("flySpeed")) { _abilities.FlySpeed = pb["flySpeed"].ToTagFloat(); } } if (ctree.ContainsKey("PlayerGameType")) { _gameType = (PlayerGameType)ctree["PlayerGameType"].ToTagInt().Data; } _inventory.LoadTree(ctree["Inventory"].ToTagList()); if (ctree.ContainsKey("EnderItems")) { if (ctree["EnderItems"].ToTagList().Count > 0) { _enderItems.LoadTree(ctree["EnderItems"].ToTagList()); } } return(this); }
public override TileEntity LoadTree(TagNode tree) { TagNodeCompound ctree = tree as TagNodeCompound; if (ctree == null || base.LoadTree(tree) == null) { return(null); } _delay = ctree["Delay"].ToTagShort(); _entityID = ctree["EntityId"].ToTagString(); if (ctree.ContainsKey("MaxSpawnDelay")) { _maxDelay = ctree["MaxSpawnDelay"].ToTagShort(); } if (ctree.ContainsKey("MinSpawnDelay")) { _minDelay = ctree["MinSpawnDelay"].ToTagShort(); } if (ctree.ContainsKey("SpawnCount")) { _spawnCount = ctree["SpawnCount"].ToTagShort(); } if (ctree.ContainsKey("SpawnRange")) { _spawnRange = ctree["SpawnRange"].ToTagShort(); } if (ctree.ContainsKey("MaxNearbyEnemies")) { _maxNearbyEnemies = ctree["MaxNearbyEnemies"].ToTagShort(); } if (ctree.ContainsKey("RequiredPlayerRange")) { _requiredPlayerRange = ctree["RequiredPlayerRange"].ToTagShort(); } if (ctree.ContainsKey("MaxExperience")) { _maxExperience = ctree["MaxExperience"].ToTagInt(); } if (ctree.ContainsKey("RemainingExperience")) { _remainingExperience = ctree["RemainingExperience"].ToTagInt(); } if (ctree.ContainsKey("ExperienceRegenTick")) { _experienceRegenTick = ctree["ExperienceRegenTick"].ToTagInt(); } if (ctree.ContainsKey("ExperienceRegenRate")) { _experienceRegenRate = ctree["ExperienceRegenRate"].ToTagInt(); } if (ctree.ContainsKey("ExperienceRegenAmount")) { _experienceRegenRate = ctree["ExperienceRegenAmount"].ToTagInt(); } if (ctree.ContainsKey("SpawnData")) { _spawnData = ctree["SpawnData"].ToTagCompound(); } return(this); }
public static bool EntityTranslator(TagNodeCompound Target, List <LanguageItem> Source) { bool result = false; if (Target.ContainsKey("CustomName")) { string name = Target["CustomName"].ToTagString().Data; foreach (LanguageItem item in Source) { if ((item.Original as Entity).CustomName == name && name != "" && name != null) { Entity tra = item.Translated as Entity; if (tra.CustomName == "") { break; } Target["CustomName"] = new TagNodeString(tra.CustomName); result = true; } } } if (Target["id"].ToTagString().Data.ToLower().Contains("item")) { foreach (LanguageItem e in Source) { for (int i = 0; i < 6; i++) { if (Target.ContainsKey("Item") && ItemTranslator(Target["Item"].ToTagCompound(), (e.Original as Entity).Equipments[i], (e.Translated as Entity).Equipments[i])) { result = true; goto Next; } } } Next :; } else if (Target.ContainsKey("ArmorItems") || Target.ContainsKey("HandItems")) { TagNodeList list = Target["ArmorItems"].ToTagList(); bool b1 = false, b2 = false, b3 = false, b4 = false; foreach (LanguageItem e in Source) { if (list.Count > 0 && ItemTranslator(list[0].ToTagCompound(), (e.Original as Entity).Equipments[5], (e.Translated as Entity).Equipments[0])) { b1 = true; } if (list.Count > 1 && ItemTranslator(list[1].ToTagCompound(), (e.Original as Entity).Equipments[4], (e.Translated as Entity).Equipments[1])) { b2 = true; } if (list.Count > 2 && ItemTranslator(list[2].ToTagCompound(), (e.Original as Entity).Equipments[3], (e.Translated as Entity).Equipments[2])) { b3 = true; } if (list.Count > 3 && ItemTranslator(list[3].ToTagCompound(), (e.Original as Entity).Equipments[2], (e.Translated as Entity).Equipments[3])) { b4 = true; } if (b1 && b2 && b3 && b4) { goto Next; } } Next: TagNodeList list2 = Target["HandItems"].ToTagList(); bool b5 = false, b6 = false; foreach (LanguageItem e in Source) { if (list2.Count > 0 && ItemTranslator(list2[0].ToTagCompound(), (e.Original as Entity).Equipments[0], (e.Translated as Entity).Equipments[0])) { b5 = true; } if (list2.Count > 1 && ItemTranslator(list2[1].ToTagCompound(), (e.Original as Entity).Equipments[1], (e.Translated as Entity).Equipments[1])) { b6 = true; } if (b5 && b6) { goto End; } } End : result = result ? true : b1 || b2 || b3 || b4 || b5 || b6; } else if (Target.ContainsKey("Equipment")) { TagNodeList list = Target["Equipment"].ToTagList(); bool b1 = false, b2 = false, b3 = false, b4 = false, b5 = false; foreach (LanguageItem e in Source) { if (list.Count > 0 && ItemTranslator(list[0].ToTagCompound(), (e.Original as Entity).Equipments[0], (e.Translated as Entity).Equipments[0])) { b1 = true; } if (list.Count > 1 && ItemTranslator(list[1].ToTagCompound(), (e.Original as Entity).Equipments[2], (e.Translated as Entity).Equipments[1])) { b2 = true; } if (list.Count > 2 && ItemTranslator(list[2].ToTagCompound(), (e.Original as Entity).Equipments[3], (e.Translated as Entity).Equipments[1])) { b3 = true; } if (list.Count > 3 && ItemTranslator(list[3].ToTagCompound(), (e.Original as Entity).Equipments[4], (e.Translated as Entity).Equipments[1])) { b4 = true; } if (list.Count > 4 && ItemTranslator(list[4].ToTagCompound(), (e.Original as Entity).Equipments[5], (e.Translated as Entity).Equipments[1])) { b5 = true; } if (b1 && b2 && b3 && b4 && b5) { goto End; } } End: result = result ? true : b1 || b2 || b3 || b4 || b5; } return(result); }
public AnvilChunk LoadTree(TagNode tree) { TagNodeCompound ctree = tree as TagNodeCompound; if (ctree == null) { return(null); } _tree = new NbtTree(ctree); TagNodeCompound level = _tree.Root["Level"] as TagNodeCompound; TagNodeList sections = level["Sections"] as TagNodeList; foreach (TagNodeCompound section in sections) { AnvilSection anvilSection = new AnvilSection(section); if (anvilSection.Y < 0 || anvilSection.Y >= _sections.Length) { continue; } _sections[anvilSection.Y] = anvilSection; } FusedDataArray3[] blocksBA = new FusedDataArray3[_sections.Length]; YZXNibbleArray[] dataBA = new YZXNibbleArray[_sections.Length]; YZXNibbleArray[] skyLightBA = new YZXNibbleArray[_sections.Length]; YZXNibbleArray[] blockLightBA = new YZXNibbleArray[_sections.Length]; for (int i = 0; i < _sections.Length; i++) { if (_sections[i] == null) { _sections[i] = new AnvilSection(i); } blocksBA[i] = new FusedDataArray3(_sections[i].AddBlocks, _sections[i].Blocks); dataBA[i] = _sections[i].Data; skyLightBA[i] = _sections[i].SkyLight; blockLightBA[i] = _sections[i].BlockLight; } _blocks = new CompositeDataArray3(blocksBA); _data = new CompositeDataArray3(dataBA); _skyLight = new CompositeDataArray3(skyLightBA); _blockLight = new CompositeDataArray3(blockLightBA); _heightMap = new ZXIntArray(XDIM, ZDIM, level["HeightMap"] as TagNodeIntArray); if (level.ContainsKey("Biomes")) { _biomes = new ZXByteArray(XDIM, ZDIM, level["Biomes"] as TagNodeByteArray); } else { level["Biomes"] = new TagNodeByteArray(new byte[256]); _biomes = new ZXByteArray(XDIM, ZDIM, level["Biomes"] as TagNodeByteArray); for (int x = 0; x < XDIM; x++) { for (int z = 0; z < ZDIM; z++) { _biomes[x, z] = BiomeType.Default; } } } _entities = level["Entities"] as TagNodeList; _tileEntities = level["TileEntities"] as TagNodeList; if (level.ContainsKey("TileTicks")) { _tileTicks = level["TileTicks"] as TagNodeList; } else { _tileTicks = new TagNodeList(TagType.TAG_COMPOUND); } // List-type patch up if (_entities.Count == 0) { level["Entities"] = new TagNodeList(TagType.TAG_COMPOUND); _entities = level["Entities"] as TagNodeList; } if (_tileEntities.Count == 0) { level["TileEntities"] = new TagNodeList(TagType.TAG_COMPOUND); _tileEntities = level["TileEntities"] as TagNodeList; } if (_tileTicks.Count == 0) { level["TileTicks"] = new TagNodeList(TagType.TAG_COMPOUND); _tileTicks = level["TileTicks"] as TagNodeList; } _cx = level["xPos"].ToTagInt(); _cz = level["zPos"].ToTagInt(); _blockManager = new AlphaBlockCollection(_blocks, _data, _blockLight, _skyLight, _heightMap, _tileEntities, _tileTicks); _entityManager = new EntityCollection(_entities); _biomeManager = new AnvilBiomeCollection(_biomes); return(this); }
public override TypedEntity LoadTree(TagNode tree) { TagNodeCompound ctree = tree as TagNodeCompound; if (ctree == null || base.LoadTree(tree) == null) { return(null); } _attackTime = ctree["AttackTime"].ToTagShort(); _deathTime = ctree["DeathTime"].ToTagShort(); _health = ctree["Health"].ToTagShort(); _hurtTime = ctree["HurtTime"].ToTagShort(); if (ctree.ContainsKey("CanPickUpLoot")) { _canPickUpLoot = ctree["CanPickUpLoot"].ToTagByte(); } if (ctree.ContainsKey("PersistenceRequired")) { _persistenceRequired = ctree["PersistenceRequired"].ToTagByte(); } if (ctree.ContainsKey("CustomNameVisible")) { _customNameVisible = ctree["CustomNameVisible"].ToTagByte(); } if (ctree.ContainsKey("CustomName")) { _customName = ctree["CustomName"].ToTagString(); } if (ctree.ContainsKey("ActiveEffects")) { TagNodeList ae = ctree["ActiveEffects"].ToTagList(); _activeEffects = new List <ActiveEffects>(); foreach (TagNode tag in ae) { TagNodeCompound effectTag = tag.ToTagCompound(); ActiveEffects effect = new ActiveEffects(); effect.Id = effectTag["Id"].ToTagByte(); effect.Amplifier = effectTag["Amplifier"].ToTagByte(); effect.Duration = effectTag["Duration"].ToTagInt(); effect.Ambient = effectTag["Ambient"].ToTagByte() == 1; _activeEffects.Add(effect); } } if (ctree.ContainsKey("Equipment")) { TagNodeList eq = ctree["Equipment"].ToTagList(); for (int i = 0; i < 5 && i < eq.Count; i++) { _equipment[i] = new Item().LoadTree(eq[i]); } } if (ctree.ContainsKey("DropChances")) { TagNodeList dc = ctree["DropChances"].ToTagList(); for (int i = 0; i < 5 && i < dc.Count; i++) { _dropChances[i] = dc[i].ToTagFloat(); } } return(this); }
public static bool ItemTranslator(TagNodeCompound Target, Item O, Item T) { if (!Target.ContainsKey("tag") || O == null || T == null) { return(false); } TagNodeCompound tag = Target["tag"].ToTagCompound(); string name = "", lore = ""; bool t = false; if (O is Book && T is Book) { Book bo = O as Book, bt = T as Book; string title = ""; string[] pages; lore = T.Lore == "" ? O.Lore : T.Lore; title = bt.Title == "" ? bo.Title : bt.Title; pages = (bt.Pages == "" ? bo.Pages : bt.Pages).Split('\n'); if (tag.ContainsKey("display")) { TagNodeCompound display = tag["display"].ToTagCompound(); if (display.ContainsKey("Lore")) { if (!CheckLore(display, O)) { goto Next; } List <TagNode> nodes = new List <TagNode>(); foreach (string str in lore.Split('\n')) { nodes.Add(new TagNodeString(str.Replace("\r", ""))); } display["Lore"] = new TagNodeList(TagType.TAG_STRING, nodes); t = true; } } Next: if (tag.ContainsKey("title") && tag["title"].ToTagString().Data == bo.Title) { tag["title"] = new TagNodeString(bt.Title); t = true; } if (tag.ContainsKey("pages")) { TagNodeList Pages = tag["pages"].ToTagList(); string pagestr = ""; foreach (TagNodeString s in Pages) { pagestr += "\n" + s.Data; } if (pagestr.Length != 0) { pagestr = pagestr.Substring(1); } if (pagestr == bo.Pages) { List <TagNode> result = new List <TagNode>(); foreach (string s in pages) { result.Add(new TagNodeString(s)); } tag["pages"] = new TagNodeList(TagType.TAG_STRING, result); t = true; } } } else { if (!tag.ContainsKey("display")) { return(false); } TagNodeCompound compound = tag["display"].ToTagCompound(); if (T.Name == "") { name = O.Name; } else { name = T.Name; } if (T.Lore == "") { lore = O.Lore; } else { lore = T.Lore; } if (compound.ContainsKey("Name") || compound.ContainsKey("Lore")) { if (compound.ContainsKey("Lore") && !CheckLore(compound, O)) { return(false); } if (compound.ContainsKey("Name")) { if (compound["Name"].ToTagString().Data == O.Name) { compound["Name"] = new TagNodeString(name); t = true; } else { return(false); } } if (compound.ContainsKey("Lore")) { if (CheckLore(compound, O)) { List <TagNode> nodes = new List <TagNode>(); foreach (string str in lore.Split('\n')) { nodes.Add(new TagNodeString(str.Replace("\r", ""))); } compound["Lore"] = new TagNodeList(TagType.TAG_STRING, nodes); t = true; } else { return(false); } } t = true; } } return(t); }
/// <inheritdoc/> public TagNode BuildTree() { TagNodeCompound tree = new TagNodeCompound(); tree["id"] = new TagNodeShort(_id); tree["Count"] = new TagNodeByte(_count); tree["Damage"] = new TagNodeShort(_damage); TagNodeCompound tagtree = new TagNodeCompound(); if (_enchantments.Count > 0) { TagNodeList enchList = new TagNodeList(TagType.TAG_COMPOUND); foreach (Enchantment e in _enchantments) { enchList.Add(e.BuildTree()); } tagtree["ench"] = enchList; if (_source != null && _source.ContainsKey("tag")) { tagtree.MergeFrom(_source["tag"].ToTagCompound()); } } if (_storedEnchantments.Count > 0) { TagNodeList storedEnchList = new TagNodeList(TagType.TAG_COMPOUND); foreach (Enchantment e in _storedEnchantments) { storedEnchList.Add(e.BuildTree()); } tagtree["StoredEnchantments"] = storedEnchList; if (_source != null && _source.ContainsKey("tag")) { tagtree.MergeFrom(_source["tag"].ToTagCompound()); } } if (_name != null || _lore != null || _color != 0) { TagNodeCompound displayTag = new TagNodeCompound(); if (_color != 0) { displayTag.Add("color", new TagNodeInt(_color)); } if (_name != null) { displayTag.Add("Name", new TagNodeString(_name)); } if (_lore != null) { List <TagNode> LoreList = new List <TagNode>(); string[] lores = _lore.Split('\n'); foreach (string lore in lores) { LoreList.Add(new TagNodeString(lore)); } displayTag.Add("Lore", new TagNodeList(TagType.TAG_STRING, LoreList)); } tagtree["display"] = displayTag; } if (tagtree.Count > 0) { tree["tag"] = tagtree; } if (_source != null) { tree.MergeFrom(_source); } return(tree); }
private static bool FixSpawnData(TagNodeCompound spawnData) { if (!spawnData.ContainsKey("potionValue") && !spawnData.ContainsKey("Potion")) { return(false); } int damage = 0; spawnData["id"] = new TagNodeString("minecraft:potion"); if (spawnData.ContainsKey("potionValue")) { damage = spawnData["potionValue"].ToTagInt(); spawnData.Remove("potionValue"); } if (!spawnData.ContainsKey("Potion")) { spawnData["Potion"] = new TagNodeCompound(); } TagNodeCompound potion = spawnData["Potion"].ToTagCompound(); if (!potion.ContainsKey("tag")) { potion["tag"] = new TagNodeCompound(); } TagNodeCompound tag = potion["tag"].ToTagCompound(); if (!potion.ContainsKey("Count")) { potion["Count"] = new TagNodeByte(1); } if (potion.ContainsKey("Damage")) { if (damage == 0) { damage = potion["Damage"].ToTagInt(); } potion.Remove("Damage"); } potion["id"] = new TagNodeString(ItemInfo.SplashPotion.NameID); if (damage != 0) { string potionEffect = PotionEffects[damage & 15]; string potionPrefix = ""; if ((damage & 32) == 32) { potionPrefix = "strong_"; } else if ((damage & 64) == 64) { potionPrefix = "long_"; } if (potionPrefix == "strong_" && (potionEffect == "fire_resistance" || potionEffect == "night_vision" || potionEffect == "weakness" || potionEffect == "slowness" || potionEffect == "water_breating" || potionEffect == "invisibility")) { tag["Potion"] = new TagNodeString("minecraft:" + potionEffect); } else if (potionPrefix == "long_" && (potionEffect == "healing" || potionEffect == "harming")) { tag["Potion"] = new TagNodeString("minecraft:" + potionEffect); } else { tag["Potion"] = new TagNodeString("minecraft:" + potionPrefix + potionEffect); } } return(true); }
/// <summary> /// Attempt to load a Level subtree into the <see cref="Level"/> without validation. /// </summary> /// <param name="tree">The root node of a Level subtree.</param> /// <returns>The <see cref="Level"/> returns itself on success, or null if the tree was unparsable.</returns> public virtual Level LoadTree(TagNode tree) { TagNodeCompound dtree = tree as TagNodeCompound; if (dtree == null) { return(null); } _version = null; _raining = null; _rainTime = null; _thundering = null; _thunderTime = null; _gameType = null; _mapFeatures = null; TagNodeCompound ctree = dtree["Data"].ToTagCompound(); _time = ctree["Time"].ToTagLong(); _lastPlayed = ctree["LastPlayed"].ToTagLong(); if (ctree.ContainsKey("Player")) { _player = new Player().LoadTree(ctree["Player"]); } _spawnX = ctree["SpawnX"].ToTagInt(); _spawnY = ctree["SpawnY"].ToTagInt(); _spawnZ = ctree["SpawnZ"].ToTagInt(); _sizeOnDisk = ctree["SizeOnDisk"].ToTagLong(); _randomSeed = ctree["RandomSeed"].ToTagLong(); if (ctree.ContainsKey("version")) { _version = ctree["version"].ToTagInt(); } if (ctree.ContainsKey("LevelName")) { _name = ctree["LevelName"].ToTagString(); } if (ctree.ContainsKey("raining")) { _raining = ctree["raining"].ToTagByte(); } if (ctree.ContainsKey("thundering")) { _thundering = ctree["thundering"].ToTagByte(); } if (ctree.ContainsKey("rainTime")) { _rainTime = ctree["rainTime"].ToTagInt(); } if (ctree.ContainsKey("thunderTime")) { _thunderTime = ctree["thunderTime"].ToTagInt(); } if (ctree.ContainsKey("GameType")) { _gameType = ctree["GameType"].ToTagInt(); } if (ctree.ContainsKey("MapFeatures")) { _mapFeatures = ctree["MapFeatures"].ToTagByte(); } if (ctree.ContainsKey("hardcore")) { _hardcore = ctree["hardcore"].ToTagByte(); } if (ctree.ContainsKey("generatorName")) { _generatorName = ctree["generatorName"].ToTagString(); } if (_generatorName == LevelGeneratorNames.FLAT && ctree.ContainsKey("generatorOptions")) { try { _generatorOptions = new LevelGeneratorOptions(ctree["generatorOptions"].ToTagString()); } catch (FormatException) { } } if (ctree.ContainsKey("Difficulty")) { _difficulty = ctree["Difficulty"].ToTagByte(); } if (ctree.ContainsKey("DifficultyLocked")) { _difficultyLocked = ctree["DifficultyLocked"].ToTagByte(); } if (ctree.ContainsKey("allowCommands")) { _allowCommands = ctree["allowCommands"].ToTagByte(); } _source = ctree.Copy() as TagNodeCompound; return(this); }
public LanguageItem(TagNodeCompound tag, LangItemType type) { Type = type; if (type == LangItemType.CommandBlock) { Original = tag["Command"].ToTagString().Data; } else if (type == LangItemType.Sign) { Info = tag["x"].ToTagInt().Data + "," + tag["y"].ToTagInt().Data + "," + tag["z"].ToTagInt().Data; Original = new Sign { Line1 = tag["Text1"].ToTagString().Data, Line2 = tag["Text2"].ToTagString().Data, Line3 = tag["Text3"].ToTagString().Data, Line4 = tag["Text4"].ToTagString().Data }; } else if (type == LangItemType.Container) { Name = tag["id"].ToTagString().Data; Info = tag["x"].ToTagInt().Data + "," + tag["y"].ToTagInt().Data + "," + tag["z"].ToTagInt().Data; Container c = new Container(); if (tag.ContainsKey("CustomName")) { string str = tag["CustomName"].ToTagString().Data; if (Name == "Control" || Name == "minecraft:command_block") { if (str != "" && str != "@") { c.CustomName = Name; } } else if (str != "") { c.CustomName = str; } } if (tag.ContainsKey("Lock") && tag["Lock"].ToTagString().Data != "") { c.Lock = tag["Lock"].ToTagString().Data; } if (tag.Keys.Contains("RecordItem") && tag["RecordItem"].ToTagCompound().ContainsKey("tag")) { TagNodeCompound tag1 = tag["RecordItem"].ToTagCompound()["tag"].ToTagCompound(); Item i = new Item(tag1); if (i.Check()) { c.Items.Add(i); } } if (tag.ContainsKey("Items") && tag["Items"].IsCastableTo(TagType.TAG_LIST)) { foreach (TagNodeCompound tags in tag["Items"].ToTagList()) { if (tags["id"].ToTagString().Data.Contains("written_book")) { Book i = new Book(tags); if (i.Check()) { c.Items.Add(i); } } else { Item i = new Item(tags); if (i.Check()) { c.Items.Add(i); } } } } Original = c; } else if (type == LangItemType.Entity) { Name = tag["id"].ToTagString().Data; Entity e = new Entity(); if (tag.ContainsKey("CustomName")) { e.CustomName = tag["CustomName"].ToTagString().Data; } if (Name.ToLower().Contains("item")) { if (tag.ContainsKey("Item")) { Item item = new Item(tag["Item"].ToTagCompound()); if (item.Check()) { e.Equipments[0] = item; } } } else { if (tag.ContainsKey("HandItems") || tag.ContainsKey("ArmorItems")) { TagNodeList HandItems = tag["HandItems"].ToTagList(); TagNodeList ArmorItems = tag["ArmorItems"].ToTagList(); try { if (HandItems[0].ToTagCompound().ContainsKey("id") && HandItems[0].ToTagCompound()["id"].ToTagString().Data.Contains("written_book")) { Book i = new Book(HandItems[0].ToTagCompound()); if (i.Check()) { e.Equipments[0] = i; } } else { Item i = new Item(HandItems[0].ToTagCompound()); if (i.Check()) { e.Equipments[0] = i; } } } catch { } try { if (HandItems[1].ToTagCompound().ContainsKey("id") && HandItems[1].ToTagCompound()["id"].ToTagString().Data.Contains("written_book")) { Book i = new Book(HandItems[1].ToTagCompound()); if (i.Check()) { e.Equipments[1] = i; } } else { Item i = new Item(HandItems[1].ToTagCompound()); if (i.Check()) { e.Equipments[1] = i; } } } catch { } try { if (ArmorItems[3].ToTagCompound().ContainsKey("id") && ArmorItems[3].ToTagCompound()["id"].ToTagString().Data.Contains("written_book")) { Book i = new Book(ArmorItems[3].ToTagCompound()); if (i.Check()) { e.Equipments[2] = i; } } else { Item i = new Item(ArmorItems[3].ToTagCompound()); if (i.Check()) { e.Equipments[2] = i; } } } catch { } try { if (ArmorItems[2].ToTagCompound().ContainsKey("id") && ArmorItems[2].ToTagCompound()["id"].ToTagString().Data.Contains("written_book")) { Book i = new Book(ArmorItems[2].ToTagCompound()); if (i.Check()) { e.Equipments[3] = i; } } else { Item i = new Item(ArmorItems[2].ToTagCompound()); if (i.Check()) { e.Equipments[3] = i; } } } catch { } try { if (ArmorItems[1].ToTagCompound().ContainsKey("id") && ArmorItems[1].ToTagCompound()["id"].ToTagString().Data.Contains("written_book")) { Book i = new Book(ArmorItems[1].ToTagCompound()); if (i.Check()) { e.Equipments[4] = i; } } else { Item i = new Item(ArmorItems[1].ToTagCompound()); if (i.Check()) { e.Equipments[4] = i; } } } catch { } try { if (ArmorItems[0].ToTagCompound().ContainsKey("id") && ArmorItems[0].ToTagCompound()["id"].ToTagString().Data.Contains("written_book")) { Book i = new Book(ArmorItems[0].ToTagCompound()); if (i.Check()) { e.Equipments[5] = i; } } else { Item i = new Item(ArmorItems[0].ToTagCompound()); if (i.Check()) { e.Equipments[5] = i; } } } catch { } } else if (tag.ContainsKey("Equipment")) { TagNodeList Equipment = tag["Equipment"].ToTagList(); if (Equipment[0].ToTagCompound().ContainsKey("id") && Equipment[0].ToTagCompound()["id"].ToTagString().Data.Contains("written_book")) { Book i = new Book(Equipment[0].ToTagCompound()); if (i.Check()) { e.Equipments[0] = i; } } else { Item i = new Item(Equipment[0].ToTagCompound()); if (i.Check()) { e.Equipments[0] = i; } } if (Equipment[4].ToTagCompound().ContainsKey("id") && Equipment[4].ToTagCompound()["id"].ToTagString().Data.Contains("written_book")) { Book i = new Book(Equipment[4].ToTagCompound()); if (i.Check()) { e.Equipments[2] = i; } } else { Item i = new Item(Equipment[4].ToTagCompound()); if (i.Check()) { e.Equipments[2] = i; } } if (Equipment[3].ToTagCompound().ContainsKey("id") && Equipment[3].ToTagCompound().ContainsKey("id") && Equipment[3].ToTagCompound()["id"].ToTagString().Data.Contains("written_book")) { Book i = new Book(Equipment[3].ToTagCompound()); if (i.Check()) { e.Equipments[3] = i; } } else { Item i = new Item(Equipment[3].ToTagCompound()); if (i.Check()) { e.Equipments[3] = i; } } if (Equipment[2].ToTagCompound().ContainsKey("id") && Equipment[2].ToTagCompound()["id"].ToTagString().Data.Contains("written_book")) { Book i = new Book(Equipment[2].ToTagCompound()); if (i.Check()) { e.Equipments[4] = i; } } else { Item i = new Item(Equipment[2].ToTagCompound()); if (i.Check()) { e.Equipments[4] = i; } } if (Equipment[1].ToTagCompound().ContainsKey("id") && Equipment[1].ToTagCompound()["id"].ToTagString().Data.Contains("written_book")) { Book i = new Book(Equipment[1].ToTagCompound()); if (i.Check()) { e.Equipments[5] = i; } } else { Item i = new Item(Equipment[1].ToTagCompound()); if (i.Check()) { e.Equipments[5] = i; } } Item hand = new Item(Equipment[0].ToTagCompound()); Item armor1 = new Item(Equipment[4].ToTagCompound()); Item armor2 = new Item(Equipment[3].ToTagCompound()); Item armor3 = new Item(Equipment[2].ToTagCompound()); Item armor4 = new Item(Equipment[1].ToTagCompound()); if (hand.Check()) { e.Equipments[0] = hand; } if (armor1.Check()) { e.Equipments[2] = armor1; } if (armor2.Check()) { e.Equipments[3] = armor2; } if (armor3.Check()) { e.Equipments[4] = armor3; } if (armor4.Check()) { e.Equipments[5] = armor4; } } } Original = e; } else if (type == LangItemType.MobSpawner) { Info = tag["x"].ToTagInt().Data + "," + tag["y"].ToTagInt().Data + "," + tag["z"].ToTagInt().Data; Name = tag["SpawnData"].ToTagCompound()["id"].ToTagString().Data; Original = new LanguageItem(tag["SpawnData"].ToTagCompound(), LangItemType.Entity).Original; } }