Skip to main content

Entity In Radius (Entity Condition Type)

Counts the entities within an area around the entity and compares the count with a number. A bi-entity condition can filter which entities count.

Type ID: apoli:entity_in_radius

Fields

FieldTypeDefaultDescription
bientity_conditionBi-entity Condition TypeoptionalFilters which entities count, with the entity the condition runs on as the actor and each nearby entity as the target.
shapeShapecubeThe shape of the area: cube, sphere, star, cone, or a hollow one (cube_hollow, sphere_hollow, star_hollow, cone_hollow).
hollow_thicknessFloat or Expression1How thick a hollow shape is, in blocks. A sphere_hollow counts entities between radius - hollow_thickness and radius away. Ignored by the solid shapes.
radiusFloatrequiredThe radius of the area, in blocks.
comparisonComparison>=How the count is compared with compare_to.
compare_toInteger or Expression1The number the count is compared with.

Notes

  • Positions are compared at foot level, where the entity's position is the bottom of its bounding box.
  • The entity the condition runs on is never counted.
  • Without a bientity_condition, every entity in range counts, including items, projectiles and mobs. With one, only living entities are tested and counted.
  • The scan stops as soon as the result is known, so a large radius with a >= comparison stays cheap.

Examples

{
    "type": "apoli:entity_in_radius",
    "bientity_condition": {
        "type": "apoli:target_condition",
        "condition": {
            "type": "apoli:entity_type",
            "entity_type": "minecraft:player"
        }
    },
    "shape": "sphere",
    "radius": 10.0,
    "comparison": ">=",
    "compare_to": 3
}

This checks whether there are at least 3 other players within 10 blocks.

An expression threshold

compare_to accepts a full expression, so the threshold doesn't have to be a fixed number. It is evaluated against the entity holding the power each time the condition is tested:

"condition": {
    "type": "apoli:entity_in_radius",
    "radius": 8,
    "comparison": ">=",
    "compare_to": "example:crowd_threshold"
}