Esempio n. 1
0
 private void OnMobSpawn(MobSpawnPacket p)
 {
     if (MobSpawn != null) MobSpawn.Invoke(this, new PacketEventArgs<MobSpawnPacket>(p));
 }
Esempio n. 2
0
        public static Packet GetSpawnPacket(Server server, EntityBase entity)
        {
            Packet packet = null;
            if (entity is Player)
            {
                Player p = ((Player)entity);

                packet = new NamedEntitySpawnPacket
                {
                    EntityId = p.EntityId,
                    X = p.Position.X,
                    Y = p.Position.Y,
                    Z = p.Position.Z,
                    Yaw = p.PackedYaw,
                    Pitch = p.PackedPitch,
                    PlayerName = p.Client.Username + p.EntityId,
                    CurrentItem = 0
                };
            }
            else if (entity is ItemEntity)
            {
                ItemEntity item = (ItemEntity)entity;
                packet = new SpawnItemPacket
                {
                    X = item.Position.X,
                    Y = item.Position.Y,
                    Z = item.Position.Z,
                    Yaw = item.PackedYaw,
                    Pitch = item.PackedPitch,
                    EntityId = item.EntityId,
                    ItemId = item.ItemId,
                    Count = item.Count,
                    Durability = item.Durability,
                    Roll = 0
                };
            }
            else if (entity is Mob)
            {
                Mob mob = (Mob)entity;
                server.Logger.Log(Logger.LogLevel.Debug, ("ClientSpawn: Sending Mob " + mob.Type + " (" + mob.Position.X + ", " + mob.Position.Y + ", " + mob.Position.Z + ")"));
                packet = new MobSpawnPacket
                {
                    X = mob.Position.X,
                    Y = mob.Position.Y,
                    Z = mob.Position.Z,
                    Yaw = mob.PackedYaw,
                    Pitch = mob.PackedPitch,
                    EntityId = mob.EntityId,
                    Type = mob.Type,
                    Data = mob.Data
                };
            }

            return packet;
        }
Esempio n. 3
0
        public Packet GetSpawnPacket(EntityBase entity)
        {
            Packet packet = null;
            if (entity is Player)
            {
                Player p = ((Player)entity);

                packet = new NamedEntitySpawnPacket
                {
                    EntityId = p.EntityId,
                    X = p.Position.X,
                    Y = p.Position.Y,
                    Z = p.Position.Z,
                    Yaw = p.PackedYaw,
                    Pitch = p.PackedPitch,
                    PlayerName = p.Client.Username + p.EntityId,
                    CurrentItem = 0,
                    Data = new MetaData()
                };
            }
            else if (entity is Mob)
            {
                Mob mob = (Mob)entity;
                Logger.Log(LogLevel.Debug, ("ClientSpawn: Sending Mob " + mob.Type + " (" + mob.Position.X + ", " + mob.Position.Y + ", " + mob.Position.Z + ")"));
                packet = new MobSpawnPacket
                {
                    X = mob.Position.X,
                    Y = mob.Position.Y,
                    Z = mob.Position.Z,
                    Yaw = mob.PackedYaw,
                    Pitch = mob.PackedPitch,
                    EntityId = mob.EntityId,
                    Type = mob.Type,
                    Data = mob.Data
                };
            }
            else if (entity is ExpOrbEntity)
            {
                var orb = (ExpOrbEntity)entity;
                var coords = UniversalCoords.FromAbsWorld(orb.Position);
                packet = new ExperienceOrbPacket
                {
                    EntityId = orb.EntityId,
                    Count = 1,
                    X = coords.WorldX,
                    Y = coords.WorldY,
                    Z = coords.WorldZ
                };
            }

            return packet;
        }
Esempio n. 4
0
 public static void ReadMobSpawn(TestClient client, PacketReader reader)
 {
     MobSpawnPacket ms = new MobSpawnPacket();
     ms.Read(reader);
 }