internal void TrackEntity(Entity entity) { if (!KnownEntities.Contains(entity.EntityId)) { KnownEntities.Add(entity.EntityId); if (entity is PlayerEntity) { var player = entity as PlayerEntity; var selectedItem = player.SelectedItem.Id; if (selectedItem == -1) { selectedItem = 0; } SendPacket(new SpawnPlayerPacket(player.EntityId, UUID, player.Username, MathHelper.CreateAbsoluteInt(player.Position.X), MathHelper.CreateAbsoluteInt(player.Position.Y), MathHelper.CreateAbsoluteInt(player.Position.Z), MathHelper.CreateRotationByte(player.Yaw), MathHelper.CreateRotationByte(player.Pitch), selectedItem, player.Metadata)); if (!player.SelectedItem.Empty) { SendPacket(new EntityEquipmentPacket(entity.EntityId, EntityEquipmentPacket.EntityEquipmentSlot.HeldItem, player.SelectedItem)); } // TODO: Send armor } else if (entity is ObjectEntity) { var objectEntity = entity as ObjectEntity; SendPacket(new SpawnObjectPacket(objectEntity.EntityId, objectEntity.EntityType, MathHelper.CreateAbsoluteInt(objectEntity.Position.X), MathHelper.CreateAbsoluteInt(objectEntity.Position.Y), MathHelper.CreateAbsoluteInt(objectEntity.Position.Z), MathHelper.CreateRotationByte(objectEntity.Yaw), MathHelper.CreateRotationByte(objectEntity.Pitch), objectEntity.Data, 0, 0, 0)); // TODO: Velocity stuff here if (objectEntity.SendMetadataToClients) { SendPacket(new EntityMetadataPacket(objectEntity.EntityId, objectEntity.Metadata)); } } } }
private void addToKnown(List <IMappable> knownObjects) { foreach (var obj in knownObjects) { if (obj is Entity) { KnownEntities.Add(obj as Entity); } else if (obj is Item) { KnownItems.Add(obj as Item); } } }