当前位置: 首页>>代码示例>>C#>>正文


C# NbtCompound.Has方法代码示例

本文整理汇总了C#中NbtCompound.Has方法的典型用法代码示例。如果您正苦于以下问题:C# NbtCompound.Has方法的具体用法?C# NbtCompound.Has怎么用?C# NbtCompound.Has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NbtCompound的用法示例。


在下文中一共展示了NbtCompound.Has方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LivingEntity

 public LivingEntity(NbtCompound c)
 {
     SetBaseStuff(c);
     if (!c.Has("HurtTime"))
     {
         Console.WriteLine(c);
         return;
     }
     lolID = (c["id"] as NbtString).Value;
     Health = (c["Health"] as NbtShort).Value;
     HurtTime = (c["HurtTime"] as NbtShort).Value;
     AttackTime = (c["AttackTime"] as NbtShort).Value;
     DeathTime = (c["DeathTime"] as NbtShort).Value;
 }
开发者ID:aphistic,项目名称:MineEdit,代码行数:14,代码来源:LivingEntity.cs

示例2: GetEntity

        public static Entity GetEntity(NbtCompound c)
        {
            if (!c.Has("id"))
            {
                Console.WriteLine(c.ToString());
            }

            if (c.Has("x") && c.Has("y") && c.Has("z"))
                throw new Exception("TileEntity is in Entities compound!?");

            string entID = c.Get<NbtString>("id").Value;
            if (entID == "NULL") return null;
            if (EntityTypes.ContainsKey(entID))
            {
                try
                {
                    return (Entity)EntityTypes[entID].GetConstructor(new Type[] { typeof(NbtCompound) }).Invoke(new Object[] { c });
                }
                catch (TargetInvocationException e)
                {
                    Console.WriteLine("Failed to load " + entID + ": \n" + e.InnerException.ToString());
                    throw e.InnerException;
                }
            }

            // Try to figure out what the hell this is.

            if (!Directory.Exists("Entities"))
                Directory.CreateDirectory("Entities");

            // Do we have a LivingEntity or just an Entity?
            // Quick and simple test: health.
            if (c.Has("Health") && entID!="Item")
            {
                GenTemplate(c, "livingentity.template");
                // Goodie, just whip up a new LivingEntity and we're relatively home free.
                return new LivingEntity(c);
            }
            else
            {
                GenTemplate(c, "entity.template");
                return new Entity(c);
            }
        }
开发者ID:N3X15,项目名称:MineEdit,代码行数:44,代码来源:Entity.cs

示例3: Minecart

        public Minecart(NbtCompound c)
        {
            SetBaseStuff(c);

            Type = (MinecartType)c.Get<NbtInt>("Type").Value;
            if (c.Has("PushX"))
            {
                PushX = c.Get<NbtDouble>("PushX").Value;
                PushZ = c.Get<NbtDouble>("PushZ").Value;
                Fuel = c.Get<NbtShort>("Fuel").Value;
            }
            else
            {
                PushX = 0;
                PushZ = 0;
                Fuel = 0;
            }
        }
开发者ID:N3X15,项目名称:MineEdit,代码行数:18,代码来源:Minecart.cs


注:本文中的NbtCompound.Has方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。