Description
## Touhou Little Maid: Epistalove
This mod is an add-on for **Contact: LoveRekindled** and **Touhou Little Maid**, allowing maids to write letters to their masters.
You can get a quick overview from this
[Bilibili video](https://www.bilibili.com/video/BV1apxbznEiq).
### Letter Content
Letters can be generated in two ways: **AI-generated** or **preset text**, with full customization through **data packs** or **KubeJS**. See the [**official documentation**](https://doc.sighs.cc/TLME/dev) for details.
To enable AI generation, follow the steps in the
[**official Touhou Little Maid guide**](https://www.bilibili.com/opus/1071601611768332294).
AI generation is highly recommended — it can use in-game environmental data as prompts, allowing letters to naturally adapt to different situations.
### When Letters Are Written
By talking to a maid using AI dialogue (press **T** on the maid), you can directly request a letter. This requires enabling the **Function Call** feature of Touhou Little Maid.


In other cases, maids write letters based on configured rules. See the [**official documentation**](https://doc.sighs.cc/TLME/dev).
Letter delivery works as follows:
- **Following mode:** the maid hands the letter directly to the player.
- **HOME mode + nearby mailbox:** the maid mails it through Epistalove; the player must retrieve it from their personal mailbox.
- **HOME mode + no mailbox nearby:** the maid will hold the letter until a player or mailbox appears.
### Best Example
The following KubeJS example makes the maid write a letter every time you earn a new advancement, with content related to that advancement.
For most well-known mods, the AI can recognize their advancements.
```javascript
// server_scripts
LetterEvents.registerLetterRules(event => {
// AI: First Gift
event.createAI('advancement','lonesome',
'As a maid, your master has just completed the Minecraft advancement ${adv}. This is an important moment—please write a short letter to your master about it.')
.trigger('advancement').repeat().minAffection(0).maxAffection(500).cooldown(0).register();
});
PlayerEvents.advancement(event => {
let advancement = event.advancement;
if (advancement.description.empty) return;
let str = `${advancement.displayText.getString()}:${advancement.description.getString()}`;
if (advancement.description.getContents().getKey()) str += `(${advancement.description.getContents().getKey()})`;
LetterAPI.triggerEventWithContext(event.player, "advancement", { adv: str });
});
```
### Future Plans
- Improve customization features.