예제 #1
0
파일: Entity.cs 프로젝트: xorle/MineEdit
        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));
            }
        }
예제 #2
0
 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;
 }
예제 #3
0
 public LivingEntity(NbtCompound c)
 {
     SetBaseStuff(c);
     if (!c.Has("HurtTime"))
     {
         Console.WriteLine(c);
         return;
     }
     Air        = (c["Air"] as NbtShort).Value;
     Fire       = (c["Fire"] as NbtShort).Value;
     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;
 }
예제 #4
0
파일: Minecart.cs 프로젝트: xorle/MineEdit
        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;
            }
        }
예제 #5
0
파일: Entity.cs 프로젝트: N3X15/MineEdit
        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);
            }
        }
예제 #6
0
파일: Minecart.cs 프로젝트: N3X15/MineEdit
        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;
            }
        }