Skip to content

Templates ​

Templates let you rewrite what What Hit Me? shows, line by line, with {variables}. Pack makers set them in the pack folder; players can have personal ones.

Nothing changes until you write one

Without a template every output uses the built-in look, in every language. You only replace the outputs you want.

The outputs ​

OutputWhat it changesAlso used for
hoverThe hover details of a record (death screen tooltip)Hover text of /whm history lines and of the chat summary
lineOne timeline line of the death screen panelLines of /whm history
summaryThe respawn chat summary
alertThe totem / prevented death / heavy-hit chat alert
copyThe text copied by [Copy] / [Copy Recap]

Death messages of rules use the same syntax, see Death messages.

Where templates come from ​

PrioritySourceFile
1 (highest)Personalconfig/whathitme/whathitme-client-templates.json (client)
2Pack"templates" in any config/whathitme/pack/**/*.json
3Built-inThe normal output
  • Lock an output ("locks": { "templates": ["summary"] }, or the lock in the Templates tab) and personal templates are ignored for it; lock templates in the personal group to ignore every personal template. See Settings & locks.
  • A rule branch that hides fields skips personal templates for its records, so players cannot get around hidden fields.
  • Variables the pack switched off render empty in every template.
  • On a server, pack templates are also used for the English chat sent to players without the mod.

Writing a template ​

In a pack file, each output is a list of lines (or one string with \n):

json
{
  "templates": {
    "summary": [
      "&6&l===== What Hit Me? =====",
      "&cKilling blow: &f{killing_blow} &c({damage} ❤)",
      "&3Properties: {properties}",
      "&6Last {total_seconds}s: {total} ❤ in {total_hits} hits",
      "&aTip: {tip}",
      "&b{recap_link}",
      "{toggle_notice}"
    ]
  }
}

The personal file has the same shape:

json
{
  "templates": {
    "line": ["&4{killing} &8{time_ago} &f{name} &c-{damage} ❤ &e{badges}"]
  }
}

The easiest way to write them is the in-game template editor with its live preview.

Syntax ​

SyntaxMeaningExample
{variable}Value of the variable. Names are case-insensitive.{attacker_name}
{variable|fallback}Fallback text when the variable is empty{attacker_owner|nobody}
{variable:2}Number of decimals (0 - 9) for numbers; default is 1 for most numbers{damage:2} -> 3.75
& + codeColor and format codes: &0-&f colors, &l bold, &n underline, &r reset&cDanger
A line lang:<key>The whole line is a translation key, translated for each readerlang:mypack.summary.header
A line that is a known translation keyTranslated toowhathitme.summary.header
{mob_...}Alias of {attacker_...}{mob_name} = {attacker_name}

Automatic line dropping: a line whose placeholders are all empty is left out. So "Weapon: {weapon}" disappears when the attacker had no weapon. A line without any placeholder is always shown.

Unknown variables are empty. /whm reload lists them with the file name, and the editor shows them in red.

Long lines wrap automatically in the tooltip and the panel.

Variables ​

Variables respect the display switches

A variable whose display switch is off (in either file, or masked by the server) is empty, so its line disappears. Templates can never reveal information the server disabled. Fields hidden by a rule are empty too.

Damage ​

VariableValueSwitch
{damage}Damage taken in heartsshowDamageAmount
{damage_hp}Damage taken in health pointsshowDamageAmount
{raw_damage}Damage before armor, in heartsshowMitigationDetails
{mitigation}Percentage blocked by armor and effects (0 decimals by default)showMitigationDetails
{absorbed}Absorption (yellow hearts) usedshowMitigationDetails
{health_after}Health left after the hit, in heartsshowMitigationDetails
{max_health}Max health in heartsshowMitigationDetails
{max_hp_percent}Damage as a percentage of max health (0 decimals)showMaxHpPercentage
{hits}Merged hit count (empty for a single hit)showSmartMergeHitCount

Damage type ​

VariableValueSwitch
{name}Main name: rule name, custom name, attacker or damage type
{damage_name}Damage type name (with renames), without the attacker
{damage_id}Internal damage idshowInternalDamageId
{damage_mod}Mod of the damageshowSourceModName
{properties}Damage properties (Fire, Magic, ...)showDamageProperties
{death_message}The vanilla death message (summary, alert, copy, death messages)

Attacker ​

VariableValueSwitch
{attacker_name}Attacker nameshowAttackerName
{attacker_id}Attacker entity idshowAttackerName
{attacker_mod}Mod of the attackershowAttackerName + showSourceModName
{attacker_distance}Distance to the attacker in blocksshowAttackerDistance
{attacker_owner}Owner of the pet, turret or projectileshowEntityOwner
{direct}Projectile / direct entity (when not the attacker)showAttackerName
{weapon}Attacker weaponshowAttackerWeapon
{weapon_id}Attacker weapon item idshowAttackerWeapon
{weapon_enchants}Enchantments of the weaponshowAttackerWeapon

Context ​

VariableValueSwitch
{environment}Block / fluid at feet and body, items in handshowEnvironmentContext
{dimension}Dimension idincludeEquipmentInCopy
{x} {y} {z}Death position (whole blocks; {x:1} for decimals)includeEquipmentInCopy + includeCoordsInCopy
{time_ago}How long ago the hit happenedshowTimestamp
{time}Clock time of the hit (HH:mm:ss)showTimestamp

Badges and other ​

VariableValueSwitch
{badges}Badges: estimate, totem, heavy hit, reflected, invisible, vital hitper badge
{killing}☠ when this is the killing blow
{tip}Counter-measure tipshowHints
{player}Player name
{script:<name>}Value of a script variable, computed on the server (script integration)

Summary, alert and copy ​

These need a whole death or snapshot, so they are filled in summary, alert and copy (and death messages), and empty in hover / line.

VariableValue
{killing_blow}Killing blow name (hover shows its details)
{total}Damage of the last summarySeconds in hearts
{total_hits}Hits of the last summarySeconds
{total_seconds}Length of that window (summarySeconds)
{recap_link}Clickable link to the full recap (/whm last)
{toggle_notice}The /whm togglechat notice (showToggleChatNotice)
{alert_kind}Totem of Undying, Heavy Hit or Death Prevented
{details_link}Clickable [Details] link of an alert
{timeline}Every damage line of the recap (copy)
{equipment}Equipment block: dimension, armor, effects (includeEquipmentInCopy)
{effects}Active effects at death (includeEquipmentInCopy)
{recap}The complete built-in recap text

Examples per output ​

A custom line template in the death screen panel

The built-in summary (top) and a two-line custom summary template (bottom) in the chat

hover ​

json
"hover": [
  "&l{name}",
  "{badges}",
  "&8ID: {damage_id}",
  "&cDamage: {damage} ❤ ({damage_hp} HP)",
  "&7Before armor: {raw_damage} ❤, {mitigation}% mitigated",
  "&eAbsorbed: {absorbed} ❤",
  "&7Health: {health_after} / {max_health} ❤",
  "&eMerged hits: x{hits}",
  "&fAttacker: {attacker_name}",
  "&7Via: {direct}",
  "&bWeapon: {weapon} &d{weapon_enchants}",
  "&7Distance: {attacker_distance}m",
  "&7Owner: {attacker_owner}",
  "&3Properties: {properties}",
  "&9Mod: {damage_mod}",
  "&7{environment}",
  "&aTip: {tip}"
]

line ​

json
"line": ["&4{killing} &8{time_ago} &f{name} &c-{damage} ❤ &e{badges}"]

A compact line with the share of max health:

json
"line": ["&f{name} &c{damage:0}❤ &7({max_hp_percent|?}%)"]

summary ​

A short two-line summary:

json
"summary": [
  "&c☠ {killing_blow} &7({damage} ❤, {total} ❤ in {total_seconds}s)",
  "&a✎ {tip} &b{recap_link}"
]

alert ​

json
"alert": ["&6{alert_kind}: &f{name} &c({damage} ❤) {details_link}"]

copy ​

Markdown for Discord:

json
"copy": [
  "**Death recap** ({time})",
  "Killing blow: {killing_blow} ({damage} hearts)",
  "Death message: {death_message}",
  "{timeline}",
  "Last {total_seconds}s: {total} hearts in {total_hits} hits",
  "{equipment}"
]

Translated lines ​

json
"summary": [
  "lang:mypack.whm.header",
  "&c{killing_blow} &7- {tip}"
]

Checking a template ​

WayWhat it shows
Template editorLive preview on every keystroke, with your latest death or a sample death
/whm template preview <output>The template rendered with your latest death (or a sample death) in chat
/whm reloadUnknown variables and outputs, with the file name

Personal templates ​

Players can write their own templates (unless the pack locks them):

  • In game: /whm template, or Templates... in the settings screen, then Save.
  • In the file config/whathitme/whathitme-client-templates.json (created with commented examples), then /whm reload.
  • Back to the pack / built-in look: Reset in the editor, /whm template reset <output>, or /whm template reset for all.

Made by junjun1z. The mods are MIT licensed.