1. Wiki
  2. /Entities
  3. /minecraft:target_nearby_sensor

minecraft:target_nearby_sensor

Don't want to write this by hand? GodCraft sets minecraft:target_nearby_sensor for you with a switch.Get GodCraft

Overview

minecraft:target_nearby_sensor is an entity component: it goes in the components object of a custom mob, or in one of its component groups. Watches for targets at two distances and runs events when one comes close, moves away, or goes out of sight. Creepers use this to start swelling.

Fields

FieldTypeDefaultDescription
inside_rangeDecimal"1"Distance in blocks that counts as close.
must_seeBoolean"false"If true, the target must be visible for the close event to fire.
on_inside_rangeStringnoneEvent to run when a target comes within the close range.
on_outside_rangeStringnoneEvent to run when a target moves beyond the close range but stays within the outer range.
on_vision_lost_inside_rangeStringnoneEvent to run when a close target can no longer be seen.
outside_rangeDecimal"5"Distance in blocks that counts as the outer range.

Example

Inside the components object of BP/entities/<name>.json (values are the defaults or placeholders):

BP/entities/<name>.json
{
  "minecraft:target_nearby_sensor": {
    "inside_range": "1",
    "must_see": "false",
    "on_inside_range": "",
    "on_outside_range": "",
    "on_vision_lost_inside_range": "",
    "outside_range": "5"
  }
}

We use cookies to improve your experience and analyse site traffic. Learn more