Esempio n. 1
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);
        }
Esempio n. 2
0
    public static Vector3 GetPlayerRot()
    {
        TagNodeCompound player = GetPlayerData();
        TagNodeList     Pos    = player["Rotation"] as TagNodeList;
        TagNodeFloat    y      = Pos[0] as TagNodeFloat;
        TagNodeFloat    x      = Pos[1] as TagNodeFloat;
        Vector3         rot    = new Vector3(0, y, x);

        return(rot);
    }
        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);
        }
Esempio n. 4
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);
        }
 public TagFloatDataNode(TagNodeFloat tag)
     : base(tag)
 {
 }