{
  "format_version": "1.10.0",
  "minecraft:attachable": {
    "description": {
      "identifier": "mnp_ci:super_rod.player",
      "item": { "mnp_ci:super_rod": "q.owner_identifier == 'minecraft:player'" },
      "materials": {
        "default": "entity_alphatest",
        "line": "mnp_ci_fishing_line", //disables directional shading
        "bobber": "entity_alphatest_one_sided"
      },
      "textures": {
        "default": "textures/mnp/ci/entity/attachable/super_rod",

        "line_001": "textures/mnp/ci/entity/attachable/super_rod_line_001",
        "line_002": "textures/mnp/ci/entity/attachable/super_rod_line_002",
        "line_003": "textures/mnp/ci/entity/attachable/super_rod_line_003",
        "line_004": "textures/mnp/ci/entity/attachable/super_rod_line_004",
        "line_005": "textures/mnp/ci/entity/attachable/super_rod_line_005",
        "line_006": "textures/mnp/ci/entity/attachable/super_rod_line_006",
        "line_007": "textures/mnp/ci/entity/attachable/super_rod_line_007",
        "line_008": "textures/mnp/ci/entity/attachable/super_rod_line_008",
        "line_009": "textures/mnp/ci/entity/attachable/super_rod_line_009",
        "line_010": "textures/mnp/ci/entity/attachable/super_rod_line_010",
        "line_011": "textures/mnp/ci/entity/attachable/super_rod_line_011",
        "line_012": "textures/mnp/ci/entity/attachable/super_rod_line_012",
        "line_013": "textures/mnp/ci/entity/attachable/super_rod_line_013",
        "line_014": "textures/mnp/ci/entity/attachable/super_rod_line_014",
        "line_015": "textures/mnp/ci/entity/attachable/super_rod_line_015",
        "line_016": "textures/mnp/ci/entity/attachable/super_rod_line_016",
        "line_017": "textures/mnp/ci/entity/attachable/super_rod_line_017",
        "line_018": "textures/mnp/ci/entity/attachable/super_rod_line_018",
        "line_019": "textures/mnp/ci/entity/attachable/super_rod_line_019",
        "line_020": "textures/mnp/ci/entity/attachable/super_rod_line_020",
        "line_021": "textures/mnp/ci/entity/attachable/super_rod_line_021",
        "line_022": "textures/mnp/ci/entity/attachable/super_rod_line_022",
        "line_023": "textures/mnp/ci/entity/attachable/super_rod_line_023",
        "line_024": "textures/mnp/ci/entity/attachable/super_rod_line_024",
        "line_025": "textures/mnp/ci/entity/attachable/super_rod_line_025",
        "line_026": "textures/mnp/ci/entity/attachable/super_rod_line_026",
        "line_027": "textures/mnp/ci/entity/attachable/super_rod_line_027",
        "line_028": "textures/mnp/ci/entity/attachable/super_rod_line_028",
        "line_029": "textures/mnp/ci/entity/attachable/super_rod_line_029",
        "line_030": "textures/mnp/ci/entity/attachable/super_rod_line_030",
        "line_031": "textures/mnp/ci/entity/attachable/super_rod_line_031",
        "line_032": "textures/mnp/ci/entity/attachable/super_rod_line_032",
        "line_033": "textures/mnp/ci/entity/attachable/super_rod_line_033",
        "line_034": "textures/mnp/ci/entity/attachable/super_rod_line_034",
        "line_035": "textures/mnp/ci/entity/attachable/super_rod_line_035",
        "line_036": "textures/mnp/ci/entity/attachable/super_rod_line_036",
        "line_037": "textures/mnp/ci/entity/attachable/super_rod_line_037",
        "line_038": "textures/mnp/ci/entity/attachable/super_rod_line_038",
        "line_039": "textures/mnp/ci/entity/attachable/super_rod_line_039",
        "line_040": "textures/mnp/ci/entity/attachable/super_rod_line_040",
        "line_041": "textures/mnp/ci/entity/attachable/super_rod_line_041",
        "line_042": "textures/mnp/ci/entity/attachable/super_rod_line_042",
        "line_043": "textures/mnp/ci/entity/attachable/super_rod_line_043",
        "line_044": "textures/mnp/ci/entity/attachable/super_rod_line_044",
        "line_045": "textures/mnp/ci/entity/attachable/super_rod_line_045",
        "line_046": "textures/mnp/ci/entity/attachable/super_rod_line_046",
        "line_047": "textures/mnp/ci/entity/attachable/super_rod_line_047",
        "line_048": "textures/mnp/ci/entity/attachable/super_rod_line_048",
        "line_049": "textures/mnp/ci/entity/attachable/super_rod_line_049",
        "line_050": "textures/mnp/ci/entity/attachable/super_rod_line_050",
        "line_051": "textures/mnp/ci/entity/attachable/super_rod_line_051",
        "line_052": "textures/mnp/ci/entity/attachable/super_rod_line_052",
        "line_053": "textures/mnp/ci/entity/attachable/super_rod_line_053",
        "line_054": "textures/mnp/ci/entity/attachable/super_rod_line_054",
        "line_055": "textures/mnp/ci/entity/attachable/super_rod_line_055",
        "line_056": "textures/mnp/ci/entity/attachable/super_rod_line_056",
        "line_057": "textures/mnp/ci/entity/attachable/super_rod_line_057",
        "line_058": "textures/mnp/ci/entity/attachable/super_rod_line_058",
        "line_059": "textures/mnp/ci/entity/attachable/super_rod_line_059",
        "line_060": "textures/mnp/ci/entity/attachable/super_rod_line_060",
        "line_061": "textures/mnp/ci/entity/attachable/super_rod_line_061",
        "line_062": "textures/mnp/ci/entity/attachable/super_rod_line_062",
        "line_063": "textures/mnp/ci/entity/attachable/super_rod_line_063",
        "line_064": "textures/mnp/ci/entity/attachable/super_rod_line_064",
        "line_065": "textures/mnp/ci/entity/attachable/super_rod_line_065",
        "line_066": "textures/mnp/ci/entity/attachable/super_rod_line_066",
        "line_067": "textures/mnp/ci/entity/attachable/super_rod_line_067",
        "line_068": "textures/mnp/ci/entity/attachable/super_rod_line_068",
        "line_069": "textures/mnp/ci/entity/attachable/super_rod_line_069",
        "line_070": "textures/mnp/ci/entity/attachable/super_rod_line_070",
        "line_071": "textures/mnp/ci/entity/attachable/super_rod_line_071",
        "line_072": "textures/mnp/ci/entity/attachable/super_rod_line_072",
        "line_073": "textures/mnp/ci/entity/attachable/super_rod_line_073",
        "line_074": "textures/mnp/ci/entity/attachable/super_rod_line_074",
        "line_075": "textures/mnp/ci/entity/attachable/super_rod_line_075",
        "line_076": "textures/mnp/ci/entity/attachable/super_rod_line_076",
        "line_077": "textures/mnp/ci/entity/attachable/super_rod_line_077",
        "line_078": "textures/mnp/ci/entity/attachable/super_rod_line_078",
        "line_079": "textures/mnp/ci/entity/attachable/super_rod_line_079",
        "line_080": "textures/mnp/ci/entity/attachable/super_rod_line_080",
        "line_081": "textures/mnp/ci/entity/attachable/super_rod_line_081",
        "line_082": "textures/mnp/ci/entity/attachable/super_rod_line_082",
        "line_083": "textures/mnp/ci/entity/attachable/super_rod_line_083",
        "line_084": "textures/mnp/ci/entity/attachable/super_rod_line_084",
        "line_085": "textures/mnp/ci/entity/attachable/super_rod_line_085",
        "line_086": "textures/mnp/ci/entity/attachable/super_rod_line_086",
        "line_087": "textures/mnp/ci/entity/attachable/super_rod_line_087",
        "line_088": "textures/mnp/ci/entity/attachable/super_rod_line_088",
        "line_089": "textures/mnp/ci/entity/attachable/super_rod_line_089",
        "line_090": "textures/mnp/ci/entity/attachable/super_rod_line_090",
        "line_091": "textures/mnp/ci/entity/attachable/super_rod_line_091",
        "line_092": "textures/mnp/ci/entity/attachable/super_rod_line_092",
        "line_093": "textures/mnp/ci/entity/attachable/super_rod_line_093",
        "line_094": "textures/mnp/ci/entity/attachable/super_rod_line_094",
        "line_095": "textures/mnp/ci/entity/attachable/super_rod_line_095",
        "line_096": "textures/mnp/ci/entity/attachable/super_rod_line_096",
        "line_097": "textures/mnp/ci/entity/attachable/super_rod_line_097",
        "line_098": "textures/mnp/ci/entity/attachable/super_rod_line_098",
        "line_099": "textures/mnp/ci/entity/attachable/super_rod_line_099",
        "line_100": "textures/mnp/ci/entity/attachable/super_rod_line_100",
        "line_101": "textures/mnp/ci/entity/attachable/super_rod_line_101",
        "line_102": "textures/mnp/ci/entity/attachable/super_rod_line_102",
        "line_103": "textures/mnp/ci/entity/attachable/super_rod_line_103",
        "line_104": "textures/mnp/ci/entity/attachable/super_rod_line_104",
        "line_105": "textures/mnp/ci/entity/attachable/super_rod_line_105",
        "line_106": "textures/mnp/ci/entity/attachable/super_rod_line_106",
        "line_107": "textures/mnp/ci/entity/attachable/super_rod_line_107",
        "line_108": "textures/mnp/ci/entity/attachable/super_rod_line_108",
        "line_109": "textures/mnp/ci/entity/attachable/super_rod_line_109",
        "line_110": "textures/mnp/ci/entity/attachable/super_rod_line_110",
        "line_111": "textures/mnp/ci/entity/attachable/super_rod_line_111",
        "line_112": "textures/mnp/ci/entity/attachable/super_rod_line_112",
        "line_113": "textures/mnp/ci/entity/attachable/super_rod_line_113",
        "line_114": "textures/mnp/ci/entity/attachable/super_rod_line_114",
        "line_115": "textures/mnp/ci/entity/attachable/super_rod_line_115",
        "line_116": "textures/mnp/ci/entity/attachable/super_rod_line_116",
        "line_117": "textures/mnp/ci/entity/attachable/super_rod_line_117",
        "line_118": "textures/mnp/ci/entity/attachable/super_rod_line_118",
        "line_119": "textures/mnp/ci/entity/attachable/super_rod_line_119",
        "line_120": "textures/mnp/ci/entity/attachable/super_rod_line_120",
        "line_121": "textures/mnp/ci/entity/attachable/super_rod_line_121",
        "line_122": "textures/mnp/ci/entity/attachable/super_rod_line_122",
        "line_123": "textures/mnp/ci/entity/attachable/super_rod_line_123",
        "line_124": "textures/mnp/ci/entity/attachable/super_rod_line_124",
        "line_125": "textures/mnp/ci/entity/attachable/super_rod_line_125",
        "line_126": "textures/mnp/ci/entity/attachable/super_rod_line_126",
        "line_127": "textures/mnp/ci/entity/attachable/super_rod_line_127",
        "line_128": "textures/mnp/ci/entity/attachable/super_rod_line_128"
      },
      "geometry": {
        // Empty model with only the bones we need to query the trs off. It needs to always be rendered so as not to throw errors.
        "default": "geometry.super_rod_rig.mnp_ci",

        // The difference between first and third person models are where the long fishing line (and bobber that goes with) are nested, starting with the bone 'line_root0'
        // In first person, need to nest them under the root bone to cancel out camera pitch and yaw. line_root0 is positioned at the tip of the rod thanks to the v.line_trs variable.
        // In third person, 'line_root0' is directly nested under 'rod_line1' since we can directly orient it in world space, and so that there is no disconnect with the start of the line and 'rod_line1', since v.line_trs because the player Y rotation is locked.

        // Base models
        "fp_base": "geometry.fp_super_rod.mnp_ci", // base model for first person
        "tp_base": "geometry.tp_super_rod.mnp_ci", // base model for third person

        // Separate models for the fishing line since they use different textures
        "line": "geometry.super_rod_line.mnp_ci", // short fishing line (when not casted, same model for fp and tp)

        // long fishing line for third person
        "tp_line_01": "geometry.tp_super_rod_line_01.mnp_ci",
        "tp_line_02": "geometry.tp_super_rod_line_02.mnp_ci",
        "tp_line_03": "geometry.tp_super_rod_line_03.mnp_ci",
        "tp_line_04": "geometry.tp_super_rod_line_04.mnp_ci",
        "tp_line_05": "geometry.tp_super_rod_line_05.mnp_ci",
        "tp_line_06": "geometry.tp_super_rod_line_06.mnp_ci",
        "tp_line_07": "geometry.tp_super_rod_line_07.mnp_ci",
        "tp_line_08": "geometry.tp_super_rod_line_08.mnp_ci",
        "tp_line_09": "geometry.tp_super_rod_line_09.mnp_ci",
        "tp_line_10": "geometry.tp_super_rod_line_10.mnp_ci",
        "tp_line_11": "geometry.tp_super_rod_line_11.mnp_ci",
        "tp_line_12": "geometry.tp_super_rod_line_12.mnp_ci",
        "tp_line_13": "geometry.tp_super_rod_line_13.mnp_ci",
        "tp_line_14": "geometry.tp_super_rod_line_14.mnp_ci",
        "tp_line_15": "geometry.tp_super_rod_line_15.mnp_ci",
        "tp_line_16": "geometry.tp_super_rod_line_16.mnp_ci",
        "tp_line_17": "geometry.tp_super_rod_line_17.mnp_ci",
        "tp_line_18": "geometry.tp_super_rod_line_18.mnp_ci",
        "tp_line_19": "geometry.tp_super_rod_line_19.mnp_ci",
        "tp_line_20": "geometry.tp_super_rod_line_20.mnp_ci",
        "tp_line_21": "geometry.tp_super_rod_line_21.mnp_ci",
        "tp_line_22": "geometry.tp_super_rod_line_22.mnp_ci",
        "tp_line_23": "geometry.tp_super_rod_line_23.mnp_ci",
        "tp_line_24": "geometry.tp_super_rod_line_24.mnp_ci",
        "tp_line_25": "geometry.tp_super_rod_line_25.mnp_ci",
        "tp_line_26": "geometry.tp_super_rod_line_26.mnp_ci",
        "tp_line_27": "geometry.tp_super_rod_line_27.mnp_ci",
        "tp_line_28": "geometry.tp_super_rod_line_28.mnp_ci",
        "tp_line_29": "geometry.tp_super_rod_line_29.mnp_ci",
        "tp_line_30": "geometry.tp_super_rod_line_30.mnp_ci",
        "tp_line_31": "geometry.tp_super_rod_line_31.mnp_ci",
        "tp_line_32": "geometry.tp_super_rod_line_32.mnp_ci",

        // long fishing line for first person
        "fp_line_01": "geometry.fp_super_rod_line_01.mnp_ci",
        "fp_line_02": "geometry.fp_super_rod_line_02.mnp_ci",
        "fp_line_03": "geometry.fp_super_rod_line_03.mnp_ci",
        "fp_line_04": "geometry.fp_super_rod_line_04.mnp_ci",
        "fp_line_05": "geometry.fp_super_rod_line_05.mnp_ci",
        "fp_line_06": "geometry.fp_super_rod_line_06.mnp_ci",
        "fp_line_07": "geometry.fp_super_rod_line_07.mnp_ci",
        "fp_line_08": "geometry.fp_super_rod_line_08.mnp_ci",
        "fp_line_09": "geometry.fp_super_rod_line_09.mnp_ci",
        "fp_line_10": "geometry.fp_super_rod_line_10.mnp_ci",
        "fp_line_11": "geometry.fp_super_rod_line_11.mnp_ci",
        "fp_line_12": "geometry.fp_super_rod_line_12.mnp_ci",
        "fp_line_13": "geometry.fp_super_rod_line_13.mnp_ci",
        "fp_line_14": "geometry.fp_super_rod_line_14.mnp_ci",
        "fp_line_15": "geometry.fp_super_rod_line_15.mnp_ci",
        "fp_line_16": "geometry.fp_super_rod_line_16.mnp_ci",
        "fp_line_17": "geometry.fp_super_rod_line_17.mnp_ci",
        "fp_line_18": "geometry.fp_super_rod_line_18.mnp_ci",
        "fp_line_19": "geometry.fp_super_rod_line_19.mnp_ci",
        "fp_line_20": "geometry.fp_super_rod_line_20.mnp_ci",
        "fp_line_21": "geometry.fp_super_rod_line_21.mnp_ci",
        "fp_line_22": "geometry.fp_super_rod_line_22.mnp_ci",
        "fp_line_23": "geometry.fp_super_rod_line_23.mnp_ci",
        "fp_line_24": "geometry.fp_super_rod_line_24.mnp_ci",
        "fp_line_25": "geometry.fp_super_rod_line_25.mnp_ci",
        "fp_line_26": "geometry.fp_super_rod_line_26.mnp_ci",
        "fp_line_27": "geometry.fp_super_rod_line_27.mnp_ci",
        "fp_line_28": "geometry.fp_super_rod_line_28.mnp_ci",
        "fp_line_29": "geometry.fp_super_rod_line_29.mnp_ci",
        "fp_line_30": "geometry.fp_super_rod_line_30.mnp_ci",
        "fp_line_31": "geometry.fp_super_rod_line_31.mnp_ci",
        "fp_line_32": "geometry.fp_super_rod_line_32.mnp_ci"
      },
      "scripts": {
        "initialize": [
          "v.has_rendered = false;", // Once the attachable has rendered, previous bone transformations can be queried with q.bone_orientation_trs()
          "v.is_first_person = c.is_first_person;", // Used in the RC

          // structure variables to initialize others
          "v.vec_struct.x = 0; v.vec_struct.y = 0; v.vec_struct.z = 0;", // Vector
          "v.trs_struct.t.x = 0; v.trs_struct.t.y = 0; v.trs_struct.t.z = 0;v.trs_struct.r.x = 0; v.trs_struct.r.y = 0; v.trs_struct.r.z = 0;v.trs_struct.s.x = 0; v.trs_struct.s.y = 0; v.trs_struct.s.z = 0;", // Transform

          // "lure" variables
          "v.l = v.vec_struct;", // lure location         (gotten by scripting)
          "v.l_v = v.vec_struct;", // lure velocity       (gotten by scripting)

          // "player" variables
          "v.is_holding_fish = 0;", // whether the player is holding a fish (after catching a fish)       (gotten by scripting)

          "v.p_h.x = q.position(0); v.p_h.y = q.position(1) + 1.5; v.p_h.z = q.position(2);", // player head location     (gotten by scripting, only using queries to initialize) (used for 1st person)
          "v.prev_p_h.x = q.position(0); v.prev_p_h.y = q.position(1) + 1.5; v.prev_p_h.z = q.position(2);", // previous player head location   (gotten by scripting, only using queries to initialize) (used for 1st person)
          "v.p_h_v = v.vec_struct;", // player head velocity            (calculated from scripting)

          "v.prev_time_stamp = q.time_stamp;", // time in tick of the last calculation of player variables gotten from queries
          "v.prev_p_3p.x = q.position(0); v.prev_p_3p.y = q.position(1); v.prev_p_3p.z = q.position(2);", // previous player feet location  (gotten from queries) (used for 3rd person)
          "v.p_v_3p.x = 0; v.p_v_3p.y = 0; v.p_v_3p.z = 0;", // player velocity       (calculated from queries)
          "v.p_v_3p_frame_alpha = 0;", // resets to 0 every time the related variables are updated. goes from 0 to 1 in the span of a tick (and continues), meant to interpolate velocity variables and such
          "v.script_frame_alpha = 0;", // resets to 0 every time the related variables are updated. goes from 0 to 1 in the span of a tick (and continues), meant to interpolate velocity variables and such

          "v.casted_rot_y = q.body_y_rotation + q.target_y_rotation;", // player root Y rotation (in world space) to face direction they cast the rod in         (calculated from scripting)
          "v.yaw = 0;", // player head yaw    (calculated from scripting for first person / gotten from queries for third person)
          "v.prev_yaw = 0;", // previous player head yaw
          "v.yaw_delta = 0;", // player head yaw delta

          "v.smooth_yaw_speed = math.clamp(q.yaw_speed * 0.05, -10, 10) * 0.1;", //used for swaying the short fishing line (yaw speed gotten from query for 3rd person, calculated from temp leaking yaw for 1st person)
          "v.smooth_pitch_speed = 0;",

          "v.smooth_p_local_vel_forward = 0; v.smooth_p_local_vel_right = 0; v.smooth_p_vel_up = 0; v.sway_forward = 0;  v.sway_right = 0;",

          //"fishing rod" variables
          "v.script_tick = 0;", // time in tick of the last scripting update (gotten by scripting)
          "v.prev_script_tick = 0;", // previous time in tick of the last scripting update
          "v.lure_stuck = 0;", // whether the lure is stuck         (gotten by scripting)
          "v.is_casted = 0;", // whether the rod has been cast     (gotten by scripting)
          "v.is_reeling = 0;", // whether the player is reeling     (gotten by scripting)
          "v.is_fish_pulling = 0;", // whether the fish is pulling       (gotten by scripting)

          "v.cast = 0;", //set in the attachable AC on_entry of the "cast" state, pre_animation decays it. Used by v.reel_mod and v.reel_mod2

          // variables for the fishing line once cast
          "v.line_trs = v.trs_struct;",
          "v.root_trs = v.trs_struct;",

          "v.line = v.vec_struct;", //relative location of the lure to tip of the rod       (calculated)
          "v.line_pitch = 0;", // rotation to point to the lure from the tip of the rod     (calculated)
          "v.line_magn = 0;", // distance from the tip of the rod to the lure               (calculated)
          "v.line_magn2 = 0;",
          "v.line_amp = 0;", // arbitrary, defines the amplitude of the arc formed by the fishing line segments from the tip of the rod to the lure    (calculated)

          "v.line_nbr_segm = 10;", // number of fishing line segments
          "v.line_segm_z = 0; v.line_segm_z2 = 0; v.line_segm0_y = 0; v.line_segm1_y = 0; v.line_segm2_y = 0; v.line_segm3_y = 0; v.line_segm4_y = 0; v.line_segm5_y = 0; v.line_segm6_y = 0; v.line_segm7_y = 0; v.line_segm8_y = 0; v.line_segm9_y = 0;", //position of line segments, nested under bones pointing at the lure

          // variables related to using the item
          "v.use_duration = q.main_hand_item_use_duration > 0;", //time in seconds since the item is used. initialized to be 0 or 1 to make the "charge" or "cast" animations match

          "v.reel_mod = 0;", // used in the RC to cycle between 4 "frames" of the spinning reel (giving illusion of spinning)
          "v.reel_in_time = 0;", // gotten from player variables, set by player aniamtion (to synchronize hand movement with handle of spinning reel)
          "v.reel_mod2 = 0;",
          "v.line_scroll = 0;", // used in the RC to cycle through all the "line" textures, making it look like UV animation offset, pixel by pixel

          // hard-coded variables of the player entity
          "v.is_paperdoll = 0;",
          "v.player_x_rotation = 0;", // head pitch (head yaw is not available this way)
          "v.player_arm_height = 0;" // v.player_arm_height goes from 0 to 1 when switching item. used to reset v.use_duration so as not to replay "charge" or "cast" animation after selecting the rod again while it was "casted"
        ],
        "parent_setup": "v.vec_struct.x = 0; v.vec_struct.y = 0; v.vec_struct.z = 0; t.p_h = v.__p_h??v.vec_struct; t.p_h_r = v.__p_h_r??v.vec_struct; t.c_p_h_r = v.__c_p_h_r??v.vec_struct; t.l = v.__l??v.vec_struct; t.l_v = v.__l_v??v.vec_struct; t.is_paperdoll = v.is_paperdoll; t.player_x_rotation = v.player_x_rotation; t.player_arm_height = v.player_arm_height; t.script_tick = v.__t??0; t.is_casted = v.__is_c??0; t.is_reeling = v.__is_r??0; t.is_fish_pulling = v.__is_fp??0; t.lure_stuck = v.__l_s??0; t.is_holding_fish = v.__is_fh??0; t.reel_in_time = v.reel_in_time??0;",
        "pre_animation": [
          "v.is_paperdoll = t.is_paperdoll; v.player_x_rotation = t.player_x_rotation; v.player_arm_height = t.player_arm_height; v.script_tick = t.script_tick; v.casted_rot_y = v.is_casted ? math.atan2(-t.c_p_h_r.x, t.c_p_h_r.z) -q.body_y_rotation : q.body_y_rotation + q.target_y_rotation; v.yaw = c.is_first_person ? math.atan2(-t.p_h_r.x, t.p_h_r.z) : q.body_y_rotation + q.target_y_rotation; v.is_casted = t.is_casted; v.is_reeling = t.is_reeling; v.is_fish_pulling = t.is_fish_pulling; v.lure_stuck = t.lure_stuck; v.is_holding_fish = t.is_holding_fish; v.p_h = t.p_h??v.vec_struct; v.l = t.l??v.vec_struct; v.l_v = t.l_v??v.vec_struct; v.reel_in_time = t.reel_in_time;",

          // Position, velocity variables of the player head; Head yaw (for first person) & yaw speed (degrees per tick)
          "v.script_tick > v.prev_script_tick ? {v.prev_script_tick = v.script_tick; v.script_frame_alpha = 0; v.p_h_v.x = v.p_h.x - v.prev_p_h.x; v.p_h_v.y = v.p_h.y - v.prev_p_h.y; v.p_h_v.z = v.p_h.z - v.prev_p_h.z; v.prev_p_h = v.p_h; v.yaw_delta = math.min_angle(v.yaw - v.prev_yaw); v.prev_yaw = v.yaw;};",

          // Position, velocity variables of the player feet
          "!q.is_in_ui && q.time_stamp > v.prev_time_stamp ? {v.p_v_3p.x = q.position(0) - v.prev_p_3p.x; v.prev_p_3p.x = q.position(0); v.p_v_3p.y = q.position(1) - v.prev_p_3p.y; v.prev_p_3p.y = q.position(1); v.p_v_3p.z = q.position(2) - v.prev_p_3p.z; v.prev_p_3p.z = q.position(2); v.p_v_3p_frame_alpha = 0;};",

          // Bone trs to get position of the tip of the rod   &   position and rotation of the root bone of the attachable, to cancel it out
          "v.has_rendered ? {v.line_trs = q.bone_orientation_trs('rod_line1'); v.root_trs = q.bone_orientation_trs('root');};",

          // incrementing "frame_alpha" variables
          "v.script_frame_alpha = v.script_frame_alpha + q.delta_time * 20; v.p_v_3p_frame_alpha = v.p_v_3p_frame_alpha + q.delta_time * 20;",

          // calculating "line" variables (vector between tip of the rod and the lure):
          // for 1st person
          "c.is_first_person && v.is_casted && !q.is_in_ui ? {t.line_t_x = -v.line_trs.t.x * 0.0625; t.line_t_y = -v.line_trs.t.y * 0.0625 + 1.5; t.line_t_z = -v.line_trs.t.z * 0.0625; t.cos_yaw = math.cos(v.yaw); t.sin_yaw = math.sin(v.yaw); t.cos_pitch = math.cos(v.player_x_rotation); t.sin_pitch = math.sin(v.player_x_rotation); v.line.x = -v.l.x + v.prev_p_h.x - (v.p_h_v.x - v.l_v.x) * (1-v.script_frame_alpha) + t.line_t_x * t.cos_yaw + t.sin_yaw * (t.line_t_z * t.cos_pitch + t.line_t_y * t.sin_pitch); v.line.y = v.l.y - v.prev_p_h.y + (v.p_h_v.y - v.l_v.y) * (1-v.script_frame_alpha) + t.line_t_y * t.cos_pitch - t.line_t_z * t.sin_pitch; v.line.z = v.l.z - v.prev_p_h.z + (v.p_h_v.z - v.l_v.z) * (1-v.script_frame_alpha) + (t.line_t_z * t.cos_pitch + t.line_t_y * t.sin_pitch) * t.cos_yaw - t.sin_yaw * t.line_t_x;};",
          // for 3rd person
          "!c.is_first_person && v.is_casted && !q.is_in_ui ? {t.line_t_x = -v.line_trs.t.x * 0.0625; t.line_t_y = -v.line_trs.t.y * 0.0625 + 1.5; t.line_t_z = -v.line_trs.t.z * 0.0625; t.cos_yaw = math.cos(q.body_y_rotation); t.sin_yaw = math.sin(q.body_y_rotation); v.line.x = v.l.x - v.prev_p_3p.x + (v.p_v_3p.x - v.l_v.x) * (1-v.p_v_3p_frame_alpha) + t.line_t_x * t.cos_yaw + t.line_t_z * t.sin_yaw; v.line.y = v.l.y - v.prev_p_3p.y + (v.p_v_3p.y - v.l_v.y) * (1-v.p_v_3p_frame_alpha) + t.line_t_y; v.line.z = -v.l.z + v.prev_p_3p.z - (v.p_v_3p.z - v.l_v.z) * (1-v.p_v_3p_frame_alpha) + t.line_t_z * t.cos_yaw - t.line_t_x * t.sin_yaw;};",

          // calculating length of vector between tip of the rod and the lure (and magnitude delta for v.line_scroll)
          "t.line_magn = math.sqrt(math.pow(v.line.x, 2) + math.pow(v.line.y, 2) + math.pow(v.line.z, 2)); v.line_magn_delta = t.line_magn - v.line_magn; v.line_magn = t.line_magn;",
          "t.line_magn2 = math.sqrt(math.pow(v.line.x, 2) + math.pow(v.line.y, 2)*(v.is_reeling ? 0.1 : 0) + math.pow(v.line.z, 2)); v.line_magn_delta2 = t.line_magn2 - v.line_magn2; v.line_magn2 = t.line_magn2;", // for v.line_scroll, lessening the impact of vertical lure movement to avoid jittering due to it bobbing on water

          // calculating position of each fishing line segment (basically a flattened semi-circle. they are nested in a bone already pointing at the lure from the tip of the rod). variable.line_amp is the maximum amplitude of the arc shape.
          "v.line_pitch = math.asin(v.line.y/v.line_magn); v.line_amp = math.lerp(0, (v.is_reeling ? 0.5 : 3 + (1 - math.clamp(v.line_magn, 0, 32)/32) * 7) * (0.05 + 0.95 * math.cos(v.line_pitch)), math.clamp(v.line_magn*0.33, 0, 1)); t.i = 0; loop(v.line_nbr_segm, {t.pos_y = -math.sin(math.pow(v.line_pitch > 0 ? t.i / v.line_nbr_segm : 1 - t.i / v.line_nbr_segm, math.cos(v.line_pitch)*0.8 + 0.2) * 180) * v.line_amp; t.i==0?{v.line_segm0_y=t.pos_y;};t.i==1?{v.line_segm1_y=t.pos_y;};t.i==2?{v.line_segm2_y=t.pos_y;};t.i==3?{v.line_segm3_y=t.pos_y;};t.i==4?{v.line_segm4_y=t.pos_y;};t.i==5?{v.line_segm5_y=t.pos_y;};t.i==6?{v.line_segm6_y=t.pos_y;};t.i==7?{v.line_segm7_y=t.pos_y;};t.i==8?{v.line_segm8_y=t.pos_y;};t.i==9?{v.line_segm9_y=t.pos_y;};t.i=t.i+1;}); v.line_segm_z = v.line_magn*16/v.line_nbr_segm; v.line_segm_z2 = math.pow(v.line_segm_z, 2);",

          // for the sway animations
          "t.yaw_speed = math.clamp(c.is_first_person ? v.yaw_delta : q.yaw_speed * 0.05, -10, 10) * 0.1; v.smooth_yaw_speed = math.lerp(t.yaw_speed, v.smooth_yaw_speed, math.exp((-5 + 4 * math.abs(t.yaw_speed)) * q.delta_time));",
          "q.time_stamp > v.prev_time_stamp ? {v.prev_pitch = (v.pitch ?? v.player_x_rotation); v.pitch = v.player_x_rotation;};",
          "t.pitch_coeff = -2 + math.sqrt(0.5 + math.clamp(v.smooth_pitch_speed * 0.4, -1, 1) * 0.5); v.smooth_pitch_speed = math.lerp(math.clamp(((v.pitch ?? v.player_x_rotation) - (v.prev_pitch ?? v.player_x_rotation)) * t.pitch_coeff * 0.3, -2, 1), v.smooth_pitch_speed, math.exp(-3 * q.delta_time));",

          // local player velocity, variables swaying the short fishing line
          "t.local_p_vel_forward = math.cos(c.is_first_person ? v.yaw : q.body_y_rotation + q.target_y_rotation) * v.p_v_3p.z - math.sin(c.is_first_person ? v.yaw : q.body_y_rotation + q.target_y_rotation) * v.p_v_3p.x; v.smooth_p_local_vel_forward = math.lerp(t.local_p_vel_forward * 0.2, v.smooth_p_local_vel_forward, math.exp(-3 * q.delta_time));",
          "t.local_p_vel_right = -math.cos(c.is_first_person ? v.yaw : q.body_y_rotation + q.target_y_rotation) * v.p_v_3p.x - math.sin(c.is_first_person ? v.yaw : q.body_y_rotation + q.target_y_rotation) * v.p_v_3p.z; v.smooth_p_local_vel_right = math.lerp(t.local_p_vel_right * 0.2, v.smooth_p_local_vel_right, math.exp(-3 * q.delta_time));",
          "v.sway_forward = math.clamp(math.lerp(v.smooth_pitch_speed / (1 + v.smooth_yaw_speed * 0.5), v.smooth_pitch_speed / (1 + v.smooth_yaw_speed * 0.5) * 0.5 + v.smooth_p_local_vel_forward * 3, math.min(math.abs(v.smooth_p_local_vel_forward) * 40, 1)), -1, 1);",
          "v.smooth_p_vel_up = math.lerp(math.clamp(-v.p_v_3p.y * 1.4, 0, 1), v.smooth_p_vel_up, math.exp(-4 * q.delta_time));", // only accounts for downwards velocity (falling)
          "v.sway_right = math.clamp(math.lerp(v.smooth_yaw_speed / (1 + v.smooth_pitch_speed * 0.5 + math.abs(v.smooth_p_local_vel_forward) * 30), v.smooth_yaw_speed / (1 + v.smooth_pitch_speed * 0.5 + math.abs(v.smooth_p_local_vel_forward) * 30) * 0.5 + v.smooth_p_local_vel_right * 3, math.min(math.abs(v.smooth_p_local_vel_right) * 40, 1)), -1, 1);",
          "t.sway_magn = math.sqrt(math.pow(v.sway_forward,2) + math.pow(v.sway_right,2)); v.sway_dir_angle = math.atan2(v.sway_right/t.sway_magn, v.sway_forward/t.sway_magn) * math.clamp(t.sway_magn*5, 0, 1);", // 0 when not moving or moving forward. 180 moving backwards. -90 moving left, 90 moving right.

          "!q.main_hand_item_use_duration && v.player_arm_height <= 0.4 ? {v.use_duration = 0;};",
          "q.main_hand_item_use_duration ? {v.use_duration = (v.was_not_using_item??0) ? 0 : v.use_duration; v.use_duration = v.use_duration + q.delta_time;};", // When not using item, preserves the last value reached. When starting to use again, reset at 0.
          "v.was_not_using_item = q.main_hand_item_use_duration == 0;",

          "v.l_v_magn = math.sqrt(v.l_v.x*v.l_v.x + v.l_v.y*v.l_v.y + v.l_v.z*v.l_v.z);",

          "v.cast = math.max(v.cast - q.delta_time, 0) * (v.cast > 3.5 || !v.lure_stuck);", // the value of v.cast set in the AC corresponds to how long the spinning reel will spin for after casting, with a minimum time after which it can be interrupted by v.lure_stuck.
          "v.cast <= 3.5 && v.l_v_magn < 0.1 ? {v.cast = 0;};",

          "v.line_scroll = v.line_scroll + v.cast * 0.2 -q.delta_time * ((v.is_reeling && !v.lure_stuck && v.l_v_magn > 0.03) * 10);",

          "v.reel_mod = v.is_reeling && !v.lure_stuck ? math.mod((c.is_first_person ? q.life_time : v.reel_in_time) * 3.5 + 0.25, 1) : 0;", // the 4 handles cycling visibility while reeling should match third person reel animation sin frequency / 360:   1260 / 360 = 3.5
          "t.reel_mod2 = v.cast ? v.reel_mod2 + q.delta_time * (-1 -5 * math.sin(v.cast * 90 / 4)) : math.mod(v.line_magn * 0.25, 1); t.reel_mod2 = t.reel_mod2 + (t.reel_mod2 < 0);      v.reel_mod2 = v.is_reeling && !v.lure_stuck && v.l_v_magn > 0.03 ? v.reel_mod*0.5 : t.reel_mod2;", //separate variable for the line inside the spool (unwinds on cast, whereas the handle does not move)

          "v.is_first_person = c.is_first_person;",
          "v.has_rendered = true;",
          "v.prev_time_stamp = q.time_stamp;"
        ],
        "animate": [
          {
            "wield_first_person": "c.is_first_person"
          },
          {
            "wield_third_person": "!c.is_first_person"
          },
          {
            "fishing_line_first_person": "c.is_first_person && v.is_casted && !q.is_in_ui"
          },
          {
            "fishing_line_third_person": "!c.is_first_person && v.is_casted && !q.is_in_ui"
          },
          "controller"

          // ,{
          //   "debug.cube_to_lure": "!c.is_first_person"
          // },
          // {
          //   "debug.cube_to_lure_first_person": "c.is_first_person"
          // }
        ]
      },
      "animations": {
        "controller": "controller.animation.super_rod.mnp_ci",

        "wield_first_person": "animation.super_rod.mnp_ci.wield_first_person",
        "wield_third_person": "animation.super_rod.mnp_ci.wield_third_person",

        "fishing_line_first_person": "animation.super_rod.mnp_ci.fishing_line_first_person",
        "fishing_line_third_person": "animation.super_rod.mnp_ci.fishing_line_third_person",

        "charge_first_person": "animation.super_rod.mnp_ci.charge_first_person",
        "cast_first_person": "animation.super_rod.mnp_ci.cast_first_person",
        "casted_first_person": "animation.super_rod.mnp_ci.casted_first_person",
        "reel_add_first_person": "animation.super_rod.mnp_ci.reel_add_first_person",
        "reel_stuck_add_first_person": "animation.super_rod.mnp_ci.reel_stuck_add_first_person",

        "sway": "animation.super_rod.mnp_ci.sway",
        "flail": "animation.super_rod.mnp_ci.flail"

        // ,"debug.cube_to_lure_first_person": "animation.super_rod.mnp_ci.debug.cube_to_lure_first_person",
        // "debug.cube_to_lure": "animation.super_rod.mnp_ci.debug.cube_to_lure"
      },
      "render_controllers": ["controller.render.default", "controller.render.super_rod.player.mnp_ci", "controller.render.super_rod_line.player.mnp_ci"]
    }
  }
}
