{
  "format_version": "1.21.90",
  "minecraft:entity": {
    "description": {
      "identifier": "projectile:torpedo",
      "is_spawnable": false,
      "is_summonable": true
    },

    "component_groups": {
      "explodeWater": {
        "minecraft:explode": {
          "power": 10,
          "fuse_length": 0.1,
          "max_resistance": 4.4,
          "breaks_blocks": true,
          "causes_fire": false,
          "destroy_affected_by_griefing": true,
          "fire_affected_by_griefing": false,
          "fuse_lit": true
        }
      },
      "despawn": {
        "minecraft:instant_despawn": {}
      }
    },

    "components": {
      "minecraft:despawn": {
        "despawn_from_distance": {
        "max_distance": 60,
        "min_distance": 55
        }
      },
      "minecraft:timer": {
        "time": 0.5,
        "time_down_event": {
          "event": "clear"
        }
      },
      "minecraft:buoyant": {
        "base_buoyancy": 1.0,
        "apply_gravity": true,
        "simulate_waves": true,
        "big_wave_probability": 0.03,
        "big_wave_speed": 10.0,
        "liquid_blocks": [
          "minecraft:water",
          "minecraft:flowing_water"
        ]
      },
      "minecraft:entity_sensor": {
        "relative_range": false,
        "subsensors": [
          {
            "cooldown": 1.0,
            "range": [1, 1],
            "event": "checkDespawn",
            "event_filters": [
              {
                "test": "in_contact_with_water",
                "subject": "self",
                "operator": "!=",
                "value": true
              }
              ]
          }
          ]
        },
      "minecraft:is_hidden_when_invisible": {
      },
      "minecraft:damage_sensor": {
        "triggers": {
          "on_damage": {
            "filters": [
              { "test": "has_tag", "subject": "other", "operator": "!=", "value": "hswowhs" }
              ]
          },
          "deals_damage": "no"
        }
      },
      "minecraft:type_family": {
        "family": [ "custom_mob", "misc", "torpedo" ]
      },
      "minecraft:breathable": {
        "total_supply": 1500,
        "suffocate_time": 0
      },
      "minecraft:nameable": {
      },
      "minecraft:health": {
        "value": 1000,
        "max": 1000,
        "min": 1
      },
      "minecraft:movement": {
        "value": 0.25
      },
      "minecraft:navigation.walk": {
        "can_path_over_water": true,
        "avoid_water": true,
        "is_amphibious": true,
        "avoid_damage_blocks": true
      },
      "minecraft:movement.basic": {

      },
      "minecraft:collision_box": {
        "width": 0.25,
        "height": 0.25
      },
      "minecraft:behavior.float": {
        "priority": 2
      },
	    "minecraft:physics": {
      },
      "minecraft:pushable": {
        "is_pushable": false,
        "is_pushable_by_piston": true
      },
      "minecraft:conditional_bandwidth_optimization": {
      }
    },

    "events": {
      "clear": {
        "queue_command": {
          "command": [
            "tag @s add clear"
            ]
        }
      },
      "explodeWater": {
        "sequence": [
          {
            "queue_command": {
              "command": [
                "particle torpedo:impact",
                "execute as @s[tag=clear] run damage @e[r=15] 200 entity_explosion"
                ]
            }
          },
          {
            "add": {
              "component_groups": [
                "explodeWater"
                ]
            },
            "filters": [
              {
                "all_of": [
                  {
                    "test": "has_tag",
                    "operator": "==",
                    "subject": "self",
                    "value": "clear"
                  }
                  ]
              }
          ]
          }
          ]
      },
      "checkDespawn": {
        "queue_command": {
          "command": [
            "execute as @s unless block ~~-0.25~ water run event entity @s despawn"
            ]
        }
      },
      "despawn": {
        "add": {
          "component_groups": [
            "despawn"
            ]
        }
      },
      "movement:engage": {
        "sequence": [
          {
            "queue_command": {
              "command": [
                "tp @s[tag=clear] ^^^1.4"
                ]
            }
          },
          {
            "queue_command": {
              "command": [
                "execute as @e[r=2.5,type=!projectile:torpedo,c=1] at @s run event entity @e[type=projectile:torpedo,r=3,tag=clear] explodeWater",
                "execute as @s[tag=clear] unless block ^^^1.5 water run event entity @s explodeWater",
                "execute as @s[tag=clear] unless block ^^^-1.5 water run event entity @s explodeWater",
                "execute as @s[tag=clear] unless block ^1.5^^ water run event entity @s explodeWater",
                "execute as @s[tag=clear] unless block ^-1.5^^ water run event entity @s explodeWater"
                ]
            }
          }
          ]
      },
      "minecraft:entity_spawned": {
        "sequence": [
          {
            "queue_command": {
              "command": [
                "scoreboard players add @s kbHori 30",
                "scriptevent dash:front"
                ]
            }
          }
        ]
      }
    }
  }
}
