{
   "format_version":"1.21.0",
   "minecraft:entity":{
      "description":{
         "identifier":"true:sentry_gun",
         "spawn_category":"creature",
         "is_spawnable":true,
         "is_summonable":true
      },
      "component_groups":{
         "true:default":{
            "minecraft:type_family":{
               "family":[
                  "sentry_gun",
                  "inanimate"
               ]
            },
            "minecraft:interact":{
               "interactions":[
                  {
                     "hurt_item":1,
                     "on_interact":{
                        "filters":{
                           "all_of":[
                              {
                                 "test":"has_tag",
                                 "subject":"other",
                                 "operator":"equals",
                                 "value":"breaking_tool"
                              }
                           ]
                        },
                        "event":"true:pick_up",
                        "target":"self"
                     },
                     "add_items":{
                        "table":"loot_tables/pick_ups/sentry_gun.json"
                     },
                     "use_item":false,
                     "play_sounds":"saddle",
                     "interact_text":"action.interact.pick_up"
                  }
               ]
            },
            "minecraft:inventory":{
               "container_type":"hopper",
               "can_be_siphoned_from":false,
               "private":false,
               "restrict_to_owner":false,
               "inventory_size":5
            },
            "minecraft:environment_sensor":{
               "triggers":[
                  {
                     "filters":{
                        "all_of":[
                           {
                              "test":"has_tag",
                              "subject":"self",
                              "operator":"equals",
                              "value":"loaded"
                           }
                        ]
                     },
                     "event":"true:loaded"
                  }
               ]
            }
         },
         "true:sentry_loaded":{
            "minecraft:type_family":{
               "family":[
                  "sentry_gun",
                  "inanimate"
               ]
            },
            "minecraft:entity_sensor":{
               "subsensors":[
                  {
                     "minimum_count":1,
                     "event_filters":{
                        "any_of":[
                           {
                              "test":"is_family",
                              "subject":"other",
                              "value":"sentry_bullet"
                           }
                        ]
                     },
                     "event":"true:take_bullet"
                  }
               ]
            },
            "minecraft:interact":{
               "interactions":[
                  {
                     "hurt_item":1,
                     "on_interact":{
                        "filters":{
                           "all_of":[
                              {
                                 "test":"has_tag",
                                 "subject":"other",
                                 "operator":"equals",
                                 "value":"breaking_tool"
                              }
                           ]
                        },
                        "event":"true:pick_up_loaded",
                        "target":"self"
                     },
                     "add_items":{
                        "table":"loot_tables/pick_ups/sentry_gun.json"
                     },
                     "use_item":false,
                     "play_sounds":"saddle",
                     "interact_text":"action.interact.pick_up"
                  }
               ]
            },
            "minecraft:is_saddled":{
               
            },
            "minecraft:inventory":{
               "container_type":"hopper",
               "can_be_siphoned_from":false,
               "private":false,
               "restrict_to_owner":false,
               "inventory_size":5
            },
            "minecraft:environment_sensor":{
               "triggers":[
                  {
                     "filters":{
                        "all_of":[
                           {
                              "test":"has_tag",
                              "subject":"self",
                              "operator":"not",
                              "value":"loaded"
                           }
                        ]
                     },
                     "event":"true:empty"
                  }
               ]
            },
            "minecraft:behavior.ranged_attack":{
               "attack_interval_min":30,
               "attack_interval_max":30,
               "charge_charged_trigger":1.0,
               "charge_shoot_trigger":1.0,
               "attack_radius":16,
               "burst_shots":30,
               "burst_interval":0.5
            },
            "minecraft:shooter":{
               "def":"true:sentry_bullet"
            },
            "minecraft:behavior.nearest_attackable_target":{
               "priority":0,
               "entity_types":[
                  {
                     "filters":{
                        "test":"is_family",
                        "subject":"other",
                        "value":"apocalypse"
                     },
                     "max_dist":16
                  }
               ],
               "must_see":true
            },
            "minecraft:behavior.random_look_around":{
               "priority":1
            },
            "minecraft:movement":{
               "value":0.0
            },
            "minecraft:navigation.walk":{
               
            },
            "minecraft:movement.basic":{
               
            }
         },
         "true:despawn":{
            "minecraft:transformation":{
               "into":"true:despawn"
            }
         },
         "true:despawn_loaded":{
            "minecraft:transformation":{
               "into":"true:despawn",
               "drop_inventory":false
            }
         }
      },
      "components":{
         "minecraft:collision_box":{
            "width":2.0,
            "height":4.0
         },
         "minecraft:damage_sensor":{
            "triggers":[
               {
                  "on_damage":{
                     "filters":{
                        "test":"is_family",
                        "subject":"other",
                        "value":"player"
                     }
                  },
                  "deals_damage":false
               }
            ]
         },
         "minecraft:health":{
            "value":99999,
            "max":99999
         },
         "minecraft:scale":{
            "value":0.4
         },
         "minecraft:knockback_resistance":{
            "value":100,
            "max":100
         },
         "minecraft:physics":{
            
         }
      },
      "events":{
         "minecraft:entity_spawned":{
            "add":{
               "component_groups":[
                  "true:default"
               ]
            }
         },
         "true:loaded":{
            "add":{
               "component_groups":[
                  "true:sentry_loaded"
               ]
            },
            "remove":{
               "component_groups":[
                  "true:default"
               ]
            }
         },
         "true:empty":{
            "add":{
               "component_groups":[
                  "true:default"
               ]
            },
            "remove":{
               "component_groups":[
                  "true:sentry_loaded"
               ]
            }
         },
         "true:pick_up":{
            "add":{
               "component_groups":[
                  "true:despawn"
               ]
            }
         },
         "true:pick_up_loaded":{
            "add":{
               "component_groups":[
                  "true:despawn"
               ]
            }
         },
         "true:take_bullet":{
            "queue_command":{
               "command":[
                  "scoreboard players remove @e [type=true:sentry_gun,r=1] bullet_count 1",
                  "playsound sentry_gun_shooting @a [r=16] ~ ~ ~",
                  "playanimation @e [type=true:sentry_gun,r=1] animation.sentry_gun.shoot"
               ]
            }
         }
      }
   }
}