{
  "format_version": "1.20.71",
  "minecraft:entity": {
    "description": {
      "identifier": "mythicus_im:hdc.trashcan",
      "is_spawnable": false,
      "is_summonable": true,
      "is_experimental": false,

      "animations": {
        "root": "controller.animation.mythicus_im.trashcan.anchor.root"
      },
      "scripts": {
        "animate": [
          "root"
        ]
      }
    },

    "component_groups": {
      
      "mythicus_im:instant_despawn": { "minecraft:instant_despawn": {} },

      "mythicus_im:trashcan.closed": {
        "minecraft:entity_sensor": {
          "subsensors": [
            {
              "event": "mythicus_im:trashcan.open",
              "cooldown": 0.2,
              "range": [6, 6],
              "minimum_count": 1,
              "event_filters": {
                "all_of": [
                  {
                    "test": "is_family",
                    "subject": "other",
                    "value": "player"
                  },
                  {
                    "test": "has_container_open",
                    "subject": "other",
                    "value": true
                  }
                ]
              }
            }
          ]
        }
      },
      "mythicus_im:trashcan.open": {
        "minecraft:entity_sensor": {
          "subsensors": [
            {
              "event": "mythicus_im:trashcan.closed",
              "cooldown": 0.2,
              "range": [6, 6],
              "minimum_count": 0,
              "maximum_count": 0,
              "event_filters": {
                "all_of": [
                  {
                    "test": "is_family",
                    "subject": "other",
                    "value": "player"
                  },
                  {
                    "test": "has_container_open",
                    "subject": "other",
                    "value": true
                  }
                ]
              }
            }
          ]
        }
      },

      "mythicus_im:trashcan.close": {
        "minecraft:environment_sensor": {
          "triggers": [
            { 
              "filters": { "test": "distance_to_nearest_player", "operator": ">=", "value": 7 },
              "event": "mythicus_im:trashcan.far"
            }
          ]
        }
      },
      "mythicus_im:trashcan.far": {
        "minecraft:environment_sensor": {
          "triggers": [
            { 
              "filters": { "test": "distance_to_nearest_player", "operator": "<", "value": 7 },
              "event": "mythicus_im:trashcan.close"
            }
          ]
        }
      }

    },

    "components": {
      
      "minecraft:collision_box": {
        "width": 0,
        "height": 0
      },
      "minecraft:custom_hit_test": {
        "hitboxes": [
          {
            "width": 0.76,
            "height": 1.0,
            "pivot": [
              0,
              0.5,
              0
            ]
          }
        ]
      },
      "minecraft:damage_sensor": {
        "triggers": {
          "cause": "all",
          "deals_damage": false
        }
      },
      "minecraft:health": {
        "value": 100,
        "min": 100,
        "max": 100
      },
      "minecraft:persistent": {
      },
      "minecraft:knockback_resistance": {
        "value": 1,
        "max": 1
      },
      //"minecraft:push_through": {
      //  "value": 1
      //},
      "minecraft:pushable": {
        "is_pushable": false,
        "is_pushable_by_piston": false
      },
      "minecraft:physics": {
        "has_gravity": false,
        "has_collision": false
      },

      "minecraft:nameable": {
        "allow_name_tag_renaming": false
      },
      "minecraft:is_chested": {},
      "minecraft:inventory": {
        "container_type": "inventory",
        "inventory_size": 27,
        "can_be_siphoned_from": false,
        "restrict_to_owner": false,
        "private": false
      }

    },

    "events": {

      "minecraft:entity_spawned": { "add": { "component_groups": [ "mythicus_im:trashcan.far" ] } },

      "mythicus_im:instant_despawn": { "add": { "component_groups": [ "mythicus_im:instant_despawn" ] } },

      "mythicus_im:trashcan.close": { "add": { "component_groups": [ "mythicus_im:trashcan.close", "mythicus_im:trashcan.closed" ] } },
      "mythicus_im:trashcan.far": { 
        "remove": { "component_groups": [ "mythicus_im:trashcan.closed", "mythicus_im:trashcan.open" ] },
        "add": { "component_groups": [ "mythicus_im:trashcan.far" ] }
      },

      "mythicus_im:trashcan.open": { "add": { "component_groups": [ "mythicus_im:trashcan.open" ] } },
      "mythicus_im:trashcan.closed": { 
        "queue_command": { "command": [ "scriptevent mythicus_im:trashcan.empty" ] },
        "add": { "component_groups": [ "mythicus_im:trashcan.closed" ] } 
      }

    }

  }
}