{
  "format_version": "1.16.0",
  "minecraft:entity": {
    "description": {
      "identifier": "numberblocks:octonaughty",
      "spawn_category": "creature",
      "is_spawnable": true,
      "is_summonable": true,
      "properties": {
        "minecraft:nature_spawn": {
          "type": "bool", 
          "default": false,
          "client_sync": true
        },
        "numberblocks:splited": {
          "type": "bool", 
          "default": false,
          "client_sync": true
        },
        "numberblocks:eight": {
          "type": "int",
          "range": [ 0, 1 ], 
          "default": 0, 
          "client_sync": true
        }
      }
    },
    
    "component_groups": {
      "nature_spawn": {
        "minecraft:experience_reward": {
          "on_death": "query.last_hit_by_player ? 10 + (Math.die_roll(query.equipment_count,2,6)) : 0"
        },
        "minecraft:loot": {
          "table": "loot_tables/entities/numberblocks/octonaughty.json"
        },
        "minecraft:despawn": {
          "despawn_from_distance": {}
        }
      },
      "normal": {
        "minecraft:health": {
          "value": 20,
          "max": 20
        },
        "minecraft:attack": {
          "damage": 6
        },
        "minecraft:collision_box": {
          "width": 0.8,
          "height": 2.3
        }
      },
      "cube": {
        "minecraft:health": {
          "value": 24,
          "max": 24
        },
        "minecraft:attack": {
          "damage": 4
        },
        "minecraft:collision_box": {
          "width": 1,
          "height": 1.3
        }
      },
      "angry": {
        "minecraft:angry": {
          "duration": 30,
          "broadcast_anger": false,
          "broadcast_anger_on_attack": false,
          "broadcast_anger_on_being_attacked": true,
          "broadcast_range": 16,
          "broadcast_targets": [
            "terrible_two"
          ],
          "calm_event": {
            "event": "become_calm_event",
            "target": "self"
          },
          "filters": {
            "all_of": [
              { "test": "is_family", "subject": "other", "operator": "!=", "value": "terribleblock" },
              { "test": "is_family", "subject": "other", "operator": "!=", "value": "illager" },
              { "test": "is_family", "subject": "other", "operator": "!=", "value": "twenty_seven" },
              { "test": "is_family", "subject": "other", "operator": "!=", "value": "forty" },
              { "test": "is_family", "subject": "other", "operator": "!=", "value": "fifty_six" },
              {
                "none_of": [
                  {
                    "all_of": [
                      { "test": "is_family", "subject": "other", "value": "sixty_four" },
                      { "test": "int_property", "subject": "other", "domain": "numberblocks:sixty_four", "value": 1 }
                    ]
                  }
                ]
              },
              { "test": "is_family", "subject": "other", "operator": "!=", "value": "seventy_two" },
              { "test": "is_family", "subject": "other", "operator": "!=", "value": "eighty" }
            ]
          }
        }
      },
      "split_into_quarters_nature_spawn": {
        "minecraft:transformation": {
          "into": "numberblocks:terrible_two_blue<numberblocks:spawn_fours>",
          "preserve_equipment": true
        }
      },
      "split_into_quarters": {
        "minecraft:transformation": {
          "into": "numberblocks:terrible_two_blue<numberblocks:egg_spawn_fours>",
          "preserve_equipment": true
        }
      },
      "has_fractionator": {
        "minecraft:equipment": {
          "table": "loot_tables/entities/numberblocks/fractionator_equipment.json",
          "slot_drop_chance": [
            {
              "slot": "slot.weapon.mainhand",
              "drop_chance": 1.0
            }
          ]
        }
      }
    },
    "components": {
      "minecraft:is_hidden_when_invisible": {
      },

      "minecraft:type_family": {
        "family": [
          "eight",
          "numberblock",
          "numberblocks",
          "mob",
          "terribleblock",
          "even",
          "octonaughty",
          "cube",
          "male"
        ]
      },
      "minecraft:breathable": {
        "total_supply": 15,
        "suffocate_time": 0
      },
      "minecraft:nameable": {
      },
      "minecraft:health": {
        "value": 20,
        "max": 20
      },
      "minecraft:attack": {
        "damage": 6
      },
      "minecraft:leashable_to": {
      },
      "minecraft:hurt_on_condition": {
        "damage_conditions": [
          {
            "filters": { "test": "in_lava", "subject": "self", "operator": "==", "value": true },
            "cause": "lava",
            "damage_per_tick": 4
          }
        ]
      },
      "minecraft:movement": {
        "value": 0.25
      },
      "minecraft:navigation.walk": {
        "can_path_over_water": true,
        "avoid_water": true,
        "avoid_damage_blocks": true
      },
      "minecraft:movement.basic": {

      },
      "minecraft:jump.static": {
      },
      "minecraft:can_climb": {
      },
      "minecraft:on_target_acquired": {
        "event": "become_angry_event",
        "target": "self"
      },
      "minecraft:equipment": {
        "slot_drop_chance": [
          {
            "slot": "slot.weapon.mainhand",
            "drop_chance": 1.0
          }
        ]
      },
      "minecraft:interact": {
        "interactions": [
          {
            "cooldown": 0,
            "use_item": false,
            "interact_text": "action.interact.numberblockssplit",
            "on_interact": {
              "filters": {
                "all_of": [
                  { "test": "has_equipment", "subject": "other", "domain": "hand", "value": "numberblocks:fractionator_split_into_quarters" },
                  { "test": "bool_property", "subject": "self", "domain": "numberblocks:splited", "operator": "!=" }
                ]
              },
              "event": "numberblocks:split_into_quarters"
            }
          },
          {
            "cooldown": 0,
            "use_item": false,
            "interact_text": "action.interact.blocksuniverseform",
            "on_interact": {
              "filters": {
                "all_of": [
                  {
                    "any_of": [
                      { "test": "is_family", "subject": "other", "value": "terribleblock" },
                      { "test": "bool_property", "subject": "other", "domain": "numberblocks:creative_family" }
                    ]
                  },
                  {
                    "any_of": [
                      { "test": "has_equipment", "subject": "other", "domain": "hand", "operator": "!=", "value": "name_tag" },
                      { "test": "has_nametag", "subject": "self" }
                    ]
                  }
                ]
              },
              "event": "numberblocks:change_form"
            }
          }
        ]
      },
      "minecraft:behavior.float": {
        "priority": 0
      },
      "minecraft:behavior.avoid_mob_type": {
        "priority": 1,
        "entity_types": [
          {
            "filters": {
              "all_of": [
                {
                  "any_of": [
                    { "test": "is_family", "subject": "other", "value": "twenty_seven" },
                    { "test": "is_family", "subject": "other", "value": "fifty_six" },
                    { "test": "is_family", "subject": "other", "value": "sixty_four_cube" },
                    { "test": "is_family", "subject": "other", "value": "seventy_two" },
                    { "test": "is_family", "subject": "other", "value": "eighty" }
                  ]
                },
                {
                  "any_of": [
                    { "test": "is_family", "subject": "other", "value": "player" },
                    { "test": "bool_property", "subject": "other", "domain": "numberblocks:splited" },
                    {
                      "none_of": [
                        {
                          "all_of": [
                            { "test": "is_family", "subject": "other", "value": "even" },
                            { "test": "has_equipment", "subject": "self", "domain": "hand", "value": "numberblocks:fractionator_split_into_half" }
                          ]
                        },
                        {
                          "all_of": [
                            { "test": "is_family", "subject": "other", "value": "family_of_threes" },
                            { "test": "has_equipment", "subject": "self", "domain": "hand", "value": "numberblocks:fractionator_split_into_thirds" }
                          ]
                        },
                        {
                          "all_of": [
                            { "test": "is_family", "subject": "other", "value": "family_of_fours" },
                            { "test": "has_equipment", "subject": "self", "domain": "hand", "value": "numberblocks:fractionator_split_into_quarters" }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            "max_dist": 8,
            "sprint_speed_multiplier": 1.3
          }
        ]
      },
      "minecraft:behavior.hurt_by_target": {
        "priority": 2,
        "entity_types": [
          {
            "filters": {
              "all_of": [
                { "test": "is_family", "subject": "other", "operator": "!=", "value": "terribleblock" },
                { "test": "is_family", "subject": "other", "operator": "!=", "value": "illager" },
                { "test": "is_family", "subject": "other", "operator": "!=", "value": "twenty_seven" },
                { "test": "is_family", "subject": "other", "operator": "!=", "value": "fifty_six" },
                {
                  "none_of": [
                    {
                      "all_of": [
                        { "test": "is_family", "subject": "other", "value": "sixty_four" },
                        { "test": "int_property", "subject": "other", "domain": "numberblocks:sixty_four", "value": 1 }
                      ]
                    }
                  ]
                },
                { "test": "is_family", "subject": "other", "operator": "!=", "value": "seventy_two" },
                { "test": "is_family", "subject": "other", "operator": "!=", "value": "eighty" }
              ]
            },
            "max_dist": 64
          }
        ]
      },
      "minecraft:behavior.send_event": {
        "priority": 3,
        "event_choices": [
          {
            "min_activation_range": 0.0,
            "max_activation_range": 8.0,
            "cooldown_time": 5.0,
            "cast_duration": 1.0,
            "weight": 1,
            "filters": {
              "all_of": [
                { "test": "has_equipment", "subject": "self", "domain": "hand", "value": "numberblocks:fractionator_split_into_half" },
                { "test": "is_family", "subject": "other", "operator": "!=", "value": "player" },
                { "test": "is_family", "subject": "other", "operator": "!=", "value": "terribleblock" },
                { "test": "bool_property", "subject": "other", "domain": "numberblocks:splited", "operator": "!=" },
                { "test": "is_family", "subject": "other", "value": "even" },
                { "test": "is_family", "subject": "other", "operator": "!=", "value": "zero" }
              ]
            },
            "sequence": [
              {
                "event": "numberblocks:split_into_half"
              }
            ]
          },
          {
            "min_activation_range": 0.0,
            "max_activation_range": 8.0,
            "cooldown_time": 5.0,
            "cast_duration": 1.0,
            "weight": 1,
            "filters": {
              "all_of": [
                { "test": "has_equipment", "subject": "self", "domain": "hand", "value": "numberblocks:fractionator_split_into_thirds" },
                { "test": "is_family", "subject": "other", "operator": "!=", "value": "player" },
                { "test": "is_family", "subject": "other", "operator": "!=", "value": "terribleblock" },
                { "test": "bool_property", "subject": "other", "domain": "numberblocks:splited", "operator": "!=" },
                { "test": "is_family", "subject": "other", "value": "family_of_threes" }
              ]
            },
            "sequence": [
              {
                "event": "numberblocks:split_into_thirds"
              }
            ]
          },
          {
            "min_activation_range": 0.0,
            "max_activation_range": 8.0,
            "cooldown_time": 5.0,
            "cast_duration": 1.0,
            "weight": 1,
            "filters": {
              "all_of": [
                { "test": "has_equipment", "subject": "self", "domain": "hand", "value": "numberblocks:fractionator_split_into_quarters" },
                { "test": "is_family", "subject": "other", "operator": "!=", "value": "player" },
                { "test": "is_family", "subject": "other", "operator": "!=", "value": "terribleblock" },
                { "test": "bool_property", "subject": "other", "domain": "numberblocks:splited", "operator": "!=" },
                { "test": "is_family", "subject": "other", "value": "family_of_fours" }
              ]
            },
            "sequence": [
              {
                "event": "numberblocks:split_into_quarters"
              }
            ]
          }
        ]
      },
      "minecraft:behavior.nearest_attackable_target": {
        "priority": 3,
        "must_see": true,
        "reselect_targets": true,
        "within_radius": 16.0,
        "entity_types": [
          {
            "filters": {
              "all_of": [
                {
                  "any_of": [
                    { "test": "is_family", "subject": "other", "value": "player" },
                    { "test": "is_family", "subject": "other", "value": "numberblock" },
                    { "test": "is_family", "subject": "other", "value": "alphablock" },
                    { "test": "is_family", "subject": "other", "value": "snowgolem" },
                    { "test": "is_family", "subject": "other", "value": "irongolem" },
                    { "test": "is_family", "subject": "other", "value": "wandering_trader" },
                    {
                      "all_of": [
                        { "test": "is_family", "subject": "other", "value": "villager" },
                        { "test": "has_component", "subject": "other", "operator": "!=", "value": "minecraft:is_baby" }
                      ]
                    }
                  ]
                },
                { "test": "is_family", "subject": "other", "operator": "!=", "value": "terribleblock" },
                { "test": "is_family", "subject": "other", "operator": "!=", "value": "zero" },
                { "test": "is_family", "subject": "other", "operator": "!=", "value": "twenty_seven" },
                { "test": "is_family", "subject": "other", "operator": "!=", "value": "fifty_six" },
                {
                  "none_of": [
                    {
                      "all_of": [
                        { "test": "is_family", "subject": "other", "value": "sixty_four" },
                        { "test": "int_property", "subject": "other", "domain": "numberblocks:sixty_four", "value": 1 }
                      ]
                    }
                  ]
                },
                { "test": "is_family", "subject": "other", "operator": "!=", "value": "sixty_four_cube" },
                { "test": "is_family", "subject": "other", "operator": "!=", "value": "seventy_two" },
                { "test": "is_family", "subject": "other", "operator": "!=", "value": "eighty" },
                { "test": "is_family", "subject": "other", "operator": "!=", "value": "times_table" },
                { "test": "is_family", "subject": "other", "operator": "!=", "value": "colourblocks" },
                { "test": "is_family", "subject": "other", "operator": "!=", "value": "wonderblocks" },
                { "test": "has_equipment", "subject": "self", "domain": "hand", "operator": "!=", "value": "numberblocks:fractionator_split_into_half" },
                { "test": "has_equipment", "subject": "self", "domain": "hand", "operator": "!=", "value": "numberblocks:fractionator_split_into_thirds" },
                { "test": "has_equipment", "subject": "self", "domain": "hand", "operator": "!=", "value": "numberblocks:fractionator_split_into_quarters" }
              ]
            },
            "max_dist": 16
          }
        ]
      },
      "minecraft:behavior.melee_box_attack": {
        "priority": 4,
        "track_target": true
      },
      "minecraft:behavior.random_stroll": {
        "priority": 5,
        "speed_multiplier": 1.0
      },
      "minecraft:behavior.look_at_player": {
        "priority": 6,
        "look_distance": 6.0,
        "probability": 0.02
      },
      "minecraft:behavior.random_look_around": {
        "priority": 7
      },
	    "minecraft:physics": {
      },
      "minecraft:pushable": {
        "is_pushable": true,
        "is_pushable_by_piston": true
      },
      "minecraft:conditional_bandwidth_optimization": {
      }
    },
    "events": {
      "numberblocks:nature_spawn_fractionator": {
        "sequence":[
          {
            "trigger": "minecraft:nature_spawn"
          },
          {
            "randomize": [
              {
                "weight": 75
              },
              {
                "weight": 25,
                "trigger": "numberblocks:has_fractionator"
              }
            ]
          }
        ]
      },
      "numberblocks:has_fractionator": {
        "add": {
          "component_groups": [
            "has_fractionator"
          ]
        }
      },
      "minecraft:nature_spawn": {
        "set_property": {
          "minecraft:nature_spawn": true
        },
        "add": {
          "component_groups": [
            "nature_spawn"
          ]
        }
      },
      "numberblocks:splited": {
        "set_property": {
          "numberblocks:splited": true
        }
      },
      "numberblocks:nature_spawn_splited": {
        "sequence": [
          {
            "trigger": "minecraft:nature_spawn"
          },
          {
            "trigger": "numberblocks:splited"
          }
        ]
      },
      "minecraft:entity_spawned": {
        "add": {
          "component_groups": [
            "normal"
          ]
        }
      },
      "numberblocks:change_form": {
        "sequence": [
          {
            "filters": { "test": "int_property", "subject": "self", "domain": "numberblocks:eight", "value": 1 },
            "trigger": "numberblocks:octonaughty"
          },
          {
            "filters": { "test": "int_property", "subject": "self", "domain": "numberblocks:eight", "value": 0 },
            "trigger": "numberblocks:octonaughty_cube"
          }
        ]
      },
      "numberblocks:octonaughty": {
        "set_property": {
          "numberblocks:eight": 0
        },
        "remove": {
          "component_groups": [
            "cube"
          ]
        },
        "add": {
          "component_groups": [
            "normal"
          ]
        }
      },
      "numberblocks:octonaughty_cube": {
        "set_property": {
          "numberblocks:eight": 1
        },
        "remove": {
          "component_groups": [
            "normal"
          ]
        },
        "add": {
          "component_groups": [
            "cube"
          ]
        }
      },
      "become_angry_event": {
        "add": {
          "component_groups": [
            "angry"
          ]
        }
      },
      "become_calm_event": {
        "remove": {
          "component_groups": [
            "angry"
          ]
        }
      },
      "numberblocks:split_into_quarters": {
        "sequence": [
          {
            "filters": { "test": "bool_property", "subject": "self", "domain": "minecraft:nature_spawn" },
            "add": {
              "component_groups": [
                "split_into_quarters_nature_spawn"
              ]
            }
          },
          {
            "filters": { "test": "bool_property", "subject": "self", "domain": "minecraft:nature_spawn", "operator": "!=" },
            "add": {
              "component_groups": [
                "split_into_quarters"
              ]
            }
          }
        ]
      }
    }
  }
}
