{
  "format_version": "1.20.50",
  "minecraft:entity": {
    "description": {
      "identifier": "cc_alien:alien_emp",
      "is_spawnable": true,
      "is_summonable": true,
      "is_experimental": false,
      "scripts": {
        "animate": [
          "despawn_controller",
          "crash_on_damage",
          "fall_controller",
          { "kill_nearby_aliens": "q.property('cc_alien:on_off')" }
        ]
      },
      "animations": {
        "despawn_controller": "controller.animation.cc_alien.alien_beacon_player.despawn_controller",
        "crash_on_damage": "controller.animation.cc_alien.alien_beacon_player.crash_on_damage",
        "fall_controller": "controller.animation.cc_alien.alien_beacon_player.fall_controller",
        "kill_nearby_aliens": "animation.cc_alien.alien_emp.kill_nearby_aliens"
      },
      "properties": {
        "cc_alien:despawn": {
          "default": false,
          "type": "bool"
        },
        "cc_alien:crashed": {
          "default": false,
          "type": "bool",
          "client_sync": true
        },
        "cc_alien:on_off": {
          "default": false,
          "type": "bool",
          "client_sync": true
        }
      }
    },
    "components": {
      "minecraft:interact": {
        "interactions": [
          {
            "on_interact": {
              "event": "toggle_on_off",
              "target": "self",
              "filters": {
                "test": "is_family",
                "operator": "==",
                "subject": "other",
                "value": "player"
              }
            }
          }
        ]
      },
      "minecraft:damage_sensor": {
        "triggers": [
          {
            "on_damage": {
              "filters": {
                "test": "is_family",
                "operator": "==",
                "subject": "other",
                "value": "player"
              },
              "target": "self",
              "event": "trigger_despawn"
            }
          },
          {
            "cause": "all",
            "deals_damage": false
          }
        ]
      },
      "minecraft:loot": {
        "table": "loot_tables/cc/alien/entities/alien_emp.json"
      },
      "minecraft:health": {
        "min": -1,
        "max": 45
      },
      "minecraft:physics": {},
      "minecraft:pushable": {
        "is_pushable": false,
        "is_pushable_by_piston": true
      },
      "minecraft:knockback_resistance": {
        "value": 1.0
      },
      "minecraft:balloonable": {
        "mass": 0.4
      },
      "minecraft:behavior.float": {
        "priority": 0
      },
      "minecraft:variant": {
        "value": 0
      }
    },
    "component_groups": {
      "crashed": {
        "minecraft:health": {
          "min": 0,
          "max": 0
        },
        "minecraft:knockback_resistance": {
          "value": 1.0
        },
        "minecraft:pushable": {
          "is_pushable": false,
          "is_pushable_by_piston": true
        },
        "minecraft:movement": {
          "value": 0
        }
      }
    },
    "events": {
      "trigger_despawn": {
        "set_property": {
          "cc_alien:despawn": true
        }
      },
      "on_crash": {
        "add": {
          "component_groups": ["crashed"]
        },
        "set_property": {
          "cc_alien:crashed": true,
          "cc_alien:on_off": false
        }
      },
      "toggle_on_off": {
        "sequence": [
          {
            "filters": {
              "all_of": [
                {
                  "test": "bool_property",
                  "subject": "self",
                  "value": false,
                  "domain": "cc_alien:on_off"
                },
                {
                  "test": "bool_property",
                  "subject": "self",
                  "value": false,
                  "domain": "cc_alien:crashed"
                }
              ]
            },
            "set_property": {
              "cc_alien:on_off": true
            }
          },
          {
            "filters": {
              "all_of": [
                {
                  "test": "bool_property",
                  "subject": "self",
                  "value": true,
                  "domain": "cc_alien:on_off"
                },
                {
                  "test": "bool_property",
                  "subject": "self",
                  "value": false,
                  "domain": "cc_alien:crashed"
                }
              ]
            },
            "set_property": {
              "cc_alien:on_off": false
            }
          }
        ]
      },
      "cc_alien.turn_on": {
        "set_property": {
          "cc_alien": true
        }
      },
      "cc_alien.turn_off": {
        "set_property": {
          "cc_alien": false
        }
      }
    }
  }
}
