Entity Documentation - minecraft:despawn

minecraft:despawn compels an entity despawn when the despawn rules or optional filters evaluate to true.

Parameters

Name Default Value Type Description
despawn_from_distance not set JSON Object Specifies if the "min_distance" and "max_distance" are used in the standard despawn rules.
despawn_from_chance true Boolean Determines if "min_range_random_chance" is used in the standard despawn rules.
despawn_from_inactivity true Boolean Determines if the "min_range_inactivity_timer" is used in the standard despawn rules.
despawn_from_simulation_edge true Boolean Determines if the mob is instantly despawned at the edge of simulation distance in the standard despawn rules.
filters not set Minecraft Filter The list of conditions that must be satisfied before the entity is despawned. If a filter is defined then standard despawn rules are ignored.
min_range_inactivity_timer 30 Integer The amount of time in seconds that the mob must be inactive.
min_range_random_chance 800 Integer A random chance between 1 and the given value.
remove_child_entities false Boolean If true, all entities linked to this entity in a child relationship (eg. leashed) will also be despawned.

despawn_from_distance

despawn_from_distance is a JSON Object that is defined by 2 parameters. Each item has the following properties:

Name Default Value Type Description
max_distance 128 Integer Maximum distance for standard despawn rules to instantly despawn the mob.
min_distance 32 Integer Minimum distance for standard despawn rules to try to despawn the mob.

Example

"minecraft:despawn":{
    "despawn_from_distance": {
        "max_distance": 128,
        "min_distance": 32
    },
    "despawn_from_chance": false,
    "despawn_from_inactivity": false,
    "despawn_from_simulation_edge": true,
    "min_range_inactivity_timer": 30 ,
    "min_range_random_chance": 800,
    "remove_child_entities": false,
    "filters":{"test": "has_damage", "target": "self"}
}

Vanilla entities examples

zoglin

"minecraft:despawn": {
        "filters": {
          "any_of": [
            {
              "all_of": [
                {
                  "test": "is_persistent",
                  "value": false
                },
                {
                  "test": "distance_to_nearest_player",
                  "operator": ">",
                  "value": 54
                }
              ]
            },
            {
              "all_of": [
                {
                  "test": "is_persistent",
                  "value": false
                },
                {
                  "test": "inactivity_timer",
                  "subject": "self",
                  "value": 30
                },
                {
                  "test": "random_chance",
                  "value": 800
                },
                {
                  "test": "distance_to_nearest_player",
                  "operator": ">",
                  "value": 32
                }
              ]
            }
          ]
        }
      }

Vanilla entities using minecraft:despawn