Errands
Everything a pet does is an errand: following you, working, taking slips, going shopping, giving presents, taking photos, sleeping, and its pastimes too. pet_errand/ has one file per errand, and the file name is the errand's id; pet_errand/gift_owner.json, for example, is chiikawa:gift_owner. For how it plays, see What It Is Thinking.
There are three kinds of files:
- Errands written in the code, such as following, shopping and giving presents. Their files only have the shared fields, which control how urgent the errand is, how long it takes and how long it rests.
- Chores, whose files have an
action, such as harvesting, pulling weeds, hunting and performing. What to do, and what to do it to, are both written in the file; see Chores below. - Pastimes, which are chores too, with two more fields,
whenandcast, for when they happen and who does them; see Pastimes.
How It Picks an Errand
Each time a pet picks an errand, it first finds the highest priority among the errands it can do right now, and only compares scores within that priority. The score first gets the bonuses from slips and from being keen on work, is then multiplied by the factors in its personality, and finally gets a little randomness according to randomness in its personality. The errand with the highest score is what it does.
An errand of a higher priority can interrupt one of a lower priority. Errands of the same priority never interrupt each other: the one in progress gets finished first, and the others wait their turn however high their score. That is why personality factors only work within one priority, and however large they are, wandering never wins over work.
The mod's own errands and their default priorities:
| Default priority | Errands |
|---|---|
| 100 | flee running away when hit without fighting back |
| 80 | melee, ranged defending itself, protecting you and clearing out monsters around it; defend_self taking a weapon from its backpack to fight back; gift_owner bringing you a present it has in hand; cooperate playing along when another pet invites it; take_exam going to sit an exam at an Exam Desk; check_results going to see its results the next day |
| 50 | follow_owner following; take_task taking a slip at a Labor Board; shop going shopping; answer_whistle a wild pet coming over to look when it hears Whistle Candy; harvest harvesting; plant planting; deliver putting the harvest into chests; weed pulling weeds; pick_mushroom picking mushrooms at night; hunt_melee, hunt_ranged clearing out monsters near home on Free Roam, which is what hunting slips count; play_music performing |
| 40 | take_photo Hachiware taking photos |
| 30 | offer_gift picking a present out of its backpack when it wants to give one; socialize going to find another pet to act out a little scene with; pick_up_item picking things up off the ground |
| 10 | stay sitting and looking around; wander wandering; sleep sleeping; all pastimes |
These numbers are only a convention. The mod doesn't sort errands by number, and modpacks are free to change them.
Shared Fields
Every errand file has these fields. Take giving presents as an example, pet_errand/gift_owner.json:
{
"priority": 80,
"score": 0.85,
"max_ticks": 2400,
"rests": {
"done": 0,
"gave_up": 600,
"interrupted": 0,
"reports": { "given": { "from": "chiikawa:gifting_cooldown" } }
},
"yields_to": ["chiikawa:melee", "chiikawa:ranged", "chiikawa:defend_self"],
"overlays": [],
"tuning": {
"arrive_distance": 1,
"morning_from": 0.77,
"morning_to": 0.8,
"reach": 2.0,
"slept_ticks": 100,
"speed": 1.0
}
}| Field | Meaning |
|---|---|
priority | The priority, a whole number of 0 or more, see above |
score | How keen it is on this errand within its priority, 0 to 1 |
max_ticks | The longest it spends on it; if it isn't done by then, it gives up |
rests | How long it rests after finishing, giving up or being interrupted, see below |
yields_to | Optional, errands of the same priority it gives way to: while these still have something to do, it doesn't start. Only errands of the same priority can be listed |
overlays | Optional, little extras it does alongside this errand; for now the only one is chiikawa:idle_chatter, talking to itself now and then while wandering |
start_voice | Optional, a voice line moment to say when it sets off; melee and shooting, for example, have hunt |
tuning | The errand's own numbers, see below |
Giving presents has melee, shooting and defending itself in yields_to, so a pet in the middle of a fight won't walk off to give you a present. A Farmer's deliver gives way to harvest and plant, and plant gives way to harvest, so it always harvests first, then plants, and only then puts the harvest into chests.
What goes in tuning depends on the errand. For an errand written in the code, the errand itself sets its shape; for a chore, its action does. No field may be left out, so the easiest way is to copy the same errand, or a file with the same action, from data/chiikawa/pet_errand/ in the mod's jar and change the numbers. A few errands list animations per character in tuning: cowers in flee is the pose it hides in, and sleeps in sleep is the pose it sleeps in. by_character is written per character, and every other character uses otherwise.
How Long It Rests
done, gave_up and interrupted in rests are how long the errand rests after being finished, given up or interrupted before it is done again. All three have to be written, and gave_up can't be 0, or else the moment it gives up it would start over again straight away. Each one can be written three ways:
| Written as | Meaning |
|---|---|
600 | The whole errand rests for 600 ticks |
{ "ticks": 200, "per": "subject" } | It rests for 200 ticks only from this particular target, such as the crop it couldn't reach or the pet it has just acted out a scene with, and carries on with everything else |
{ "from": "chiikawa:gifting_cooldown" } | How long it rests is decided by a number in another file; "per": "subject" can be added too |
Only these can go in from:
| Name | Takes |
|---|---|
chiikawa:camera_cooldown | cooldown_ticks of the camera |
chiikawa:camera_retry | retry_ticks of the camera |
chiikawa:photo_upload_wait | The time it waits for the owner's game to draw the photo |
chiikawa:gifting_cooldown | cooldown_ticks of presents |
chiikawa:music_retry | How long to wait before trying again when a song couldn't start, from the mod's settings |
chiikawa:scene_cooldown | cooldown_ticks of little scenes |
chiikawa:pastime_cooldown | cooldown_ticks in a pastime's own tuning, scaled by "Pastimes" in the mod's settings |
reports is optional. It holds how long to rest when the outcome is only known afterwards, with keys set by the errand itself: given for giving presents is after the present has been handed over; taken, stored and failed for taking photos are after a photo is taken, after it is saved, and after a shot that didn't happen; played for little scenes is after a scene has been acted out.
Chores
A file with an action is a chore. A pet only does a chore when it is written in the chore list of a job the pet has; pastimes are the exception, and every pet considers them. Take pulling weeds as an example, pet_errand/weed.json:
{
"action": "chiikawa:harvest_block",
"category": "forage",
"counter": "chiikawa:weed",
"requires": ["wild_or_slip"],
"target": {
"type": "blocks",
"blocks": "#chiikawa:entity_weeds",
"missing": "no_weed"
},
"priority": 50,
"score": 0.5,
"max_ticks": 600,
"rests": {
"done": 0,
"gave_up": { "per": "subject", "ticks": 200 },
"interrupted": 0
},
"yields_to": [],
"overlays": [],
"tuning": { "no_way_ticks": 0, "reach_sqr": 3.0, "speed": 0.8, "tool_wear": 0 }
}Besides the shared fields above, a chore has these:
| Field | Meaning |
|---|---|
action | How it is done, see the table below |
category | What kind of thing it counts as, which decides under which order it is done, see the table below |
counter | Optional, which kind of slip progress one go of it counts towards. When the slip in hand counts this chore, its score gets a little boost |
requires | Optional, extra conditions: wild_or_slip means wild pets do it on their own, while your own pets only do it with a slip in hand that counts this chore, and writing it requires a counter; at_night means it is only done at night |
target | What it is done to; some actions require it and some don't allow it, see the table below |
action can only be one of these, which the mod has:
action | What it does | target | The mod's own files |
|---|---|---|---|
chiikawa:harvest_block | Breaks the block and puts what it gets into its backpack | ripe_crop or blocks | harvest, weed, pick_mushroom |
chiikawa:plant_block | Plants seeds from its backpack | plantable_soil | plant |
chiikawa:deposit | Puts things from its backpack into a container | container | deliver |
chiikawa:strike | Hits with a sword | foe | melee, hunt_melee |
chiikawa:shoot | Shoots with a bow | foe | ranged, hunt_ranged |
chiikawa:busk | Performs with the Music Box | Not written | play_music |
chiikawa:perform, chiikawa:visit, chiikawa:ask_praise | Pastimes, see Pastimes | Not written | See that page |
There are five types of target, and each needs a missing, see below:
type | What it is done to | Also needs |
|---|---|---|
ripe_crop | Ripe crops | Nothing |
plantable_soil | Farmland that will take the seeds in its backpack; it doesn't look for any while it has no seeds | Nothing |
blocks | Blocks in a block tag; for two-block-tall plants only the lower block counts | blocks, a block tag |
container | Containers that will take things from its backpack; it doesn't look for any while it has nothing to put in | blocks, the containers' block tag, and items, an item tag of what to put in |
foe | An enemy the pet has its eye on | grounds, why it fights, see below |
The pet finds block targets itself, and how far it looks is written in sight in the job file, see Jobs.
grounds in foe lists which reasons this chore fights for, and can take several: self is whatever hit it or has it targeted, owner is whatever hit you, is being hit by you or has you targeted, nearby is hostile mobs around it while it follows you or is out in the wild, and hunt is hostile mobs near home while it is on Free Roam. The mod's own melee and ranged list the first three, at priority 80; hunt_melee and hunt_ranged only list hunt, at priority 50, the same as work, so clearing out monsters never interrupts the work in progress.
missing is the reason shown on the pet's screen when there is no target: the part of a key in the resource pack's language file that comes after intent.chiikawa.fail.. no_weed, for example, matches intent.chiikawa.fail.no_weed, "No weeds nearby".
The common categorys are these:
category | Who does it |
|---|---|
work | Your own pets on Free Roam |
forage | Wild pets, and your own pets on Free Roam |
combat | Everyone except sitting pets |
pastime | Pets that are wandering, see Pastimes |
The rest (follow_owner, stay, wander, pick_up, take_task, shop, gift, social, exam, curious, photo, sleep, safety) are used by the errands written in the code, and chores seldom need them. pick_up is the one the "Auto Pickup" switch on the pet's screen turns on and off; see Its Screen.
Changing and Adding
Changing an errand. Put a file with the same name under data/chiikawa/pet_errand/. It replaces the mod's own copy entirely, so every field has to be written. An errand written in the code can't be turned into a chore, so its file can't have an action.
Adding a chore. Create a new file under your own namespace. For example, write a data/my_pack/pet_errand/pick_flowers.json modelled on weed.json, change target to { "type": "blocks", "blocks": "#minecraft:small_flowers", "missing": "no_flower" }, and remove requires and counter, and Farmers will go and pick the little flowers near home on their own. Then add my_pack:pick_flowers to the chore list in pet_job/farmer.json, see Jobs. The name shown on screen comes from intent.my_pack.pick_flowers in the resource pack's language file, and the reason shown when there is no target from intent.chiikawa.fail.no_flower.
What happens with mistakes. A file that can't be read is skipped, and the log says which file it is and what is wrong; that errand no longer starts until the file is fixed and you run /reload. Listing an errand in yields_to that doesn't exist or has a different priority, or an action that doesn't match its target, also counts as a mistake. A file whose name matches no errand and that has no action only gets a note in the log.
