minecraft:target_nearby_sensor

Dynamic value

Properties

This component has no properties in the official schema: add it as an empty object {} to switch the behaviour on.

Example from the game files

This is how vanilla Creeper uses it in Minecraft Bedrock 1.26.60.5:

{
  "minecraft:target_nearby_sensor": {
    "inside_range": 2.5,
    "on_inside_range": {
      "event": "minecraft:start_exploding",
      "target": "self"
    },
    "on_vision_lost_inside_range": {
      "event": "minecraft:stop_exploding",
      "target": "self"
    },
    "must_see": true,
    "on_outside_range": {
      "event": "minecraft:stop_exploding",
      "target": "self"
    },
    "outside_range": 6
  }
}

Used by 4

Vanilla entities with minecraft:target_nearby_sensor in their definition:

Related components