minecraft
Gear (item)
This article is a work in progress. 
Please help in the expansion or creation of this article by expanding or improving it. The talk page may contain suggestions.
This article is about data pack contents. For the game mechanic, see Damage.
Information icon
This feature is exclusive to Java Edition. 

Damage types are JSON files located in data packs that define different kinds of damage that entities can take. They control which attributes the damage has as well as which death message is used when an entity dies due to that type of damage.

Additionally, the built-in damage type tags control many aspects of how damage is applied by the game.

Custom damage types can currently only be applied using the /damage command.

File format

Damage types are stored as JSON files within a data pack, at the path data/<namespace>/damage_type/<name>.json.

  • The root object.
    •  message_id: Used as part of the death message translation key if  death_message_type is set to default, as shown below.
    •  exhaustion: The amount of hunger exhaustion caused by this damage type.
    •  scaling: Whether this damage type scales with difficulty.
      Possible values: never, always, or when_caused_by_living_non_player. See below for more detail.
    •  effects: Optional field controlling how incoming damage is shown to the player.
      Possible values: hurt (default), thorns, drowning, burning, poking, freezing. See below for more detail.
    •  death_message_type: Optional field that controls the kind of death messages to use.
      Possible values: default (default), fall_variants, intentional_game_design. See below for more detail.

For example, here is JSON for the built-in minecraft:arrow:

{
	"exhaustion": 0.1,
 	"message_id": "arrow",
	"scaling": "when_caused_by_living_non_player"
}

Scaling

Damage types control whether damage scales with difficulty.[more information needed]

Possible values of  scaling:

Effects

Damage types control how incoming damage is shown to the player.

Possible values of  effects:

Death messages

Damage types control the death messages displayed when players or pets die.

Possible values of  death_message_type:

Default message type

When standard death message logic is being used, messages are generated as follows, making use of the  message_id tag:

Design

Because of how the default death messages are set up, most vanilla damage types are divided into ones that will always have an attacker[note 1] and ones that will never have an attacker. Depending on whether there was an attacker, the translation for normal deaths (death.attack.<message_id>) will have either one or two available insertions. Translations have no safe way to access an insertion that may or may not be there, so the primary options are:

The death type is planned to always have an attacker.

The death type is planned to never have an attacker.

The death type may or may not have an attacker.

To avoid the awkwardness of the third option you can have two different damage types, one for use with an attacker, and one for use without an attacker:

"death.attack.active_electricity": "%s was electrocuted by %s",
"death.attack.active_electricity.item": "%s was electrocuted by %s using %s",
"death.attack.passive_electricity": "%s was electrocuted",
"death.attack.passive_electricity.player": "%s was electrocuted whilst trying to escape %s",

History

Java Edition
1.19.423w06aAdded damage types to data packs.
1.20pre1Added outside_border, and generic_kill.

Notes

  1. a b c d e The entity that was responsible for the damage. Also known as the "source entity". For example, if a player is shot by a skeleton, the skeleton is the attacker. If a player is shot by a dispenser, the arrow itself is the attacker. If the player is pricked by a cactus, there is no attacker.
  2. a b This includes armor stands.