Pastimes
Sheltering from the rain, watching you work, Chiikawa curling up in fright, Usagi shrieking and bouncing around, Rakko staring at sweets... Each of these pastimes is a file under pet_errand/, written alongside the other errands, with two more fields, when and cast. For how it plays, see Pastimes.
Pastimes don't need to be written into any job. Every pet considers them, and cast decides which characters do them. Create a new file under your own namespace and you have a new pastime.
Writing the File
Take Chiikawa getting scared as an example, pet_errand/cower.json:
{
"action": "chiikawa:perform",
"category": "pastime",
"when": [
{ "type": "scared", "by": ["thunder", "creeper"] }
],
"cast": {
"chiikawa:chiikawa": {
"pose": "cry,hurt",
"begin": { "reaction": "hurt", "voice": "scared" },
"now_and_then": {
"every_ticks": { "type": "minecraft:uniform", "min_inclusive": 200, "max_inclusive": 300 },
"voice": "scared"
},
"until": {
"cue": { "type": "owner", "is": "near", "range": 2.0 },
"after_ticks": 40
},
"ticks": 600
}
},
"requires": [],
"priority": 10,
"score": 0.9,
"max_ticks": 700,
"rests": {
"done": { "from": "chiikawa:pastime_cooldown" },
"gave_up": 200,
"interrupted": 0
},
"yields_to": [],
"overlays": [],
"tuning": { "cooldown_ticks": 2400 }
}For the shared fields such as priority, score, max_ticks and rests, see Errands. A pastime's category is always pastime, and it has no target. On top of that it has:
| Field | Meaning |
|---|---|
action | chiikawa:perform does it on the spot; chiikawa:visit walks somewhere first and then does it; chiikawa:ask_praise copies a nearby friend for a while, then walks up to you for praise, which is what Momonga's pastime uses |
when | Conditions that all have to hold, see below; an empty list [] means it can happen at any time |
cast | Which characters do it and how each does it, by character id; a character not written doesn't do it. At least one character has to be written |
How Each Character Does It
Each character in cast is written the same way as each side in a little scene:
| Field | Meaning |
|---|---|
to | Where it goes first; required for every character in a visit, and not allowed in perform or ask_praise, see the table below |
pose | Optional, the pose held the whole time |
begin | Optional, what it does at the start |
now_and_then | Optional, what it does every so often along the way; needs every_ticks, how often, either a fixed number or a vanilla random number |
end | Optional, what it does at the end, however it ends |
until | Optional, a condition for ending early. cue is one condition written the same way as in when, and after_ticks is the least time after the start before it is checked |
ticks | The longest it goes on |
begin, now_and_then and end can each have an animation, a reaction expression (happy, hurt, confused) and a voice moment; for voice moments, see Voice Lines.
pose and animation are animation names. You can list several separated by commas, and a character uses the first one it has: with "cry,hurt", it cries if it has a crying animation, and otherwise looks hurt. To see which animations each character has, look at assets/chiikawa/animations/<character>.json in the resource pack; a character with none of them just stands there.
There are four kinds of to:
type | Where it goes | Also needs |
|---|---|---|
owner | To your side | Nothing |
shelter | The nearest place out of the rain, such as under an overhang or a tree | Nothing |
creature | The nearest creature of some kind it can see | entities, an entity tag |
item | The nearest thing of some kind it can see, on the ground or in someone's hand | items, an item tag |
When It Happens
Every condition in when has to hold before a pet does it. The conditions are these:
type | Holds when | Also needs |
|---|---|---|
weather | It is raining, or thundering | is, rain (rain, with thunder counting too) or thunder (thunder only) |
under_sky | It is standing in the open, where the rain reaches it | Nothing |
phase | It is one of certain periods of the day | in, chosen from MORNING, DAY, EVENING, NIGHT |
scared | It got scared, by any of the listed things | by, chosen from thunder thunder, creeper a Creeper about to explode and hurt just being hit |
owner | You are nearby and doing a certain thing | is and range, see below |
sees | It can see a certain creature or thing nearby | entities, an entity tag, or items, an item tag; plus range, how close |
lacking | It is short of something for work, such as seeds or arrows | Nothing |
is in owner can be near, you only have to be nearby; working, digging or placing blocks; returned, just back after being out a while; finished, just done with a long stretch of work; or sleeping, asleep in bed. range is how close to it you have to be, in blocks. This distance is measured straight from where you are, and isn't limited by radius below.
Its Numbers
What goes in tuning follows the action:
action | Fields in tuning |
|---|---|
perform | cooldown_ticks |
visit | cooldown_ticks, plus speed, how fast it walks; arrive_distance, how close it walks up to you or the creature; reach, how close to you or the creature it starts; and place_reach, how close to a place it starts |
ask_praise | cooldown_ticks, speed, arrive_distance, reach, plus imitate_ticks, how long it copies, and imitates, the animation it plays when there is no friend nearby to copy |
cooldown_ticks is the shortest wait after doing it once before doing it again. When done in rests is written as { "from": "chiikawa:pastime_cooldown" }, this is how long it rests, divided by "Pastimes" in the mod's settings: at 200%, the cooldown is halved; at 0%, no pastimes happen at all. See Getting Started.
The default priority of pastimes is 10, the same as wandering and sleeping, so they only happen when there's nothing that needs doing, and work comes first. Sitting pets don't do them.
The Mod's Own Pastimes
| File | Who | When | What it does |
|---|---|---|---|
rain_shelter | Every character except Usagi | It's raining and it's standing in the open | Chiikawa runs to your side and curls up into a ball; the others go and sit somewhere out of the rain |
rain_play | Usagi | It's raining and it's standing in the open | Hops around in the rain |
watch_owner_work | Every character | You dig or place blocks within 16 blocks | Walks over to your side to watch, clapping now and then |
cower | Chiikawa | Thunder, or a Creeper about to explode | Curls up and cries, and only feels better once you come within 2 blocks |
frenzy | Usagi | Any time | Shrieks and bounces around |
ask_praise | Momonga | Another pet within 8 blocks, and you within 16 | Copies its friend for a while, then comes to you for praise, and sulks if you ignore it |
evening_drink | Kurimanju | Evening | Sits down for a drink and lets out a sigh |
coffee_for_a_worker | Kurimanju | You've just finished a long stretch of work nearby | Comes over to hand you a cup |
sweets_stare | Rakko | It can see sweets within 8 blocks | Goes over and stares at them |
sword_practice | Rakko | Any time | Practises with its sword on its own |
greet_owner | Shisa | You're just back after being out a while | Comes over, bows and greets you |
To see the exact numbers of each pastime, copy its file from data/chiikawa/pet_errand/ in the mod's jar.
How Far It Looks Around
Which places a pet can see are out of the rain, what creatures and things are nearby, whether you've just come back and whether you've just finished working are all decided by pet_surroundings/surroundings.json:
{
"radius": 8,
"away_ticks": 2400,
"returned_ticks": 200,
"settle_ticks": 100,
"spell_ticks": 400,
"finished_ticks": 600
}| Field | Meaning | Default |
|---|---|---|
radius | How far it looks around, in blocks. Places out of the rain, and the creatures and things that sees and to look for, are all searched within this range; you also have to come within it before it can tell whether you've just come back or just finished working | 8 |
away_ticks | How long you have to be out of this range for your return to count as "just back after being out a while" | 2400 |
returned_ticks | How long after you come back it still counts as "just back" | 200 |
settle_ticks | How long you have to stop before a stretch of work counts as finished; if you stop for less and carry on, it is still the same stretch | 100 |
spell_ticks | The shortest stretch of work that is worth a cup of coffee once it's finished | 400 |
finished_ticks | How long after a stretch of work is finished it still counts as "just finished" | 600 |
Writing a range in sees larger than radius doesn't let it see any further.
There is only one copy of this file, so to change it, replace it entirely, with every field written. If any one is missing, the file can't be read, the pets can't see anything, and the pastimes that depend on what they see won't happen either.
