{
  "format_version": "1.21.0",
  "minecraft:entity": {
    "description": {
      "identifier": "lv_te:fred",
      "is_spawnable": true,
      "is_summonable": true,
      "is_experimental": false,
      "properties": {
        "lv.te:cracking": {
          "client_sync": true,
          "default": 0,
          "range": [
            0,
            3
          ],
          "type": "int"
        }
      }
    },
    "component_groups": {
      "move_to_charge": {
        "minecraft:skin_id": {
          "value": 2
        },
        "minecraft:attack": {
          "damage": 0
        },
        "minecraft:behavior.nearest_attackable_target": {
          "priority": 0,
          "reselect_targets": true,
          "target_search_height": 50,
          "within_radius": 50,
          "must_see": false,
          "entity_types": [
            {
              "filters": [
                {
                  "any_of": [
                    {
                      "all_of": [
                        {
                          "test": "is_family",
                          "subject": "other",
                          "value": "fuel_station"
                        },
                        {
                          "test": "is_skin_id",
                          "subject": "self",
                          "value": 2
                        }
                      ]
                    }
                  ]
                }
              ],
              "max_dist": 50
            }
          ]
        },
        "minecraft:behavior.melee_attack": {
          "priority": 0,
          "require_complete_path": true,
          "track_target": true
        },
        "minecraft:behavior.move_towards_target": {
          "within_radius": 2,
          "priority": 1
        },
        "minecraft:target_nearby_sensor": {
          "inside_range": 1.0,
          "outside_range": 3.0,
          "must_see": true,
          "on_inside_range": {
            "event": "reached_station"
          }
        },
        "minecraft:follow_range": {
          "value": 100,
          "max": 100
        }
      },
      "move_to_machines": {
        "minecraft:skin_id": {
          "value": 1
        },
        "minecraft:attack": {
          "damage": 0
        },
        "minecraft:behavior.nearest_attackable_target": {
          "priority": 0,
          "reselect_targets": true,
          "target_search_height": 50,
          "within_radius": 50,
          "must_see": false,
          "entity_types": [
            {
              "filters": [
                {
                  "any_of": [
                    {
                      "all_of": [
                        {
                          "test": "is_family",
                          "subject": "other",
                          "value": "fuel_needed"
                        },
                        {
                          "test": "is_skin_id",
                          "subject": "self",
                          "value": 1
                        }
                      ]
                    }
                  ]
                }
              ],
              "max_dist": 50
            }
          ]
        },
        "minecraft:behavior.melee_attack": {
          "priority": 0,
          "require_complete_path": true,
          "track_target": true
        },
        "minecraft:behavior.move_towards_target": {
          "within_radius": 2,
          "priority": 1
        },
        "minecraft:target_nearby_sensor": {
          "inside_range": 2.0,
          "outside_range": 3.0,
          "must_see": true,
          "on_inside_range": {
            "event": "reached_machine"
          },
          "on_outside_range": {
            "event": "not_reached_machine"
          }
        },
        "minecraft:follow_range": {
          "value": 100,
          "max": 100
        }
      },
      "moving": {
        "minecraft:flying_speed": {
          "value": 0.1
        },
        "minecraft:movement": {
          "value": 0.2
        },
        "minecraft:variant": {
          "value": 0
        }
      },
      "charging": {
        "minecraft:timer": {
          "time": 20,
          "looping": true,
          "time_down_event": {
            "event": "move_to_machines",
            "target": "self"
          }
        },
        "minecraft:flying_speed": {
          "value": 0.0
        },
        "minecraft:movement": {
          "value": 0.0
        },
        "minecraft:variant": {
          "value": 1
        }
      },
      "lv_te:despawn": {
        "minecraft:instant_despawn": {
          "remove_child_entities": false
        }
      }
    },
    "components": {
      "minecraft:on_target_acquired": "target_found",
      "minecraft:inventory": {
        "container_type": "minecart_chest",
        "inventory_size": 27
      },
      "minecraft:damage_sensor": {
        "triggers": [
          {
            "on_damage": {
              "filters": [
                {
                  "all_of": [
                    {
                      "test": "is_family",
                      "subject": "damager",
                      "value": "player"
                    },
                    {
                      "test": "int_property",
                      "domain": "lv.te:cracking",
                      "operator": "<",
                      "value": 2
                    }
                  ]
                }
              ],
              "target": "self",
              "event": "lv_te:cracking"
            },
            "deals_damage": false
          },
          {
            "on_damage": {
              "filters": [
                {
                  "all_of": [
                    {
                      "test": "is_family",
                      "subject": "damager",
                      "value": "player"
                    },
                    {
                      "test": "int_property",
                      "domain": "lv.te:cracking",
                      "operator": ">=",
                      "value": 2
                    }
                  ]
                }
              ],
              "target": "self",
              "event": "lv_te:break_pair"
            },
            "deals_damage": false
          },
          {
            "cause": "all",
            "deals_damage": false
          }
        ]
      },
      "minecraft:leashable": {
        "soft_distance": 4.0,
        "hard_distance": 6.0,
        "max_distance": 10.0,
        "on_leash": {
          "event": "minecraft:on_leash",
          "target": "self"
        },
        "on_unleash": {
          "event": "minecraft:on_unleash",
          "target": "self"
        }
      },
      "minecraft:balloonable": {
        "mass": 0.8
      },
      "minecraft:is_hidden_when_invisible": {},
      "minecraft:nameable": {},
      "minecraft:type_family": {
        "family": [
          "lv.te.fred",
          "inanimate"
        ]
      },
      "minecraft:breathable": {
        "total_supply": 15,
        "suffocate_time": 0
      },
      "minecraft:collision_box": {
        "width": 0.1,
        "height": 0.1
      },
      "minecraft:custom_hit_test": {
        "hitboxes": [
          {
            "width": 0.5,
            "height": 0.7,
            "pivot": [
              0,
              0.5,
              0
            ]
          }
        ]
      },
      "minecraft:health": {
        "value": 30,
        "max": 30
      },
      "minecraft:navigation.hover": {
        "can_path_over_water": true,
        "can_sink": false,
        "can_pass_doors": false,
        "can_path_from_air": true,
        "avoid_water": true,
        "avoid_damage_blocks": true,
        "avoid_sun": false
      },
      "minecraft:movement.hover": {},
      "minecraft:jump.static": {},
      "minecraft:can_fly": {},
      "minecraft:physics": {
        "has_gravity": false
      },
      "minecraft:behavior.float": {
        "priority": 7
      },
      "minecraft:behavior.look_at_player": {
        "priority": 8,
        "target_distance": 6.0,
        "probability": 0.02
      },
      "minecraft:behavior.random_look_around": {
        "priority": 8
      },
      "minecraft:pushable": {
        "is_pushable": true,
        "is_pushable_by_piston": true
      }
    },
    "events": {
      "minecraft:entity_spawned": {
        "add": {
          "component_groups": [
            "move_to_machines",
            "moving"
          ]
        }
      },
      "lv_te:remove_machine": {
        "add": {
          "component_groups": [
            "lv_te:despawn"
          ]
        }
      },
      "lv_te:reset_cracking": {
        "set_property": {
          "lv.te:cracking": 0
        }
      },
      "lv_te:cracking": {
        "queue_command": {
          "command": "scriptevent lv.te:tech_mech.cracking"
        }
      },
      "reached_machine": {
        "queue_command": {
          "command": [
            "scriptevent lv.te:fred.charge_machine",
            "playanimation @s animation.lv_te.fred.fuel"
          ]
        }
      },
      "reached_station": {
        "add": {
          "component_groups": [
            "charging"
          ]
        },
        "remove": {
          "component_groups": [
            "move_to_charge",
            "moving"
          ]
        }
      },
      "move_to_station": {
        "add": {
          "component_groups": [
            "move_to_charge",
            "moving"
          ]
        },
        "remove": {
          "component_groups": [
            "charging",
            "move_to_machines"
          ]
        }
      },
      "move_to_machines": {
        "add": {
          "component_groups": [
            "move_to_machines",
            "moving"
          ]
        },
        "remove": {
          "component_groups": [
            "charging",
            "move_to_charge"
          ]
        }
      },
      "lv_te:instant_cracking": {
          "set_property": {
              "lv.te:cracking": 2
          },
          "queue_command": {
              "command": "scriptevent lv.te:tech_mech.cracking"
          }
      },
      "lv_te:break_pair": {
          "queue_command": {
              "command": "scriptevent lv.te:machines.break.fred"
          }
      }
    }
  }
}