Conditions
What has to hold before a line, a choice or a binding is used. Weighed on the server, so a failed choice is never sent at all.
"condition" in any requires list: on a choice, a variant, a murmur line, or a speaker binding.
A list is an and. any_of is the or, inverted is the not.
Conditions never reach the client
They are weighed on the server as the panel is sent, and again when it comes back up, so a merchant who sold out while the player was reading is no longer offering to show you. A choice that fails a condition is never sent at all.
About the conversation
| Condition | Fields | True when |
|---|---|---|
has_flag | flag, is=true | The player carries that flag. Reach for this first. |
has_completed | dialogue | They have read that conversation through to the end. |
has_items | item, count=1 | They are carrying enough. Item or #tag. |
holding | item, is=true | It is in one of their hands. |
times_spoken | at_least=0, at_most=∞, today=false | How often they have come to this speaker, counting the visit being paid now. |
can_go_back | none | They turned away from something to be here. |
has_trades | none | The speaker has something in stock right now. |
sells | item | The speaker has that particular thing in stock. |
profession | is (list) | The speaker's trade is one of these. |
any_of | of (list) | Any one of them holds. |
inverted | of | The wrapped one does not. |
profession is what a villager is, where sells is what they happen to have on the counter today.
About the world
All of these measure from the speaker, not the player. A remark about the weather is theirs. A conversation opened with nobody on the other side falls back to the reader.
| Condition | Fields | True when |
|---|---|---|
at_hour | span | See Spans. |
in_weather | sky | clear, rain, thunder. A storm is not also rain. |
in_biome | biomes (tag) | They are standing in that country. |
indoors | is=true | They cannot see the sky. A tree counts, and should. |
during_raid | none | There is a raid on where they stand. |
near_structure | structures (tag), chunks=4 | One stands in an already-loaded chunk nearby. chunks is 0 to 8. |
in_village | is=true | By vanilla's own reckoning: the beds and workstations actually claimed. |
village_has | professions (list), radius=48 | Somebody of that trade is within reach. radius is 1 to 128. |
reputation | gossip, at_least, at_most | Vanilla's gossip, the same number that sets prices. |
player_health | at_least=0.0, at_most=1.0 | A share of their maximum, not half-hearts. |
player_has_effect | effect | They have it. hero_of_the_village is the one worth writing for. |
remembers | memory, is=true | Any of the facts a villager's brain already holds. |
doing | is | See States. |
Spans
at_hour takes one of six, by the world's own daylight clock.
| Span | Ticks |
|---|---|
day | 0 to 11999 |
night | 13000 to 22999 |
morning | 0 to 5999 |
afternoon | 6000 to 11999 |
evening | 12000 to 13999 |
small_hours | 16000 to 19999 |
They overlap deliberately: morning and afternoon are halves of day, and small_hours is the dead middle of the night rather than all of it.
States
doing describes what the speaker is up to.
| State | Means |
|---|---|
calm | Not preoccupied: the same question a conversation asks before it opens, so this is somebody who would have stopped to talk. |
idle | Nobody in their sights and nothing has just hit them. The plainer question, and the same for every kind of mob. |
fighting | Swinging at something: you, or anybody else. |
fighting_you | Swinging at the player reading this, which is worth its own line. |
fleeing | Running, hiding, or keeping something at arm's length. |
threatened | Something hostile is within eight blocks and in plain sight of them. The most expensive condition here. |
`doing` is written for murmurs
A conversation cannot open with somebody who is fighting or fleeing, so a conversation gated on those would never be given. Put them on murmur lines instead.
Reputation
{ "condition": "reputation", "gossip": "major_negative", "at_most": 0 }This is vanilla's own gossip, not a second reputation kept alongside it: the same number that decides whether you get a discount, and which villagers already pass between themselves as they go about the day.
Leave gossip out and it is the reckoning of all of it together. A speaker with no gossip of its own, an iron golem for instance, borrows the nearest villager's.
Player health
{ "condition": "player_health", "at_most": 0.4 }A share of their maximum, from 0.0 to 1.0, rather than a count of half-hearts, so one line works for a player on twenty hearts and a player on ten.
Memories
remembers reaches any of the roughly thirty facts a villager's brain already keeps, by their vanilla ids:
{ "condition": "remembers", "memory": "minecraft:golem_detected_recently" }Useful ones include minecraft:home, minecraft:job_site, minecraft:meeting_point, minecraft:golem_detected_recently, minecraft:hurt_by, and minecraft:last_slept. Set "is": false to ask that they do not hold it, which is how you write a villager who has nowhere to sleep.
Combining them
"requires": [
{ "condition": "at_hour", "span": "night" },
{
"condition": "any_of",
"of": [
{ "condition": "in_weather", "sky": "thunder" },
{ "condition": "during_raid" }
]
},
{ "condition": "inverted", "of": { "condition": "has_flag", "flag": "mypack:already_warned" } }
]At night, during either a storm or a raid, and only if they have not been warned already.
Adding your own
A record, a MapCodec, and one call. See For mod developers.
