//self reminder, dont use unless for heavy testing.
{
  "format_version": "1.21.0",
  "minecraft:entity": {
    "description": {
      "identifier": "hostile:creeper",
      "spawn_category": "creature",
      "is_spawnable": false,
      "is_summonable": true,
      "properties": {
        "creeper:charged": {
          "client_sync": true,
          "type": "enum",
          "default": "no",
          "values": [
            "no",
            "yes"
            ]
        },
        "creeper:variant": {
          "client_sync": true,
          "type": "enum",
          "default": "grass",
          "values": [
            "grass",
            "stone",
            "deepslate"
            ]
        },
        "attack:state": {
          "client_sync": true,
          "type": "enum",
          "default": "idle",
          "values": [
            "idle",
            "block",
            "basic1",
            "basic2",
            "basic3",
            "basic4",
            "charged",
            "skill",
            "grab",
            "stun",
            "dash",
            "domain"
            ]
        },
        "attack:card": {
          "client_sync": true,
          "type": "enum",
          "default": "idle",
          "values": [
            "idle",
            "grab"
            ]
        },
        "movement:state": {
          "client_sync": true,
          "type": "enum",
          "default": "walk",
          "values": [
            "walk",
            "sprint"
            ]
        },
        "damage:reduction_thorns": {
          "default": 10,
          "type": "int",
          "range": [-50, 50],
          "client_sync": true
        },
        "damage:reduction_contact": {
          "default": 10,
          "type": "int",
          "range": [0, 20],
          "client_sync": true
        },
        "damage:reduction_magic": {
          "default": 10,
          "type": "int",
          "range": [0, 20],
          "client_sync": true
        },
        "damage:reduction_projectile": {
          "default": 10,
          "type": "int",
          "range": [0, 20],
          "client_sync": true
        },
        "damage:reduction_attack": {
          "default": 10,
          "type": "int",
          "range": [0, 20],
          "client_sync": true
        }
      }
    },

    "component_groups": {
      "sensor_charged": {
        "minecraft:is_charged": {
        },
        "minecraft:target_nearby_sensor": {
          "inside_range": 2.0,
          "outside_range": 3.0,
          "must_see": true,
          "on_inside_range": {
            "event": "explode_charged"
          },
          "on_outside_range": {
            "event": "turnoff"
          },
          "on_vision_lost_inside_range": {
            "event": "turnoff"
          }
        }
      },
      "sensor": {
        "minecraft:target_nearby_sensor": {
          "inside_range": 2.0,
          "outside_range": 3.0,
          "must_see": true,
          "on_inside_range": {
            "event": "explode"
          },
          "on_outside_range": {
            "event": "turnoff"
          },
          "on_vision_lost_inside_range": {
            "event": "turnoff"
          }
        }
      },
      "explode_charged": {
        "minecraft:explode": {
          "power": 8,
          "fuse_length": 1.96,
          "max_resistance": 4.2,
          "breaks_blocks": true,
          "causes_fire": true,
          "destroy_affected_by_griefing": true,
          "fire_affected_by_griefing": false,
          "fuse_lit": true
        }
      },
      "explode": {
        "minecraft:explode": {
          "power": 5,
          "fuse_length": 1.96,
          "max_resistance": 4.2,
          "breaks_blocks": false,
          "causes_fire": true,
          "destroy_affected_by_griefing": true,
          "fire_affected_by_griefing": false,
          "fuse_lit": true
        }
      },
      "fixcollision": {
        "minecraft:collision_box": {
          "width": 0.6,
          "height": 1.5
        }
      },
      "creeper": {
        "minecraft:type_family": {
          "family": [ "mob", "custom_mob", "hostile", "creeper",
          "superarmor", "monster", "undead"]
        }
      },
      "chaseTarget": {
        "minecraft:entity_sensor": {
          "relative_range": false,
          "subsensors": [
            {
              "cooldown": 10,
              "event": "defense:random",
              "event_filters": [
                {
                  "all_of": [
                    {
                      "test": "target_distance",
                      "operator": "<",
                      "value": 6
                    },
                    {
                      "test": "has_tag",
                      "subject": "self",
                      "operator": "!=",
                      "value": "stun"
                    },
                    {
                      "test": "has_tag",
                      "subject": "self",
                      "operator": "!=",
                      "value": "hasSkill"
                    },
                    {
                      "test": "has_tag",
                      "subject": "self",
                      "operator": "!=",
                      "value": "blocking"
                    },
                    {
                      "test": "has_tag",
                      "subject": "self",
                      "operator": "!=",
                      "value": "basicAttack"
                    },
                    {
                      "any_of": [
                    {
                      "test": "has_tag",
                      "subject": "target",
                      "operator": "==",
                      "value": "hasSkill"
                    },
                    {
                      "test": "has_tag",
                      "subject": "target",
                      "operator": "==",
                      "value": "blocking"
                    },
                    {
                      "test": "has_tag",
                      "subject": "target",
                      "operator": "==",
                      "value": "basicAttack"
                    }
                        ]
                    }
                    ]
                }
              ]
            }
            ]
        }
      },
      "dashing": {
        "minecraft:timer": {
          "time": 0.75,
          "time_down_event": {
            "event": "chaseTarget"
          }
        }
      },
      "cooldownAttack": {
        "minecraft:entity_sensor": {
          "relative_range": false,
          "subsensors": [
            {
              "cooldown": 0.1,
              "event": "hasTarget",
              "event_filters": [
                {
                  "all_of": [
                    {
                      "test": "has_tag",
                      "subject": "self",
                      "operator": "==",
                      "value": "timer_0"
                    }
                    ]
                }
                ]
            },
            {
              "cooldown": 10,
              "event": "defense:random",
              "event_filters": [
                {
                  "all_of": [
                    {
                      "test": "target_distance",
                      "operator": "<",
                      "value": 8
                    },
                    {
                      "test": "has_tag",
                      "subject": "self",
                      "operator": "!=",
                      "value": "stun"
                    },
                    {
                      "test": "has_tag",
                      "subject": "self",
                      "operator": "!=",
                      "value": "hasSkill"
                    },
                    {
                      "test": "has_tag",
                      "subject": "self",
                      "operator": "!=",
                      "value": "blocking"
                    },
                    {
                      "test": "has_tag",
                      "subject": "self",
                      "operator": "!=",
                      "value": "basicAttack"
                    },
                    {
                      "any_of": [
                    {
                      "test": "has_tag",
                      "subject": "target",
                      "operator": "==",
                      "value": "hasSkill"
                    },
                    {
                      "test": "has_tag",
                      "subject": "target",
                      "operator": "==",
                      "value": "blocking"
                    },
                    {
                      "test": "has_tag",
                      "subject": "target",
                      "operator": "==",
                      "value": "basicAttack"
                    }
                        ]
                    }
                    ]
                }
              ]
            }
            ]
        }
      },
      "hasTarget": {
      },
      
      "despawn": {
        "minecraft:instant_despawn": {}
      },
      
      "movement_stop": {
      "minecraft:movement": {
        "value": 0.0
      }
      },
      "movement_walk": {
      "minecraft:movement": {
        "value": 0.2
      }
      },
      "movement_sprint": {
      "minecraft:movement": {
        "value": 0.2
      }
      },
      "body_rotation_enabled": {
        "minecraft:movement.basic": {
          "max_turn": 45
        }
      },
      "body_rotation_blocked": {
        "minecraft:movement.basic": {
          "max_turn": 0
        },
        "minecraft:body_rotation_blocked": {}
      },
      "kb_res": {
        "minecraft:knockback_resistance": {
          "value": 1.0
        }
      },
      "kb_enable": {
        "minecraft:knockback_resistance": {
          "value": 0.0
        }
      },
      "damage_iframes": {
      "minecraft:damage_sensor": {
        "triggers": {
          "on_damage": {
            "filters": { "test": "is_family", "subject": "other", "value": "lightning"
            },
            "event": "minecraft:become_charged"
          },
          "deals_damage": false
        }
      }
      },
      "damage_sensor": {
      "minecraft:damage_sensor": {
        "triggers": {
          "on_damage": {
            "filters": { "test": "is_family", "subject": "other", "value": "lightning"
            },
            "event": "minecraft:become_charged"
          },
          "deals_damage": false
        }
      }
      }
    },

    "components": {
      "minecraft:damage_sensor": {
        "triggers": {
          "on_damage": {
            "filters": { "test": "is_family", "subject": "other", "value": "lightning"
            },
            "event": "minecraft:become_charged"
          },
          "deals_damage": false
        }
      },
      "minecraft:behavior.avoid_mob_type": {
        "priority": 3,
        "entity_types": [
          {
            "filters": {
              "any_of": [
                { "test" :  "is_family", "subject" : "other", "value" :  "ocelot"},
                { "test" :  "is_family", "subject" : "other", "value" :  "cat"}
              ]
            },
            "max_dist": 6,
            "sprint_speed_multiplier": 1.2
          }
        ]
      },
      "minecraft:loot": {
        "table": "loot_tables/entities/creeperv2.json"
      },
      "minecraft:behavior.hurt_by_target": {
        "priority": 2
      },
      "minecraft:health": {
        "value": 50,
        "max": 50
      },
      "minecraft:follow_range": {
        "value": 30
      },
      "minecraft:behavior.nearest_attackable_target": {
        "priority": 3,
        "must_see": true,
        "reselect_targets": false,
        "within_radius": 30,
        "must_see_forget_duration": 100.0,
        "entity_types": [
          {
            "filters": {
              "any_of": [
                {
                  "any_of": [
                  {
                    "test": "is_family",
                    "subject": "other",
                    "operator": "==",
                    "value": "player"
                  },
                  {
                    "test": "is_family",
                    "subject": "other",
                    "operator": "==",
                    "value": "illager"
                  }
                  ]
                }
                ]
            },
            "max_dist": 31
          }
        ]
      },
      "minecraft:movement.basic": {},
      "minecraft:navigation.walk": {
        "is_amphibious": true,
        "can_pass_doors": true,
        "can_walk": true,
        "can_break_doors": false
      },
      "minecraft:jump.static": {},
      "minecraft:can_climb": {},
      "minecraft:behavior.random_stroll": {
        "priority": 17,
        "speed_multiplier": 1.0
      },
      
      //vanillaComponents(
      "minecraft:experience_reward": {
        "on_death": "Math.Min(query.player_level * 7, 100)"
      },
      "minecraft:is_hidden_when_invisible": {
      },
      "minecraft:collision_box": {
        "width": 0.6,
        "height": 1.5
      },
      "minecraft:can_climb": {
      },
      "minecraft:movement": {
        "value": 0.0
      },
      "minecraft:hurt_on_condition": {
        "damage_conditions": [
          {
            "filters": {
              "test": "in_lava",
              "subject": "self",
              "operator": "==",
              "value": true
            },
            "cause": "lava",
            "damage_per_tick": 4
          }
        ]
      },
      "minecraft:attack": {
        "damage": 0
      },
      "minecraft:behavior.melee_attack": {
        "priority": 1,
        "cooldown_time": 500,
        "speed_multiplier": 1.0,
        "track_target": true
      },
      "minecraft:breathable": {
        "total_supply": 15,
        "suffocate_time": -1,
        "inhale_time": 3.75,
        "generates_bubbles": false
      },
      "minecraft:nameable": {
        "always_show": false,
        "allow_name_tag_renaming": true
      },
      "minecraft:physics": {
        "push_towards_closest_space": true
      },
      "minecraft:pushable": {
        "is_pushable": false,
        "is_pushable_by_piston": true
      },
      "minecraft:conditional_bandwidth_optimization": {
      },
      "minecraft:block_climber": {}
      //)
    },

    "events": {
      "minecraft:become_charged": {
        "set_property": {
          "creeper:charged": "yes"
        },
        "remove": {
          "component_groups": [
            "sensor"
            ]
        },
        "add": {
          "component_groups": [
            "sensor_charged"
            ]
        }
      },
      "turnoff": {
        "set_property": {
          "attack:state": "idle"
        },
        "queue_command": {
          "command": [
            "event entity @s movement:sprint"
            ]
        },
        "remove": {
          "component_groups": [
            "explode",
            "explode_charged"
            ]
        }
      },
      "explode_charged": {
        "set_property": {
          "attack:state": "basic1"
        },
        "queue_command": {
          "command": [
            "event entity @s movement:stop"
            ]
        },
        "sequence": [
          {
            "add": {
              "component_groups": [
                "explode_charged"
                ]
            }
          }
          ]
      },
      "explode": {
        "set_property": {
          "attack:state": "basic1"
        },
        "queue_command": {
          "command": [
            "event entity @s movement:stop"
            ]
        },
        "sequence": [
          {
            "add": {
              "component_groups": [
                "explode"
                ]
            }
          }
          ]
      },
      "become:creeper": {
        "sequence": [
          {
            "queue_command": {
              "command": [
                "tag @s add team:undead",
                "tag @s add stunImmune"
                ]
            }
          },
          {
            "add": {
              "component_groups": [
                "creeper",
                "sensor"
                ]
            }
          },
          {
            "randomize": [
              {
                "weight": 1,
                "set_property": {
                  "creeper:variant": "grass"
                },
                "filters": {
                  "test": "is_underground",
                  "subject": "self",
                  "operator": "==",
                  "value": false
                }
              },
              {
                "weight": 1,
                "set_property": {
                  "creeper:variant": "stone"
                },
                "filters": {
                  "test": "is_underground",
                  "subject": "self",
                  "operator": "==",
                  "value": true
                }
              },
              {
                "weight": 1,
                "set_property": {
                  "creeper:variant": "deepslate"
                },
                "filters": {
                  "test": "is_underground",
                  "subject": "self",
                  "operator": "==",
                  "value": true
                }
              }
              ]
          }
          ]
      },
      
      "defense:random": {
        "set_property": {
          "attack:state": "idle"
        },
        "queue_command": {
          "command": [
            "scoreboard players set @s combatTag -1",
            "scoreboard players set @s block 0",
            "execute as @s if entity @e[r=20,tag=dev] at @s run say §aDefenseRandom"
          ]
        },
        "remove": {
          "component_groups": [
            "cooldownAttack",
            "hasBlock",
            "chaseTarget",
            "hasTarget"
            ]
        },
        "randomize": [
          {
            "weight": 1,
            "sequence": [
              {
                "queue_command": {
                  "command": [
                    "execute as @s at @e[tag=dev] run say I dashed, left(defense:random)",
                    "scoreboard players set @s kbHori 25"
                    ]
                }
              },
              {
                "queue_command": {
                  "command": [
                    "scriptevent dash:left"
                    ]
                }
              }
              ]
          },
          {
            "weight": 1,
            "sequence": [
              {
                "queue_command": {
                  "command": [
                    "execute as @s at @e[tag=dev] run say I dashed, right(defense:random)",
                    "scoreboard players set @s kbHori 25"
                    ]
                }
              },
              {
                "queue_command": {
                  "command": [
                    "scriptevent dash:right"
                    ]
                }
              }
              ]
          }
          ]
      },
      "chaseTarget": {
        "set_property": {
          "attack:state": "idle"
        },
        "queue_command": {
          "command": [
            "scoreboard players set @s combatTag -1",
            "execute as @s if entity @e[r=20,tag=dev] at @s run say §cChaseTarget"
          ]
        },
        "remove": {
          "component_groups": [
            "hasTarget",
            "dashing",
            "movement_stop",
            "movement_walk",
            "explode"
            ]
        },
        "randomize": [
          {
            "weight": 2,
            "add": {
              "component_groups": [
                "chaseTarget"
                ]
            },
            "queue_command": {
              "command": [
                "execute as @s at @e[tag=dev] run say I am sprinting(chaseTarget)",
                "event entity @s movement:sprint"
                ]
            },
            "set_property": {
              "movement:state": "sprint"
            }
          }
          ]
      },
      "cooldownAttack": {
        "queue_command": {
          "command": [
            "event entity @s projectile_remove",
            "scoreboard objectives add timer dummy",
            "scoreboard players random @s timer 3 60",
            "scoreboard players set @s[tag=hasTarget] combatTag 40",
            "execute as @s if entity @e[r=20,tag=dev] at @s run say §fCooldownAttack"
            ]
        },
        "set_property": {
          "attack:state": "idle",
          "attack:card": "idle"
        },
        "add": {
          "component_groups": [
            "cooldownAttack"
            ]
        }
      },
      "hasTarget": {
        "add": {
          "component_groups": [
            "hasTarget"
            ]
        },
        "remove": {
          "component_groups": [
            "cooldownAttack",
            "dashing",
            "hasBlock",
            "chaseTarget"
            ]
        },
        "queue_command": {
          "command": [
            "scoreboard players set @s combatTag -1",
            "execute as @s at @e[tag=dev] run say Found a Target(hasTarget)",
            "event entity @s[tag=hasTarget] movement:sprint",
            "event entity @s[tag=!hasTarget] movement:walk"
            ]
        }
      },
      "rideable": {
        "add": {
          "component_groups": [
            "rideable"
            ]
        }
      },
      "ridedisable": {
        "remove": {
          "component_groups": [
            "rideable"
            ]
        }
      },
      
      "despawn": {
        "add": {
          "component_groups": [
            "despawn"
            ]
        }
      },
      
      "attack_card:grab": {
        "set_property": {
          "attack:card": "grab"
        }
      },
      "attack_card:idle": {
        "set_property": {
          "attack:card": "idle"
        }
      },
      "attack_state:stun": {
        "set_property": {
          "attack:state": "stun"
        }
      },
      "attack_state:idle": {
        "set_property": {
          "attack:state": "idle"
        }
      },
      "attack_state:grab": {
        "set_property": {
          "attack:state": "grab"
        }
      },
      "attack_state:block": {
        "set_property": {
          "attack:state": "block"
        }
      },
      "attack_state:basic1": {
        "set_property": {
          "attack:state": "basic1"
        }
      },
      "attack_state:basic2": {
        "set_property": {
          "attack:state": "basic2"
        }
      },
      "attack_state:basic3": {
        "set_property": {
          "attack:state": "basic3"
        }
      },
      "attack_state:basic4": {
        "set_property": {
          "attack:state": "basic4"
        }
      },
      "attack_state:charged": {
        "set_property": {
          "attack:state": "charged"
        }
      },
      "attack_state:skill": {
        "set_property": {
          "attack:state": "skill"
        }
      },
      "attack_state:domain": {
        "set_property": {
          "attack:state": "domain"
        }
      },
      
      "remove_kb": {
        "sequence": [
          {
            "queue_command": {
              "command": [
                "tag @e remove KBframes"
                ]
            }
          },
          {
            "remove": {
              "component_groups": [
                "roar0_5",
                "roar1",
                "roar1_5",
                "roar2",
                "roar2_5",
                "roar3",
                "roar3_5",
                "roar4",
                "roar4_5",
                "pullroar0_5",
                "pullroar1",
                "pullroar1_5",
                "pullroar2",
                "pullroar2_5",
                "pullroar3",
                "pullroar3_5",
                "pullroar4",
                "pullroar4_5",
                 "golemKnock"
                ]
            }
          }
          ]
      },
      
      "movement:sprint": {
        "queue_command": {
          "command": [
            "execute as @s at @e[tag=dev] run say §aI am Sprinting(movement)"
            ]
        },
        "remove": {
          "component_groups": [
            "movement_walk",
            "movement_stop"
            ]
        },
        "add": {
          "component_groups": [
            "movement_sprint"
            ]
        },
        "set_property": {
          "movement:state": "sprint"
        }
      },
      "movement:walk": {
        "queue_command": {
          "command": [
            "execute as @s at @e[tag=dev] run say §eI am Walking(movement)"
            ]
        },
        "add": {
          "component_groups": [
            "movement_walk"
            ]
        },
        "remove": {
          "component_groups": [
            "movement_sprint",
            "movement_stop"
            ]
        },
        "set_property": {
          "movement:state": "walk"
        }
      },
      "movement:stop": {
        "queue_command": {
          "command": [
            "execute as @s at @e[tag=dev] run say §cI am Idle(movement)"
            ]
        },
        "add": {
          "component_groups": [
            "movement_stop"
            ]
        },
        "remove": {
          "component_groups": [
            "movement_sprint",
            "movement_walk"
            ]
        }
      },
      "body_rotation:blocked": {
        "add": {
          "component_groups": [
            "body_rotation_blocked"
            ]
        }
      },
      "body_rotation:enabled": {
        "add": {
          "component_groups": [
            "body_rotation_enabled"
            ]
        },
        "remove": {
          "component_groups": [
            "body_rotation_blocked"
            ]
        }
      },
      "kb:resistance": {
        "add": {
          "component_groups": [
            "kb_res"
            ]
        },
        "remove": {
          "component_groups": [
            "kb_enable"
            ]
        }
      },
      "no_kb:resistance": {
        "remove": {
          "component_groups": [
            "kb_res"
            ]
        },
        "add": {
          "component_groups": [
            "kb_enable"
            ]
        }
      },
      "invincibility:off": {
        "remove": {
          "component_groups": [
            "damage_iframes"
            ]
        },
        "add": {
          "component_groups": [
            "damage_sensor"
            ]
        }
      },
      "invincibility:on": {
        "add": {
          "component_groups": [
            "damage_iframes"
            ]
        },
        "remove": {
          "component_groups": [
            "damage_sensor"
            ]
        }
      },
      "takingHitProj": {
        "sequence": [
          {
            "queue_command": {
              "command": [
                "scoreboard players add @s[tag=!sunImmune] stun 10",
                "scoreboard players add @s takingHit 1"
                ]
            }
          }
          ]
      },
      "takingHit": {
        "sequence": [
          {
            "queue_command": {
              "command": [
                "scoreboard players add @s takingHit 1"
                ]
            }
          }
          ]
      },
      "evadingDamage": {
        "sequence": [
          {
            "queue_command": {
              "command": [
                "scoreboard players add @s evadingDamage 1"
                ]
            }
          }
          ]
      },
      "minecraft:entity_spawned": {
        "sequence": [
          {
            "queue_command": {
              "command": [
                "scoreboard players set @s spawnCD 0",
                "scoreboard players set @s stun 10",
                "scoreboard players set @s combatTag -1",
                "function setScoreboardObjectives",
                "effect @s weakness infinite 255 true"
                ]
            }
          },
          {
            "add": {
              "component_groups": [
                "movement_sprint",
                "hasTarget",
                "damage_sensor",
                "body_rotation_enabled",
                "creeper"
                ]
            }
          },
          {
            "remove": {
              "component_groups": [
                "movement_walk"
                ]
            }
          },
          {
            "queue_command": {
              "command": [
                "scoreboard players set @s bluntRes 12",
                "scoreboard players set @s slashRes 20",
                "scoreboard players set @s magicRes 20",
                "scoreboard players set @s pierceRes 5"
                ]
            }
          }
          ]
      }
    }
  }
}