Ejemplo n.º 1
0
        /// <summary>
        /// Builds a Player subtree from the current data.
        /// </summary>
        /// <returns>The root node of a Player subtree representing the current data.</returns>
        public virtual new TagNode BuildTree()
        {
            TagNodeCompound tree = base.BuildTree() as TagNodeCompound;

            tree["AttackTime"] = new TagNodeShort(_attackTime);
            tree["DeathTime"]  = new TagNodeShort(_deathTime);
            tree["Health"]     = new TagNodeShort(_health);
            tree["HurtTime"]   = new TagNodeShort(_hurtTime);

            tree["Dimension"]  = new TagNodeInt(_dimension);
            tree["Sleeping"]   = new TagNodeByte(_sleeping);
            tree["SleepTimer"] = new TagNodeShort(_sleepTimer);

            if (_spawnX != null && _spawnY != null && _spawnZ != null)
            {
                tree["SpawnX"] = new TagNodeInt(_spawnX ?? 0);
                tree["SpawnY"] = new TagNodeInt(_spawnY ?? 0);
                tree["SpawnZ"] = new TagNodeInt(_spawnZ ?? 0);
            }

            if (_world != null)
            {
                tree["World"] = new TagNodeString(_world);
            }

            tree["Inventory"] = _inventory.BuildTree();

            return(tree);
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Builds an Entity subtree from the current data.
        /// </summary>
        /// <returns>The root node of an Entity subtree representing the current data.</returns>
        public TagNode BuildTree()
        {
            TagNodeCompound tree = new TagNodeCompound();

            TagNodeList pos = new TagNodeList(TagType.TAG_DOUBLE);

            pos.Add(new TagNodeDouble(_pos.X));
            pos.Add(new TagNodeDouble(_pos.Y));
            pos.Add(new TagNodeDouble(_pos.Z));
            tree["Pos"] = pos;

            TagNodeList motion = new TagNodeList(TagType.TAG_DOUBLE);

            motion.Add(new TagNodeDouble(_motion.X));
            motion.Add(new TagNodeDouble(_motion.Y));
            motion.Add(new TagNodeDouble(_motion.Z));
            tree["Motion"] = motion;

            TagNodeList rotation = new TagNodeList(TagType.TAG_FLOAT);

            rotation.Add(new TagNodeFloat((float)_rotation.Yaw));
            rotation.Add(new TagNodeFloat((float)_rotation.Pitch));
            tree["Rotation"] = rotation;

            tree["FallDistance"] = new TagNodeFloat(_fallDistance);
            tree["Fire"]         = new TagNodeShort(_fire);
            tree["Air"]          = new TagNodeShort(_air);
            tree["OnGround"]     = new TagNodeByte(_onGround);

            return(tree);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Builds a Level subtree from the current data.
        /// </summary>
        /// <returns>The root node of a Level subtree representing the current data.</returns>
        public virtual TagNode BuildTree()
        {
            TagNodeCompound data = new TagNodeCompound();

            data["Time"]       = new TagNodeLong(_time);
            data["LastPlayed"] = new TagNodeLong(_lastPlayed);

            if (_player != null)
            {
                data["Player"] = _player.BuildTree();
            }

            data["SpawnX"]     = new TagNodeInt(_spawnX);
            data["SpawnY"]     = new TagNodeInt(_spawnY);
            data["SpawnZ"]     = new TagNodeInt(_spawnZ);
            data["SizeOnDisk"] = new TagNodeLong(_sizeOnDisk);
            data["RandomSeed"] = new TagNodeLong(_randomSeed);

            if (_version != null && _version != 0)
            {
                data["version"] = new TagNodeInt(_version ?? 0);
            }

            if (_name != null)
            {
                data["LevelName"] = new TagNodeString(_name);
            }

            if (_raining != null)
            {
                data["raining"] = new TagNodeByte(_raining ?? 0);
            }
            if (_thundering != null)
            {
                data["thundering"] = new TagNodeByte(_thundering ?? 0);
            }
            if (_rainTime != null)
            {
                data["rainTime"] = new TagNodeInt(_rainTime ?? 0);
            }
            if (_thunderTime != null)
            {
                data["thunderTime"] = new TagNodeInt(_thunderTime ?? 0);
            }

            if (_gameType != null)
            {
                data["GameType"] = new TagNodeInt(_gameType ?? 0);
            }
            if (_mapFeatures != null)
            {
                data["MapFeatures"] = new TagNodeByte(_mapFeatures ?? 0);
            }

            TagNodeCompound tree = new TagNodeCompound();

            tree.Add("Data", data);

            return(tree);
        }
Ejemplo n.º 5
0
        public override TagNode BuildTree()
        {
            TagNodeCompound tree = base.BuildTree() as TagNodeCompound;

            tree["Saddle"] = new TagNodeByte((byte)(_saddle ? 1 : 0));

            return(tree);
        }
Ejemplo n.º 6
0
        public override TagNode BuildTree()
        {
            TagNodeCompound tree = base.BuildTree() as TagNodeCompound;

            tree["note"] = new TagNodeByte(_note);

            return(tree);
        }
Ejemplo n.º 7
0
        public override TagNode BuildTree()
        {
            TagNodeCompound tree = base.BuildTree() as TagNodeCompound;

            tree["Sheared"] = new TagNodeByte((byte)(_sheared ? 1 : 0));
            tree["Color"]   = new TagNodeByte(_color);

            return(tree);
        }
Ejemplo n.º 8
0
        public override TagNode BuildTree()
        {
            TagNodeCompound tree = base.BuildTree() as TagNodeCompound;

            tree["AttackTime"]          = new TagNodeShort(_attackTime);
            tree["DeathTime"]           = new TagNodeShort(_deathTime);
            tree["Health"]              = new TagNodeShort(_health);
            tree["HurtTime"]            = new TagNodeShort(_hurtTime);
            tree["CanPickUpLoot"]       = new TagNodeByte(_canPickUpLoot);
            tree["PersistenceRequired"] = new TagNodeByte(_persistenceRequired);
            tree["CustomName"]          = new TagNodeString(_customName);
            tree["CustomNameVisible"]   = new TagNodeByte(_customNameVisible);

            if (_activeEffects != null)
            {
                TagNodeList effects = new TagNodeList(TagType.TAG_COMPOUND);
                foreach (ActiveEffects effect in _activeEffects)
                {
                    if (!effect.IsValid)
                    {
                        continue;
                    }
                    TagNodeCompound ae = new TagNodeCompound();
                    ae["Id"]        = new TagNodeByte((byte)effect.Id);
                    ae["Amplifier"] = new TagNodeByte((byte)effect.Amplifier);
                    ae["Duration"]  = new TagNodeInt(effect.Duration);
                    ae["Ambient"]   = new TagNodeByte(effect.Ambient ? (byte)1 : (byte)0);
                    effects.Add(ae);
                }

                tree["ActiveEffects"] = effects;
            }
            if (_equipment != null)
            {
                TagNodeList equipment = new TagNodeList(TagType.TAG_COMPOUND);
                foreach (Item item in _equipment)
                {
                    equipment.Add(item.BuildTree());
                }

                tree["Equipment"] = equipment;
            }
            if (_dropChances != null)
            {
                TagNodeList dropChances = new TagNodeList(TagType.TAG_FLOAT);

                foreach (float dc in _dropChances)
                {
                    dropChances.Add(new TagNodeFloat(dc));
                }

                tree["DropChances"] = dropChances;
            }

            return(tree);
        }
Ejemplo n.º 9
0
        public override TagNode BuildTree()
        {
            TagNodeCompound tree = base.BuildTree() as TagNodeCompound;

            tree["Owner"]   = new TagNodeString(_owner);
            tree["Sitting"] = new TagNodeByte((byte)(_sitting ? 1 : 0));
            tree["Angry"]   = new TagNodeByte((byte)(_angry ? 1 : 0));

            return(tree);
        }
Ejemplo n.º 10
0
        /// <inheritdoc/>
        public TagNode BuildTree()
        {
            TagNodeCompound tree = new TagNodeCompound();

            tree["id"]     = new TagNodeShort(_id);
            tree["Count"]  = new TagNodeByte(_count);
            tree["Damage"] = new TagNodeShort(_damage);

            return(tree);
        }
Ejemplo n.º 11
0
        public override TagNode BuildTree()
        {
            TagNodeCompound tree = base.BuildTree() as TagNodeCompound;

            if (_powered != null)
            {
                tree["powered"] = new TagNodeByte((byte)((_powered ?? false) ? 1 : 0));
            }

            return(tree);
        }
Ejemplo n.º 12
0
        public override TagNode BuildTree()
        {
            TagNodeCompound tree = base.BuildTree() as TagNodeCompound;

            tree["Dir"]    = new TagNodeByte((byte)_dir);
            tree["Motive"] = new TagNodeString(_motive);
            tree["TileX"]  = new TagNodeInt(_xTile);
            tree["TileY"]  = new TagNodeInt(_yTile);
            tree["TileZ"]  = new TagNodeInt(_zTile);

            return(tree);
        }
Ejemplo n.º 13
0
        public override TagNode BuildTree()
        {
            TagNodeCompound tree = base.BuildTree() as TagNodeCompound;

            tree["xTile"]    = new TagNodeShort(_xTile);
            tree["yTile"]    = new TagNodeShort(_yTile);
            tree["zTile"]    = new TagNodeShort(_zTile);
            tree["inTile"]   = new TagNodeByte(_inTile);
            tree["inGround"] = new TagNodeByte(_inGround);

            return(tree);
        }
Ejemplo n.º 14
0
        /// <inheritdoc/>
        public TagNode BuildTree()
        {
            TagNodeList list = new TagNodeList(TagType.TAG_COMPOUND);

            foreach (KeyValuePair <int, Item> item in _items)
            {
                TagNodeCompound itemtree = item.Value.BuildTree() as TagNodeCompound;
                itemtree["Slot"] = new TagNodeByte((byte)item.Key);
                list.Add(itemtree);
            }

            return(list);
        }
        public override TagNode BuildTree()
        {
            TagNodeCompound tree = base.BuildTree() as TagNodeCompound;

            if (_record != null)
            {
                tree["blockId"]   = new TagNodeInt(_blockId);
                tree["blockData"] = new TagNodeInt(_blockData);
                tree["facing"]    = new TagNodeInt(_facing);
                tree["progress"]  = new TagNodeFloat(_progress);
                tree["extending"] = new TagNodeByte(_extending);
            }

            return(tree);
        }
Ejemplo n.º 16
0
        public override TagNode BuildTree()
        {
            TagNodeCompound tree = base.BuildTree() as TagNodeCompound;

            tree["AttackTime"] = new TagNodeShort(_attackTime);
            tree["DeathTime"]  = new TagNodeShort(_deathTime);
            tree["Health"]     = new TagNodeShort(_health);
            tree["HurtTime"]   = new TagNodeShort(_hurtTime);

            if (_activeEffects != null)
            {
                TagNodeCompound ae = new TagNodeCompound();
                ae["Id"]        = new TagNodeByte((byte)_activeEffects.Id);
                ae["Amplifier"] = new TagNodeByte((byte)_activeEffects.Amplifier);
                ae["Duration"]  = new TagNodeInt(_activeEffects.Duration);

                tree["ActiveEffects"] = ae;
            }

            return(tree);
        }
Ejemplo n.º 17
0
    // Use this for initialization
    void Start()
    {
        Physics.queriesHitBackfaces = true;

        Cursor.lockState = CursorLockMode.Locked;
        camera           = transform.Find("camera");
        vcamWide         = camera.Find("vcam_wide").gameObject;
        cc           = GetComponent <CharacterController>();
        handCam      = Camera.main.transform.Find("Camera").GetComponent <Camera>();
        handAnimator = Camera.main.transform.Find("hand").GetComponent <Animator>();

        m_HeadBob.Setup(camera, 5);

        TagNodeCompound levelDat  = NBTHelper.GetLevelDat();
        TagNodeCompound player    = levelDat["Player"] as TagNodeCompound;
        TagNodeCompound abilities = player["abilities"] as TagNodeCompound;
        TagNodeByte     flying    = abilities["flying"] as TagNodeByte;

        isFlying = flying == 1 ? true : false;

        transform.position                = DataCenter.spawnPosition;
        transform.localEulerAngles        = new Vector3(0, -DataCenter.spawnRotation.y, 0);
        camera.transform.localEulerAngles = new Vector3(DataCenter.spawnRotation.z, 0, 0);

        //NetworkManager.Register(ENUM_CMD.CS_ADD_BLOCK_NOTIFY, OnAddBlockNotify);
        //NetworkManager.Register(ENUM_CMD.CS_DELETE_BLOCK_NOTIFY, OnDeleteBlockNotify);

        LoadingUI.Close();
        CrossHair.Show();
        Hand.Show();

        blockMeshFilter   = Camera.main.transform.Find("hand/block").GetComponent <MeshFilter>();
        blockMeshRenderer = Camera.main.transform.Find("hand/block").GetComponent <MeshRenderer>();
        handMeshRenderer  = Camera.main.transform.Find("hand").GetComponent <MeshRenderer>();

        position = transform.position;
        forward  = transform.forward;

        isInitialized = true;
    }
Ejemplo n.º 18
0
        /// <summary>
        /// Builds a Map subtree from the current data.
        /// </summary>
        /// <returns>The root node of a Map subtree representing the current data.</returns>
        public virtual TagNode BuildTree()
        {
            TagNodeCompound data = new TagNodeCompound();

            data["scale"]     = new TagNodeByte(_scale);
            data["dimension"] = new TagNodeByte(_dimension);
            data["height"]    = new TagNodeShort(_height);
            data["width"]     = new TagNodeShort(_width);
            data["xCenter"]   = new TagNodeInt(_x);
            data["zCenter"]   = new TagNodeInt(_z);

            data["colors"] = new TagNodeByteArray(_colors);

            if (_source != null)
            {
                data.MergeFrom(_source);
            }

            TagNodeCompound tree = new TagNodeCompound();

            tree.Add("data", data);

            return(tree);
        }
Ejemplo n.º 19
0
        /// <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);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Builds a Level subtree from the current data.
        /// </summary>
        /// <returns>The root node of a Level subtree representing the current data.</returns>
        public virtual TagNode BuildTree()
        {
            TagNodeCompound data = new TagNodeCompound();

            data["Time"]       = new TagNodeLong(_time);
            data["LastPlayed"] = new TagNodeLong(_lastPlayed);

            if (_player != null)
            {
                data["Player"] = _player.BuildTree();
            }

            data["SpawnX"]     = new TagNodeInt(_spawnX);
            data["SpawnY"]     = new TagNodeInt(_spawnY);
            data["SpawnZ"]     = new TagNodeInt(_spawnZ);
            data["SizeOnDisk"] = new TagNodeLong(_sizeOnDisk);
            data["RandomSeed"] = new TagNodeLong(_randomSeed);

            if (_version != null && _version != 0)
            {
                data["version"] = new TagNodeInt(_version ?? 0);
            }

            if (_name != null)
            {
                data["LevelName"] = new TagNodeString(_name);
            }

            if (_raining != null)
            {
                data["raining"] = new TagNodeByte(_raining ?? 0);
            }
            if (_thundering != null)
            {
                data["thundering"] = new TagNodeByte(_thundering ?? 0);
            }
            if (_rainTime != null)
            {
                data["rainTime"] = new TagNodeInt(_rainTime ?? 0);
            }
            if (_thunderTime != null)
            {
                data["thunderTime"] = new TagNodeInt(_thunderTime ?? 0);
            }

            if (_gameType != null)
            {
                data["GameType"] = new TagNodeInt(_gameType ?? 0);
            }
            if (_mapFeatures != null)
            {
                data["MapFeatures"] = new TagNodeByte(_mapFeatures ?? 0);
            }
            if (_hardcore != null)
            {
                data["hardcore"] = new TagNodeByte(_hardcore ?? 0);
            }

            if (_generatorName != null)
            {
                data["generatorName"] = new TagNodeString(_generatorName);
            }
            if (_generatorOptions != null)
            {
                data["generatorOptions"] = new TagNodeString(_generatorOptions.GetGeneratorOptions());
            }
            else
            {
                data["generatorOptions"] = new TagNodeString("");
            }
            if (_difficulty != null)
            {
                data["Difficulty"] = new TagNodeByte(_difficulty ?? 0);
            }
            if (_difficultyLocked != null)
            {
                data["DifficultyLocked"] = new TagNodeByte(_difficultyLocked ?? 0);
            }
            if (_allowCommands != null)
            {
                data["allowCommands"] = new TagNodeByte(_allowCommands ?? 0);
            }


            if (_source != null)
            {
                data.MergeFrom(_source);
            }

            TagNodeCompound tree = new TagNodeCompound();

            tree.Add("Data", data);

            return(tree);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Builds a Level subtree from the current data.
        /// </summary>
        /// <returns>The root node of a Level subtree representing the current data.</returns>
        public virtual TagNode BuildTree()
        {
            TagNodeCompound data = new TagNodeCompound();

            data["Time"]       = new TagNodeLong(_time);
            data["LastPlayed"] = new TagNodeLong(_lastPlayed);

            if (_player != null)
            {
                data["Player"] = _player.BuildTree();
            }

            data["SpawnX"]     = new TagNodeInt(_spawnX);
            data["SpawnY"]     = new TagNodeInt(_spawnY);
            data["SpawnZ"]     = new TagNodeInt(_spawnZ);
            data["SizeOnDisk"] = new TagNodeLong(_sizeOnDisk);
            data["RandomSeed"] = new TagNodeLong(_randomSeed);

            if (_version != null && _version != 0)
            {
                data["version"] = new TagNodeInt(_version ?? 0);
            }

            if (_name != null)
            {
                data["LevelName"] = new TagNodeString(_name);
            }

            if (_generator != null)
            {
                data["generatorName"] = new TagNodeString(_generator);
            }

            if (_raining != null)
            {
                data["raining"] = new TagNodeByte(_raining ?? 0);
            }
            if (_thundering != null)
            {
                data["thundering"] = new TagNodeByte(_thundering ?? 0);
            }
            if (_rainTime != null)
            {
                data["rainTime"] = new TagNodeInt(_rainTime ?? 0);
            }
            if (_thunderTime != null)
            {
                data["thunderTime"] = new TagNodeInt(_thunderTime ?? 0);
            }

            if (_gameType != null)
            {
                data["GameType"] = new TagNodeInt(_gameType ?? 0);
            }
            if (_mapFeatures != null)
            {
                data["MapFeatures"] = new TagNodeByte(_mapFeatures ?? 0);
            }
            if (_hardcore != null)
            {
                data["hardcore"] = new TagNodeByte(_hardcore ?? 0);
            }

            if (_generatorOptions != null)
            {
                data["generatorOptions"] = new TagNodeString(_generatorOptions);
            }
            if (_generatorVersion != null)
            {
                data["generatorVersion"] = new TagNodeInt(_generatorVersion ?? 0);
            }
            if (_allowCommands != null)
            {
                data["allowCommands"] = new TagNodeByte(_allowCommands ?? 0);
            }
            if (_initialized != null)
            {
                data["initialized"] = new TagNodeByte(_initialized ?? 0);
            }
            if (_DayTime != null)
            {
                data["DayTime"] = new TagNodeLong(_DayTime ?? 0);
            }
            TagNodeCompound gr = new TagNodeCompound();

            gr["commandBlockOutput"] = new TagNodeString(_gameRules.CommandBlockOutput ? "true" : "false");
            gr["doFireTick"]         = new TagNodeString(_gameRules.DoFireTick ? "true" : "false");
            gr["doMobLoot"]          = new TagNodeString(_gameRules.DoMobLoot ? "true" : "false");
            gr["doMobSpawning"]      = new TagNodeString(_gameRules.DoMobSpawning ? "true" : "false");
            gr["doTileDrops"]        = new TagNodeString(_gameRules.DoTileDrops ? "true" : "false");
            gr["keepInventory"]      = new TagNodeString(_gameRules.KeepInventory ? "true" : "false");
            gr["mobGriefing"]        = new TagNodeString(_gameRules.MobGriefing ? "true" : "false");
            data["GameRules"]        = gr;

            if (_source != null)
            {
                data.MergeFrom(_source);
            }

            TagNodeCompound tree = new TagNodeCompound();

            tree.Add("Data", data);

            return(tree);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Builds a Player subtree from the current data.
        /// </summary>
        /// <returns>The root node of a Player subtree representing the current data.</returns>
        public virtual new TagNode BuildTree()
        {
            TagNodeCompound tree = base.BuildTree() as TagNodeCompound;

            tree["AttackTime"] = new TagNodeShort(_attackTime);
            tree["DeathTime"]  = new TagNodeShort(_deathTime);
            tree["Health"]     = new TagNodeShort(_health);
            tree["HurtTime"]   = new TagNodeShort(_hurtTime);

            tree["Dimension"]  = new TagNodeInt(_dimension);
            tree["Sleeping"]   = new TagNodeByte(_sleeping);
            tree["SleepTimer"] = new TagNodeShort(_sleepTimer);

            if (_spawnX != null && _spawnY != null && _spawnZ != null)
            {
                tree["SpawnX"] = new TagNodeInt(_spawnX ?? 0);
                tree["SpawnY"] = new TagNodeInt(_spawnY ?? 0);
                tree["SpawnZ"] = new TagNodeInt(_spawnZ ?? 0);
            }
            else
            {
                tree.Remove("SpawnX");
                tree.Remove("SpawnY");
                tree.Remove("SpawnZ");
            }

            if (_world != null)
            {
                tree["World"] = new TagNodeString(_world);
            }

            if (_foodLevel != null)
            {
                tree["foodLevel"] = new TagNodeInt(_foodLevel ?? 0);
            }
            if (_foodTickTimer != null)
            {
                tree["foodTickTimer"] = new TagNodeInt(_foodTickTimer ?? 0);
            }
            if (_foodExhaustion != null)
            {
                tree["foodExhaustionLevel"] = new TagNodeFloat(_foodExhaustion ?? 0);
            }
            if (_foodSaturation != null)
            {
                tree["foodSaturation"] = new TagNodeFloat(_foodSaturation ?? 0);
            }
            if (_xpP != null)
            {
                tree["XpP"] = new TagNodeFloat(_xpP ?? 0);
            }
            if (_xpLevel != null)
            {
                tree["XpLevel"] = new TagNodeInt(_xpLevel ?? 0);
            }
            if (_xpTotal != null)
            {
                tree["XpTotal"] = new TagNodeInt(_xpTotal ?? 0);
            }
            if (_score != null)
            {
                tree["Score"] = new TagNodeInt(_score ?? 0);
            }

            if (_gameType != null)
            {
                tree["PlayerGameType"] = new TagNodeInt((int)(_gameType ?? PlayerGameType.Survival));
            }

            if (AbilitiesSet())
            {
                TagNodeCompound pb = new TagNodeCompound();
                pb["flying"]       = new TagNodeByte(_abilities.Flying ? (byte)1 : (byte)0);
                pb["instabuild"]   = new TagNodeByte(_abilities.InstantBuild ? (byte)1 : (byte)0);
                pb["mayfly"]       = new TagNodeByte(_abilities.MayFly ? (byte)1 : (byte)0);
                pb["invulnerable"] = new TagNodeByte(_abilities.Invulnerable ? (byte)1 : (byte)0);
                pb["mayBuild"]     = new TagNodeByte(_abilities.MayBuild ? (byte)1 : (byte)0);
                pb["walkSpeed"]    = new TagNodeFloat(_abilities.WalkSpeed);
                pb["flySpeed"]     = new TagNodeFloat(_abilities.FlySpeed);

                tree["abilities"] = pb;
            }

            tree["Inventory"]  = _inventory.BuildTree();
            tree["EnderItems"] = _enderItems.BuildTree();

            return(tree);
        }
Ejemplo n.º 23
0
        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);
        }
Ejemplo n.º 24
0
 public TagByteDataNode(TagNodeByte tag)
     : base(tag)
 {
 }