{
  "format_version": "1.10.0",
  "minecraft:client_entity": {
    "description": {
      "identifier": "silverlabs_nat:firefly",
      "materials": {
        "default": "silverlabs_nat.firefly_glow",
        "glow_emissive": "silverlabs_nat.firefly_glow_e"
      },
      "textures": {
        "default": "textures/sf/nba/entity/firefly",
        "glow": "textures/sf/nba/entity/firefly_glow",
        "glow_e": "textures/sf/nba/entity/firefly_glow_e",
        "overlay_none": "textures/sf/nba/empty",
        "baby": "textures/sf/nba/entity/firefly_baby"
      },
      "geometry": {
        "default": "geometry.silverlabs_nat.firefly",
        "baby": "geometry.silverlabs_nat.firefly_baby",
        "glow_layer": "geometry.silverlabs_nat.firefly_glow_layer"
      },
      "animations": {
        "fly": "animation.silverlabs_nat.firefly.fly",
        "hide": "controller.animation.silverlabs_nat.firefly.hide",
        "light_effect": "animation.silverlabs_nat.firefly.light_effect",
        "rotation": "animation.silverlabs_nat.firefly.rotation",
        "rotation_controller": "controller.animation.silverlabs_nat.firefly.rotation_controller",
        "baby_idle": "animation.silverlabs_nat.firefly_baby.idle",
        "baby_walk": "animation.silverlabs_nat.firefly_baby.walk",
        "baby_idle_event": "animation.silverlabs_nat.firefly_baby.idle_event"
      },
      "scripts": {
        "initialize": [
          "v.glow_ticks = 0;",
          "v.glow_start_time = 0.0;",
          "v.last_tick = 0;"
        ],
        "pre_animation": [
          "v.tick_index = math.floor(query.anim_time * 20);",
          "v.is_new_tick = v.tick_index > v.last_tick;",
          "v.glow_ticks = v.glow_ticks > 0 ? (v.is_new_tick ? math.max(0, v.glow_ticks - (v.tick_index - v.last_tick)) : v.glow_ticks) : (v.is_new_tick && q.property('silverlabs_nat:can_glow') && math.random(0.0, 0.99) <= 0.01 ? 30 : 0);",
          "v.last_tick = v.tick_index;",
          "v.was_glowing = v.glow_ticks > 0;",
          "v.glow_uv_frame = v.glow_ticks > 0 ? math.floor(30.0 - v.glow_ticks) : 0;",
          "v.glow_uv_offset = v.glow_ticks > 0 ? (30.0 - v.glow_ticks) / 30.0 : 0.0;",
          "v.target_body_rotation_x = math.clamp(q.vertical_speed * 10, -45, 45);",
          "v.body_rotation_x = math.lerp(v.body_rotation_x ?? 0.0, v.target_body_rotation_x, v.target_body_rotation_x == 0 ? 0.2 : 0.1);"
        ],
        "animate": [
          { "fly": "!q.is_baby" },
          { "baby_idle": "q.is_baby" },
          { "baby_walk": "q.is_baby && q.modified_move_speed > 0.01" },
          { "hide": "!q.is_baby" },
          { "light_effect": "!q.is_baby" },
          { "rotation_controller": "!q.is_baby" }
        ]
      },
      "particle_effects": {
        "hide": "silverlabs_nat:firefly_tallgrass_hide",
        "perish": "silverlabs_nat:firefly_perish",
        "light_effect": "silverlabs_nat:firefly_light_effect"
      },
      "render_controllers": [
        "controller.render.silverlabs_nat.firefly",
        "controller.render.silverlabs_nat.firefly_glow_layer"
      ],
      "spawn_egg": {
        "texture": "silverlabs_nat.firefly_spawn_egg"
      },
      "sound_effects": {
        "fly": "silverlabs_nat.beetle.fly"
      }
    }
  }
}
