public void OnModMessageReceived(object sender, ModMessageReceivedEventArgs e) { #if DEBUG ModEntry.ModMonitor.Log($"Received message.\n\tFromPlayer: \"{e.FromPlayerID}\"\n\tFromMod: \"{e.FromModID}\"\n\tType: \"{e.Type}\"", LogLevel.Trace); #endif Type messageType = typeof(EmoteMessage); if (e.FromModID != helper.ModRegistry.ModID || e.Type != messageType.ToString()) { return; } EmoteMessage message = e.ReadAs <EmoteMessage>(); switch (message.EmoteSourceType) { case CharacterType.Farmer: if (long.TryParse(message.EmoteSourceId, out long farmerId)) { Farmer farmer = Game1.getFarmer(farmerId); if (farmer != null) { FarmerPatch.DoEmotePatch.Instance.PostfixEnabled = false; farmer.PlayEmote(message.EmoteIndex); FarmerPatch.DoEmotePatch.Instance.PostfixEnabled = true; } } break; case CharacterType.NPC: NPC npc = Game1.getCharacterFromName(message.EmoteSourceId, mustBeVillager: false); if (npc != null && !npc.IsEmoting) { CharacterPatch.DoEmotePatch.Instance.PostfixEnabled = false; npc.PlayEmote(message.EmoteIndex); CharacterPatch.DoEmotePatch.Instance.PostfixEnabled = true; } break; case CharacterType.FarmAnimal: if (long.TryParse(message.EmoteSourceId, out long farmAnimalId)) { FarmAnimal farmAnimal = Game1.getFarm().getAllFarmAnimals().FirstOrDefault(x => x?.myID.Value == farmAnimalId); if (farmAnimal != null && !farmAnimal.IsEmoting) { CharacterPatch.DoEmotePatch.Instance.PostfixEnabled = false; farmAnimal.PlayEmote(message.EmoteIndex); CharacterPatch.DoEmotePatch.Instance.PostfixEnabled = true; } } break; case CharacterType.Unknown: default: break; } }