Пример #1
0
        /// <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);
        }
Пример #2
0
        /// <inheritdoc/>
        public Item Copy()
        {
            Item item = new Item();

            item._id     = _id;
            item._count  = _count;
            item._damage = _damage;
            item._color  = _color;
            item._lore   = _lore;
            item._name   = _name;

            foreach (Enchantment e in _enchantments)
            {
                item._enchantments.Add(e.Copy());
            }
            foreach (Enchantment e in _storedEnchantments)
            {
                item._storedEnchantments.Add(e.Copy());
            }

            if (_source != null)
            {
                item._source = _source.Copy() as TagNodeCompound;
            }

            return(item);
        }
Пример #3
0
        /// <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);
        }
Пример #4
0
        /// <inheritdoc />
        public Enchantment Copy()
        {
            Enchantment ench = new Enchantment(_id, _level);

            if (_source != null)
            {
                ench._source = _source.Copy() as TagNodeCompound;
            }

            return(ench);
        }
Пример #5
0
        public virtual BetaDataManager LoadTree(TagNode tree)
        {
            TagNodeCompound ctree = tree as TagNodeCompound;

            if (ctree == null)
            {
                return(null);
            }

            _mapId = ctree["map"].ToTagShort();

            _source = ctree.Copy() as TagNodeCompound;

            return(this);
        }
Пример #6
0
        /// <inheritdoc />
        public Enchantment LoadTree(TagNode tree)
        {
            TagNodeCompound ctree = tree as TagNodeCompound;

            if (ctree == null)
            {
                return(null);
            }

            _id    = ctree["id"].ToTagShort();
            _level = ctree["lvl"].ToTagShort();

            _source = ctree.Copy() as TagNodeCompound;

            return(this);
        }
Пример #7
0
        /// <summary>
        /// Attempt to load a Tile Entity subtree into the <see cref="TileEntity"/> without validation.
        /// </summary>
        /// <param name="tree">The root node of a Tile Entity subtree.</param>
        /// <returns>The <see cref="TileEntity"/> returns itself on success, or null if the tree was unparsable.</returns>
        public virtual TileEntity LoadTree(TagNode tree)
        {
            TagNodeCompound ctree = tree as TagNodeCompound;

            if (ctree == null)
            {
                return(null);
            }

            _id = ctree["id"].ToTagString();
            _x  = ctree["x"].ToTagInt();
            _y  = ctree["y"].ToTagInt();
            _z  = ctree["z"].ToTagInt();

            _source = ctree.Copy() as TagNodeCompound;

            return(this);
        }
Пример #8
0
        /// <summary>
        /// Attempt to load a <see cref="TileTick"/> subtree into the <see cref="TileTick"/> without validation.
        /// </summary>
        /// <param name="tree">The root node of a <see cref="TileTick"/> subtree.</param>
        /// <returns>The <see cref="TileTick"/> returns itself on success, or null if the tree was unparsable.</returns>
        public TileTick LoadTree(TagNode tree)
        {
            TagNodeCompound ctree = tree as TagNodeCompound;

            if (ctree == null)
            {
                return(null);
            }

            _blockId = ctree["i"].ToTagInt();
            _ticks   = ctree["t"].ToTagInt();
            _x       = ctree["x"].ToTagInt();
            _y       = ctree["y"].ToTagInt();
            _z       = ctree["z"].ToTagInt();

            _source = ctree.Copy() as TagNodeCompound;

            return(this);
        }
Пример #9
0
        /// <summary>
        /// Attempt to load an Entity subtree into the <see cref="Entity"/> without validation.
        /// </summary>
        /// <param name="tree">The root node of an Entity subtree.</param>
        /// <returns>The <see cref="Entity"/> returns itself on success, or null if the tree was unparsable.</returns>
        public Entity LoadTree(TagNode tree)
        {
            TagNodeCompound ctree = tree as TagNodeCompound;

            if (ctree == null)
            {
                return(null);
            }

            TagNodeList pos = ctree["Pos"].ToTagList();

            _pos   = new Vector3();
            _pos.X = pos[0].ToTagDouble();
            _pos.Y = pos[1].ToTagDouble();
            _pos.Z = pos[2].ToTagDouble();

            TagNodeList motion = ctree["Motion"].ToTagList();

            _motion   = new Vector3();
            _motion.X = motion[0].ToTagDouble();
            _motion.Y = motion[1].ToTagDouble();
            _motion.Z = motion[2].ToTagDouble();

            TagNodeList rotation = ctree["Rotation"].ToTagList();

            _rotation       = new Orientation();
            _rotation.Yaw   = rotation[0].ToTagFloat();
            _rotation.Pitch = rotation[1].ToTagFloat();

            _fire     = ctree["Fire"].ToTagShort();
            _air      = ctree["Air"].ToTagShort();
            _onGround = ctree["OnGround"].ToTagByte();

            _source = ctree.Copy() as TagNodeCompound;

            return(this);
        }
Пример #10
0
        /// <summary>
        /// Attempt to load a Map subtree into the <see cref="Map"/> without validation.
        /// </summary>
        /// <param name="tree">The root node of a Map subtree.</param>
        /// <returns>The <see cref="Map"/> returns itself on success, or null if the tree was unparsable.</returns>
        public virtual Map LoadTree(TagNode tree)
        {
            TagNodeCompound dtree = tree as TagNodeCompound;

            if (dtree == null)
            {
                return(null);
            }

            TagNodeCompound ctree = dtree["data"].ToTagCompound();

            _scale     = ctree["scale"].ToTagByte();
            _dimension = ctree["dimension"].ToTagByte();
            _height    = ctree["height"].ToTagShort();
            _width     = ctree["width"].ToTagShort();
            _x         = ctree["xCenter"].ToTagInt();
            _z         = ctree["zCenter"].ToTagInt();

            _colors = ctree["colors"].ToTagByteArray();

            _source = ctree.Copy() as TagNodeCompound;

            return(this);
        }
Пример #11
0
        /// <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);
        }
Пример #12
0
        /// <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();
            }

            _source = ctree.Copy() as TagNodeCompound;

            return(this);
        }
Пример #13
0
 public AnvilSection Copy()
 {
     return(new AnvilSection().LoadTree(_tree.Copy()));
 }
Пример #14
0
        /// <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);
        }