Pixel Dream StudiosWiki

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

ConditionFieldsTrue when
has_flagflag, is=trueThe player carries that flag. Reach for this first.
has_completeddialogueThey have read that conversation through to the end.
has_itemsitem, count=1They are carrying enough. Item or #tag.
holdingitem, is=trueIt is in one of their hands.
times_spokenat_least=0, at_most=∞, today=falseHow often they have come to this speaker, counting the visit being paid now.
can_go_backnoneThey turned away from something to be here.
has_tradesnoneThe speaker has something in stock right now.
sellsitemThe speaker has that particular thing in stock.
professionis (list)The speaker's trade is one of these.
any_ofof (list)Any one of them holds.
invertedofThe 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.

ConditionFieldsTrue when
at_hourspanSee Spans.
in_weatherskyclear, rain, thunder. A storm is not also rain.
in_biomebiomes (tag)They are standing in that country.
indoorsis=trueThey cannot see the sky. A tree counts, and should.
during_raidnoneThere is a raid on where they stand.
near_structurestructures (tag), chunks=4One stands in an already-loaded chunk nearby. chunks is 0 to 8.
in_villageis=trueBy vanilla's own reckoning: the beds and workstations actually claimed.
village_hasprofessions (list), radius=48Somebody of that trade is within reach. radius is 1 to 128.
reputationgossip, at_least, at_mostVanilla's gossip, the same number that sets prices.
player_healthat_least=0.0, at_most=1.0A share of their maximum, not half-hearts.
player_has_effecteffectThey have it. hero_of_the_village is the one worth writing for.
remembersmemory, is=trueAny of the facts a villager's brain already holds.
doingisSee States.

Spans

at_hour takes one of six, by the world's own daylight clock.

SpanTicks
day0 to 11999
night13000 to 22999
morning0 to 5999
afternoon6000 to 11999
evening12000 to 13999
small_hours16000 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.

StateMeans
calmNot preoccupied: the same question a conversation asks before it opens, so this is somebody who would have stopped to talk.
idleNobody in their sights and nothing has just hit them. The plainer question, and the same for every kind of mob.
fightingSwinging at something: you, or anybody else.
fighting_youSwinging at the player reading this, which is worth its own line.
fleeingRunning, hiding, or keeping something at arm's length.
threatenedSomething 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.

On this page