本文整理汇总了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;
}
示例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);
}
}
示例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;
}
}