コード例 #1
0
 private void OnExperienceOrb(ExperienceOrbPacket p)
 {
     if (ExperienceOrb != null) ExperienceOrb.Invoke(this, new PacketEventArgs<ExperienceOrbPacket>(p));
 }
コード例 #2
0
ファイル: Server.cs プロジェクト: TheaP/c-raft
        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;
        }