{
  "format_version": "1.21.0",
  "minecraft:entity": {
    "description": {
      "identifier": "silverlabs:dragon_egg",
      "is_spawnable": false,
      "is_summonable": true,
      "is_experimental": false,
      "properties": {
        "silverlabs:egg_stage": {
          "type": "int",
          "default": 0,
          "range": [0, 2],
          "client_sync": true
        },
        "silverlabs:egg_color": {
          "type": "int",
          "default": 0,
          "range": [0, 5],
          "client_sync": true
        }
      }
    },
    "component_groups": {
      "silverlabs:egg_cold": {
        "minecraft:interact": {
          "interactions": [
            {
              "on_interact": {
                "filters": {
                  "all_of": [
                    { "test": "is_family", "subject": "other", "value": "player" },
                    { "test": "has_equipment", "subject": "other", "domain": "hand", "value": "bone_meal" }
                  ]
                },
                "event": "silverlabs:advance_to_warming",
                "target": "self"
              },
              "use_item": true,
              "interact_text": "Warm Egg (Bonemeal)",
              "play_sounds": "block.bone_block.place"
            },
            {
              "on_interact": {
                "filters": { "all_of": [{ "test": "is_family", "subject": "other", "value": "player" }] },
                "event": "",
                "target": "self"
              },
              "use_item": false,
              "interact_text": "The egg feels cold..."
            }
          ]
        }
      },

      "silverlabs:egg_warming": {
        "minecraft:interact": {
          "interactions": [
            {
              "on_interact": {
                "filters": {
                  "all_of": [
                    { "test": "is_family", "subject": "other", "value": "player" },
                    { "test": "has_equipment", "subject": "other", "domain": "hand", "value": "blaze_powder" }
                  ]
                },
                "event": "silverlabs:advance_to_hatching",
                "target": "self"
              },
              "use_item": true,
              "interact_text": "Ignite Egg (Blaze Powder)",
              "play_sounds": "fire.fire"
            },
            {
              "on_interact": {
                "filters": { "all_of": [{ "test": "is_family", "subject": "other", "value": "player" }] },
                "event": "",
                "target": "self"
              },
              "use_item": false,
              "interact_text": "The egg is warming up..."
            }
          ]
        }
      },

      "silverlabs:egg_hatching": {
        "minecraft:damage_sensor": {
          "triggers": [{ "cause": "all", "deals_damage": false }]
        },
        "minecraft:spawn_entity": {
          "entities": [
            {
              "min_wait_time": 0,
              "max_wait_time": 1,
              "spawn_sound": "mob.enderdragon.growl",
              "spawn_entity": "silverlabs:spark_dragon",
              "spawn_event": "silverlabs:born_color_0",
              "num_to_spawn": 1,
              "single_use": true
            }
          ]
        },
        "minecraft:timer": {
          "time": 3,
          "looping": false,
          "time_down_event": { "event": "silverlabs:despawn_egg", "target": "self" }
        }
      },

      "silverlabs:egg_despawning": {
        "minecraft:instant_despawn": {}
      }
    },

    "components": {
      "minecraft:type_family": { "family": ["dragon_egg"] },
      "minecraft:physics": {},
      "minecraft:collision_box": { "width": 0.5, "height": 0.6 },
      "minecraft:pushable": { "is_pushable": false, "is_pushable_by_piston": false },
      "minecraft:knockback_resistance": { "value": 1.0 },
      "minecraft:persistent": {},
      "minecraft:scale": { "value": 1.0 },
      "minecraft:health": { "value": 4, "max": 4 },
      "minecraft:loot": { "table": "loot_tables/gameplay/egg_pickup.json" },
      "minecraft:behavior.look_at_player": { "priority": 7, "look_distance": 6.0, "probability": 0.02 }
    },

    "events": {
      "minecraft:entity_spawned": {
        "add": { "component_groups": ["silverlabs:egg_cold"] }
      },
      "silverlabs:advance_to_warming": {
        "remove": { "component_groups": ["silverlabs:egg_cold"] },
        "add": { "component_groups": ["silverlabs:egg_warming"] },
        "set_property": { "silverlabs:egg_stage": 1 }
      },
      "silverlabs:advance_to_hatching": {
        "remove": { "component_groups": ["silverlabs:egg_warming"] },
        "add": { "component_groups": ["silverlabs:egg_hatching"] },
        "set_property": { "silverlabs:egg_stage": 2 }
      },
      "silverlabs:despawn_egg": {
        "add": { "component_groups": ["silverlabs:egg_despawning"] }
      }
    }
  }
}
