function easeOutBack(t, back, speed)
    back = back or 1.70158
    speed = speed or 1.0
    t = math.min(math.max(t * speed, 0), 1)
    t = t - 1
    return (t * t * ((back + 1) * t + back) + 1)
end

function easeCustom(t)
    local t2 = t * t
    local t3 = t2 * t
    return 3 * t * (1 - t) * (1 - t) * 0.44 +
        3 * t2 * (1 - t) * 1 +
        t3
end

function easeCustomSec(t)
    local t2 = t * t
    local t3 = t2 * t
    return 3 * t * (1 - t) * (1 - t) * 0.44 +
        3 * t2 * (1 - t) * 0.94 +
        t3
end

global.pitchAngle = 0.0;
global.yawAngle = 0.0;
global.pitchAngleO = 0.0;
global.yawAngleO = 0.0;

global.GHP_disableShearing = 0.0;
global.GHP_disableShearingMPA = 0.0;

GHP_disableShearing = GHP_disableShearing + 1       -- disable shearing
GHP_disableShearingMPA = GHP_disableShearingMPA + 1 -- disable shears modelpart animation

local ptAngle = context.ptAngle or 0
local ywAngle = context.ywAngle or 0

local ywAngle = (context.mainHand and yawAngle) or yawAngleO
local ptAngle = (context.mainHand and pitchAngle) or pitchAngleO

local bl = context.bl
local item = context.item
local matrices = context.matrices
local player = context.player
local mainHand = context.mainHand
local deltaTime = context.deltaTime
local mainHandSwingProgress = context.mainHandSwingProgress
local swingMHand = context.swingMHand
local swingOHand = context.swingOHand
local particles = context.particles
local swingProgress = context.swingProgress
local equipProgress = context.equipProgress
local mainHandSwitchEvent = context.mainHandSwitchEvent
local offHandSwitchEvent = context.offHandSwitchEvent

local ptAngle = context.ptAngle or 0
local ywAngle = context.ywAngle or 0

local ywAngle = (context.mainHand and yawAngle) or yawAngleO
local ptAngle = (context.mainHand and pitchAngle) or pitchAngleO
local hand = context.hand
local age = P:getAge(context.player)
local crackleTick = M:floor(age / 3)
local l = (bl and 1) or -1

local function noBlocksPlease(blocks)
    for _, id in ipairs(blocks) do
        renderAsBlock:put(id, false)
    end
end

noBlocksPlease({
    "minecraft:firefly_bush",
    "minecraft:wither_rose",
    "minecraft:open_eyeblossom",
    "minecraft:closed_eyeblossom",
    "minecraft:cactus_flower",
    "minecraft:torchflower",
    "minecraft:lily_of_the_valley",
    "minecraft:cornflower",
    "minecraft:oxeye_daisy",
    "minecraft:white_tulip",
    "minecraft:pink_tulip",
    "minecraft:red_tulip",
    "minecraft:orange_tulip",
    "minecraft:azure_bluet",
    "minecraft:allium",
    "minecraft:blue_orchid",
    "minecraft:poppy",
    "minecraft:dandelion",
    "minecraft:dead_bush",
    "minecraft:bush",
    "minecraft:short_dry_grass",
    "minecraft:tall_dry_grass",
    "minecraft:crimson_fungus",
    "minecraft:warped_fungus",
    "minecraft:short_grass",
    "minecraft:tall_grass",
    "minecraft:sugar_cane",
    "minecraft:fern",
    "minecraft:large_fern",
    "minecraft:pale_hanging_moss",
    "minecraft:hanging_roots",
    "minecraft:cherry_sapling",
    "minecraft:oak_sapling",
    "minecraft:spruce_sapling",
    "minecraft:birch_sapling",
    "minecraft:acacia_sapling",
    "minecraft:dark_oak_sapling",
    "minecraft:pale_oak_sapling",
    "minecraft:jungle_sapling",
    "minecraft:mangrove_propagule",
    "minecraft:pitcher_plant",
    "minecraft:peony",
    "minecraft:rose_bush",
    "minecraft:lilac",
    "minecraft:brown_mushroom",
    "minecraft:red_mushroom",
    "minecraft:crimson_roots",
    "minecraft:warped_roots",
    "minecraft:nether_sprouts",
    "minecraft:sunflower",
    "minecraft:bell",
    "minecraft:pointed_dripstone",
    "minecraft:amethyst_cluster",
    "minecraft:large_amethyst_bud",
    "minecraft:medium_amethyst_bud",
    "minecraft:small_amethyst_bud",
    "minecraft:cocoa_beans",
    "minecraft:pumpkin_seeds",
    "minecraft:melon_seeds",
    "minecraft:beetroot_seeds",
    "minecraft:turtle_egg",
    "minecraft:nether_wart",
    "minecraft:tube_coral",
    "minecraft:bubble_coral_fan",
    "minecraft:fire_coral_fan",
    "minecraft:tube_coral_fan",
    "minecraft:horn_coral_fan",
    "minecraft:brain_coral_fan",
    "minecraft:fire_coral",
    "minecraft:horn_coral",
    "minecraft:brain_coral",
    "minecraft:bubble_coral",
    "minecraft:dead_tube_coral",
    "minecraft:dead_fire_coral",
    "minecraft:dead_horn_coral",
    "minecraft:dead_brain_coral",
    "minecraft:dead_bubble_coral",
    "minecraft:dead_bubble_coral_fan",
    "minecraft:dead_fire_coral_fan",
    "minecraft:dead_tube_coral_fan",
    "minecraft:dead_horn_coral_fan",
    "minecraft:dead_brain_coral_fan",
    "minecraft:lever",
    "minecraft:redstone_torch",
    "minecraft:big_dripleaf",
    "minecraft:white_bed",
    "minecraft:black_bed",
    "minecraft:pink_bed",
    "minecraft:light_blue_bed",
    "minecraft:purple_bed",
    "minecraft:magenta_bed",
    "minecraft:turtle_helmet",
    "minecraft:blue_bed",
    "minecraft:green_bed",
    "minecraft:orange_bed",
    "minecraft:cyan_bed",
    "minecraft:lime_bed",
    "minecraft:brown_bed",
    "minecraft:gray_bed",
    "minecraft:light_gray_bed",
    "minecraft:red_bed",
    "minecraft:yellow_bed",
    "minecraft:cobweb",
    "minecraft:flower_pot",
    "minecraft:oak_door",
    "minecraft:spruce_door",
    "minecraft:birch_door",
    "minecraft:jungle_door",
    "minecraft:acacia_door",
    "minecraft:crimson_door",
    "minecraft:mangrove_door",
    "minecraft:cherry_door",
    "minecraft:pale_oak_door",
    "minecraft:warped_door",
    "minecraft:bamboo_door",
    "minecraft:dark_oak_door",
    "minecraft:iron_door",
    "minecraft:copper_door",
    "minecraft:exposed_copper_door",
    "minecraft:weathered_copper_door",
    "minecraft:oxidized_copper_door",
    "minecraft:waxed_copper_door",
    "minecraft:waxed_exposed_copper_door",
    "minecraft:waxed_weathered_copper_door",
    "minecraft:waxed_oxidized_copper_door",
    "minecraft:copper_bars",
    "minecraft:exposed_copper_bars",
    "minecraft:weathered_copper_bars",
    "minecraft:oxidized_copper_bars",
    "minecraft:waxed_copper_bars",
    "minecraft:waxed_exposed_copper_bars",
    "minecraft:waxed_weathered_copper_bars",
    "minecraft:waxed_oxidized_copper_bars",
    "minecraft:iron_chain",
    "minecraft:copper_chain",
    "minecraft:exposed_copper_chain",
    "minecraft:weathered_copper_chain",
    "minecraft:oxidized_copper_chain",
    "minecraft:waxed_copper_chain",
    "minecraft:waxed_oxidized_copper_chain",
    "minecraft:waxed_exposed_copper_chain",
    "minecraft:waxed_weathered_copper_chain",
    "minecraft:torch",
    "minecraft:soul_torch",
    "minecraft:copper_torch",
    "minecraft:lantern",
    "minecraft:soul_lantern",
    "minecraft:weathered_copper_lantern",
    "minecraft:copper_lantern",
    "minecraft:exposed_copper_lantern",
    "minecraft:oxidized_copper_lantern",
    "minecraft:waxed_weathered_copper_lantern",
    "minecraft:waxed_copper_lantern",
    "minecraft:waxed_exposed_copper_lantern",
    "minecraft:waxed_oxidized_copper_lantern",
    "minecraft:pitcher_pod",
    "minecraft:lightning_rod",
    "minecraft:exposed_lightning_rod",
    "minecraft:weathered_lightning_rod",
    "minecraft:oxidized_lightning_rod",
    "minecraft:waxed_lightning_rod",
    "minecraft:waxed_exposed_lightning_rod",
    "minecraft:waxed_weathered_lightning_rod",
    "minecraft:waxed_oxidized_lightning_rod",
    "minecraft:bowl",
    "minecraft:lily_pad",

})

if mainHand and I:isIn(context.item, Tags:getVanillaTag("doors")) then
    M:moveX(matrices, -0.2)
    M:moveZ(matrices, 0.4)
    M:moveY(matrices, 0.3)
    M:rotateZ(matrices, 0)
    M:rotateY(matrices, -100)
end

if not mainHand and I:isIn(context.item, Tags:getVanillaTag("doors")) then
    M:moveX(matrices, 0.2)
    M:moveZ(matrices, 0.4)
    M:moveY(matrices, 0.4)
    M:rotateZ(matrices, 0)
    M:rotateY(matrices, -80)
end

if mainHand and (I:isOf(item, Items:get("minecraft:white_dye")) or I:isOf(item, Items:get("minecraft:orange_dye")) or I:isOf(item, Items:get("minecraft:magenta_dye")) or I:isOf(item, Items:get("minecraft:light_blue_dye")) or I:isOf(item, Items:get("minecraft:yellow_dye")) or I:isOf(item, Items:get("minecraft:lime_dye")) or I:isOf(item, Items:get("minecraft:pink_dye")) or I:isOf(item, Items:get("minecraft:gray_dye")) or I:isOf(item, Items:get("minecraft:light_gray_dye")) or I:isOf(item, Items:get("minecraft:cyan_dye")) or I:isOf(item, Items:get("minecraft:purple_dye")) or I:isOf(item, Items:get("minecraft:blue_dye")) or I:isOf(item, Items:get("minecraft:brown_dye")) or I:isOf(item, Items:get("minecraft:green_dye")) or I:isOf(item, Items:get("minecraft:red_dye")) or I:isOf(item, Items:get("minecraft:black_dye"))) then
    M:moveZ(matrices, -0.1)
    M:moveX(matrices, -0.05)
    M:moveY(matrices, -0.2)
    M:rotateX(matrices, -100)
    M:rotateY(matrices, -1)
    M:scale(matrices, 1.4, 1.4, 1.4)
    M:rotateX(matrices, M:clamp(P:getPitch(player) / 1, -10, 90) + ptAngle + ywAngle * 1, 0, -0.05, 0)
end

if not mainHand and (I:isOf(item, Items:get("minecraft:white_dye")) or I:isOf(item, Items:get("minecraft:orange_dye")) or I:isOf(item, Items:get("minecraft:magenta_dye")) or I:isOf(item, Items:get("minecraft:light_blue_dye")) or I:isOf(item, Items:get("minecraft:yellow_dye")) or I:isOf(item, Items:get("minecraft:lime_dye")) or I:isOf(item, Items:get("minecraft:pink_dye")) or I:isOf(item, Items:get("minecraft:gray_dye")) or I:isOf(item, Items:get("minecraft:light_gray_dye")) or I:isOf(item, Items:get("minecraft:cyan_dye")) or I:isOf(item, Items:get("minecraft:purple_dye")) or I:isOf(item, Items:get("minecraft:blue_dye")) or I:isOf(item, Items:get("minecraft:brown_dye")) or I:isOf(item, Items:get("minecraft:green_dye")) or I:isOf(item, Items:get("minecraft:red_dye")) or I:isOf(item, Items:get("minecraft:black_dye"))) then
    M:moveZ(matrices, -0.1)
    M:moveX(matrices, 0.05)
    M:moveY(matrices, -0.2)
    M:moveX(matrices, -0.05)
    M:rotateX(matrices, -100)
    M:rotateY(matrices, 2)
    M:rotateZ(matrices, -10)
    M:scale(matrices, 1.5, 1.5, 1.5)
    M:rotateX(matrices, M:clamp(P:getPitch(player) / 1, -10, 90) + ptAngle + ywAngle * 1, 0, -0.05, 0)
end

if mainHand and (I:isOf(item, Items:get("minecraft:cocoa_beans")) or (I:isOf(item, Items:get("minecraft:pumpkin_seeds")) or I:isOf(item, Items:get("minecraft:melon_seeds")) or I:isOf(item, Items:get("minecraft:beetroot_seeds")))) then
    M:moveZ(matrices, -0.05)
    M:moveX(matrices, -0.05)
    M:moveY(matrices, -0.15)
    M:rotateX(matrices, -100)
    M:rotateY(matrices, -5)
    M:rotateZ(matrices, -10)
    M:scale(matrices, 1.4, 1.4, 1.4)
    M:rotateX(matrices, M:clamp(P:getPitch(player) / 1, 0, 90) + ptAngle + ywAngle * 1, 0, -0.05, 0)
end

if not mainHand and (I:isOf(item, Items:get("minecraft:cocoa_beans")) or (I:isOf(item, Items:get("minecraft:pumpkin_seeds")) or I:isOf(item, Items:get("minecraft:melon_seeds")) or I:isOf(item, Items:get("minecraft:beetroot_seeds")))) then
    M:moveZ(matrices, -0.05)
    M:moveY(matrices, -0.15)
    M:moveX(matrices, 0.03)
    M:rotateX(matrices, -100)
    M:rotateY(matrices, 8)
    M:rotateZ(matrices, 0)
    M:scale(matrices, 1.5, 1.5, 1.5)
    M:rotateX(matrices, M:clamp(P:getPitch(player) / 1, 0, 90) + ptAngle + ywAngle * 1, 0, -0.05, 0)
end

if mainHand and (I:isOf(item, Items:get("minecraft:wheat_seeds")) or I:isOf(item, Items:get("minecraft:torchflower_seeds"))) then
    M:moveZ(matrices, -0.02)
    M:moveY(matrices, -0.02)
    M:moveX(matrices, -0.05)
    M:rotateX(matrices, -100)
    M:rotateY(matrices, 5)
    M:rotateZ(matrices, -37)
    M:scale(matrices, 1.25, 1.25, 1.25)
    M:rotateX(matrices, M:clamp(P:getPitch(player) / 1, 10, 90) + ptAngle + ywAngle * 1, 0, -0.05, 0)
end

if not mainHand and (I:isOf(item, Items:get("minecraft:wheat_seeds")) or I:isOf(item, Items:get("minecraft:torchflower_seeds"))) then
    M:moveZ(matrices, 0)
    M:moveY(matrices, -0.02)
    M:moveX(matrices, 0.05)
    M:rotateX(matrices, -100)
    M:rotateY(matrices, -3)
    M:rotateZ(matrices, 25)
    M:scale(matrices, 1.25, 1.25, 1.25)
    M:rotateX(matrices, M:clamp(P:getPitch(player) / 1, 7, 90) + ptAngle + ywAngle * 1, 0, -0.05, 0)
end

if mainHand and I:isOf(item, Items:get("minecraft:ender_pearl")) or I:isOf(item, Items:get("minecraft:ender_eye")) then
    M:rotateX(matrices, -12)
    M:scale(matrices, 1.2, 1.2, 1.2)
end

if not mainHand and I:isOf(item, Items:get("minecraft:ender_eye")) then
    M:rotateX(matrices, 0)
end

if not mainHand and I:isOf(item, Items:get("minecraft:ender_pearl")) then
    M:rotateX(matrices, -10)
    M:scale(matrices, 1.2, 1.2, 1.2)
end

if mainHand and I:isOf(item, Items:get("minecraft:bowl")) then
    M:moveY(matrices, 0.04)
    M:moveX(matrices, -0.05 * l)
    M:moveZ(matrices, 0.2)
    M:rotateX(matrices, -97.5)
    M:scale(matrices, 1.25, 1.25, 1.25)
end

if not mainHand and I:isOf(item, Items:get("minecraft:bowl")) then
    M:moveY(matrices, 0.04)
    M:moveX(matrices, -0.05 * l)
    M:moveZ(matrices, 0.2)
    M:rotateX(matrices, -97.5)
    M:scale(matrices, 1.25, 1.25, 1.25)
end

if mainHand and I:isOf(item, Items:get("minecraft:wheat")) then
    M:moveX(matrices, -0.05)
end

if not mainHand and I:isOf(item, Items:get("minecraft:wheat")) then
    M:moveX(matrices, 0.05)
end

if mainHand and I:isOf(item, Items:get("minecraft:trident")) then
    M:moveY(matrices, -0.05)
    M:moveZ(matrices, 0.1)
    M:moveX(matrices, -0.2)
    M:rotateX(matrices, -10)
    M:rotateZ(matrices, 5)
    M:rotateY(matrices, 40)
end

if not mainHand and I:isOf(item, Items:get("minecraft:trident")) then
    M:moveY(matrices, -0.05)
    M:moveZ(matrices, 0.17)
    M:moveX(matrices, 0.2)
    M:rotateX(matrices, -10)
    M:rotateZ(matrices, -5)
    M:rotateY(matrices, -40)
end


if I:isOf(item, Items:get("minecraft:fishing_rod")) then
    M:rotateX(matrices, -60)
    M:moveY(matrices, -0.2)
end

if I:isOf(item, Items:get("minecraft:warped_fungus_on_a_stick")) or I:isOf(item, Items:get("minecraft:carrot_on_a_stick")) then
    M:rotateX(matrices, -50)
    M:moveY(matrices, -0.2)
    M:moveX(matrices, 0.05)
    M:rotateZ(matrices, 5)
    M:rotateY(matrices, 10)
end

if mainHand and I:isIn(item, Tags:getVanillaTag("beds")) then
    M:moveY(matrices, 0.0)
    M:moveX(matrices, -0.3)
    M:moveZ(matrices, 0.45)
    M:rotateX(matrices, 10)
    M:rotateY(matrices, -185)
    M:rotateZ(matrices, 7)
    M:scale(matrices, 1.9, 1.9, 1.9)
end

if not mainHand and I:isIn(item, Tags:getVanillaTag("beds")) then
    M:moveY(matrices, 0.1)
    M:moveX(matrices, 0.2)
    M:moveZ(matrices, 0.2)
    M:rotateX(matrices, 10)
    M:rotateY(matrices, -190)
    M:rotateZ(matrices, 0)
    M:scale(matrices, 1.8, 1.8, 1.8)
end

if mainHand and (
        I:isOf(item, Items:get("minecraft:sentry_armor_trim_smithing_template")) or
        I:isOf(item, Items:get("minecraft:dune_armor_trim_smithing_template")) or
        I:isOf(item, Items:get("minecraft:coast_armor_trim_smithing_template")) or
        I:isOf(item, Items:get("minecraft:wild_armor_trim_smithing_template")) or
        I:isOf(item, Items:get("minecraft:ward_armor_trim_smithing_template")) or
        I:isOf(item, Items:get("minecraft:eye_armor_trim_smithing_template")) or
        I:isOf(item, Items:get("minecraft:vex_armor_trim_smithing_template")) or
        I:isOf(item, Items:get("minecraft:tide_armor_trim_smithing_template")) or
        I:isOf(item, Items:get("minecraft:snout_armor_trim_smithing_template")) or
        I:isOf(item, Items:get("minecraft:rib_armor_trim_smithing_template")) or
        I:isOf(item, Items:get("minecraft:spire_armor_trim_smithing_template")) or
        I:isOf(item, Items:get("minecraft:wayfinder_armor_trim_smithing_template")) or
        I:isOf(item, Items:get("minecraft:shaper_armor_trim_smithing_template")) or
        I:isOf(item, Items:get("minecraft:silence_armor_trim_smithing_template")) or
        I:isOf(item, Items:get("minecraft:raiser_armor_trim_smithing_template")) or
        I:isOf(item, Items:get("minecraft:host_armor_trim_smithing_template")) or
        I:isOf(item, Items:get("minecraft:flow_armor_trim_smithing_template")) or
        I:isOf(item, Items:get("minecraft:netherite_upgrade_smithing_template")) or
        I:isOf(item, Items:get("minecraft:bolt_armor_trim_smithing_template"))
    ) then
    M:moveY(matrices, 0.1)
    M:moveZ(matrices, 0.05)
    M:moveX(matrices, -0.05)
end

if mainHand and I:isIn(item, Tags:getVanillaTag("lanterns")) then
    M:moveY(matrices, 0.45)
    M:moveX(matrices, -0.02)
    M:moveZ(matrices, -0.02)
    M:rotateX(matrices, -67)
    M:rotateZ(matrices, -10)
    M:rotateY(matrices, -10)
end

if not mainHand and I:isIn(item, Tags:getVanillaTag("lanterns")) then
    M:moveY(matrices, 0.45)
    M:moveX(matrices, 0.02)
    M:moveZ(matrices, -0.02)
    M:rotateX(matrices, -67)
    M:rotateZ(matrices, -5)
    M:rotateY(matrices, -2)
end

if I:isOf(item, Items:get("minecraft:leaf_litter")) or I:isOf(item, Items:get("minecraft:pink_petals")) or I:isOf(item, Items:get("minecraft:wildflowers")) then
    M:rotateX(matrices, -5)
end

if I:isOf(item, Items:get("minecraft:flower_banner_pattern"))
    or I:isOf(item, Items:get("minecraft:creeper_banner_pattern"))
    or I:isOf(item, Items:get("minecraft:skull_banner_pattern"))
    or I:isOf(item, Items:get("minecraft:mojang_banner_pattern"))
    or I:isOf(item, Items:get("minecraft:globe_banner_pattern"))
    or I:isOf(item, Items:get("minecraft:snout_banner_pattern"))
    or I:isOf(item, Items:get("minecraft:flow_banner_pattern"))
    or I:isOf(item, Items:get("minecraft:guster_banner_pattern"))
    or I:isOf(item, Items:get("minecraft:field_masoned_banner_pattern"))
    or I:isOf(item, Items:get("minecraft:bordure_indented_banner_pattern"))
    or I:isOf(item, Items:get("minecraft:piglin_banner_pattern")) then
    M:moveY(matrices, -0.2)
    M:moveZ(matrices, 0.1)
    M:rotateX(matrices, -75)
end

if I:isOf(item, Items:get("minecraft:name_tag")) then
    M:moveY(matrices, -0.21)
    M:rotateX(matrices, -80)
end

if I:isOf(item, Items:get("minecraft:painting")) and mainHand then
    M:moveY(matrices, 0.4)
    M:moveZ(matrices, 0)
    M:moveX(matrices, 0.17)
    M:rotateX(matrices, -67)
    M:rotateZ(matrices, -3)
end

if I:isOf(item, Items:get("minecraft:painting")) and not mainHand then
    M:moveY(matrices, 0.43)
    M:moveZ(matrices, 0)
    M:moveX(matrices, -0.17)
    M:rotateX(matrices, -67)
    M:rotateZ(matrices, -3)
    M:rotateY(matrices, -3)
end

if I:isIn(item, Tags:getVanillaTag("chains")) then
    M:moveY(matrices, -0.2)
    M:moveZ(matrices, 0)
    M:rotateX(matrices, -90)
    M:rotateX(matrices, M:clamp(P:getPitch(player) / 1, -30, 90) + ptAngle + ywAngle * 1, 0, -0.05, 0)
end

if I:isOf(item, Items:get("minecraft:bell")) and mainHand then
    M:moveY(matrices, 0.3)
    M:moveZ(matrices, -0.05)
    M:moveX(matrices, -0.05)
    M:rotateX(matrices, -90)
    M:rotateX(matrices, M:clamp(P:getPitch(player) / 1, -35, 60) + ptAngle + ywAngle * 1, 0, -0.05, 0)
end

if I:isOf(item, Items:get("minecraft:bell")) and not mainHand then
    M:moveY(matrices, 0.3)
    M:moveZ(matrices, -0.05)
    M:moveX(matrices, 0)
    M:rotateX(matrices, -75)
    M:rotateZ(matrices, -3)
    M:rotateX(matrices, M:clamp(P:getPitch(player) / 1, -45, 90) + ptAngle + ywAngle * 1, 0, -0.05, 0)
end

if I:isOf(item, Items:get("minecraft:item_frame")) and mainHand then
    M:moveY(matrices, 0.4)
    M:moveZ(matrices, 0)
    M:moveX(matrices, 0.1)
    M:rotateX(matrices, -68)
    M:rotateZ(matrices, -3)
end

if I:isOf(item, Items:get("minecraft:item_frame")) and not mainHand then
    M:moveY(matrices, 0.4)
    M:moveZ(matrices, 0)
    M:moveX(matrices, -0.2)
    M:rotateX(matrices, -68)
    M:rotateZ(matrices, -3)
end

if I:isOf(item, Items:get("minecraft:glow_item_frame")) and not mainHand then
    M:moveY(matrices, -0.25)
    M:moveZ(matrices, 0)
    M:moveX(matrices, -0.1)
    M:rotateX(matrices, -95)
    M:rotateZ(matrices, -5)
    M:rotateX(matrices, M:clamp(P:getPitch(player) / 2.5, -15, 80) + ptAngle + ywAngle * 0.5, 0, -0.13, 0)
end

if I:isOf(item, Items:get("minecraft:glow_item_frame")) and mainHand then
    M:moveY(matrices, -0.25)
    M:moveZ(matrices, 0)
    M:moveX(matrices, 0.05)
    M:rotateX(matrices, -95)
    M:rotateZ(matrices, 5)
    M:rotateX(matrices, M:clamp(P:getPitch(player) / 2.5, -15, 80) + ptAngle + ywAngle * 0.5, 0, -0.13, 0)
end

if mainHand and I:isOf(item, Items:get("minecraft:lily_pad")) then
    M:moveY(matrices, 0.035)
    M:rotateZ(matrices, 6)
end

if not mainHand and I:isOf(item, Items:get("minecraft:lily_pad")) then
    M:moveY(matrices, 0.035)
    M:rotateZ(matrices, -6)
end

if I:isOf(item, Items:get("minecraft:vine"))
    or I:isOf(item, Items:get("minecraft:twisting_vines"))
    or I:isOf(item, Items:get("minecraft:weeping_vines"))
    or I:isOf(item, Items:get("minecraft:pale_hanging_moss"))
    or I:isOf(item, Items:get("minecraft:hanging_roots"))
    or I:isOf(item, Items:get("minecraft:cave_vines")) then
    M:moveY(matrices, -0.2)
    M:moveZ(matrices, -0.03)
    M:moveX(matrices, 0.07)
    M:rotateX(matrices, -75)
    M:rotateX(matrices, M:clamp(P:getPitch(player) / 1, -45, 90) + ptAngle + ywAngle * 1, 0, -0.05, 0)
end

if mainHand and I:isOf(item, Items:get("minecraft:glow_lichen")) then
    M:rotateX(matrices, -75)
    M:moveZ(matrices, -0.03)
    M:rotateZ(matrices, -30)
    M:rotateX(matrices, M:clamp(P:getPitch(player) / 1, -45, 90) + ptAngle + ywAngle * 1, 0, -0.05, 0)
end

if not mainHand and I:isOf(item, Items:get("minecraft:glow_lichen")) then
    M:rotateX(matrices, -75)
    M:moveZ(matrices, -0.03)
    M:rotateZ(matrices, 30)
    M:rotateX(matrices, M:clamp(P:getPitch(player) / 1, -45, 90) + ptAngle + ywAngle * 1, 0, -0.05, 0)
end

if I:isOf(item, Items:get("minecraft:flint_and_steel")) and mainHand then
    M:rotateX(matrices, -15)
    M:rotateY(matrices, -5)
else
    if I:isOf(item, Items:get("minecraft:flint_and_steel")) then
        M:rotateX(matrices, -15)
        M:rotateY(matrices, 5)
    end
end

if I:isOf(item, Items:get("minecraft:shears")) and mainHand then
    M:rotateZ(matrices, -45)
    M:rotateX(matrices, -65)
    M:moveZ(matrices, -0.1)
end

if I:isOf(item, Items:get("minecraft:shears")) and not mainHand then
    M:rotateZ(matrices, -45)
    M:rotateX(matrices, 65)
    M:moveZ(matrices, 0.1)
    M:moveY(matrices, 0.1)
end

if I:isOf(item, Items:get("minecraft:shears")) and animator ~= nil then
    local strength = customMainSwing or customOffSwing or swingProgress or 0
    local eased = math.sin(strength * math.pi)
    local angle = 5 * eased

    local rx, ry, rz = 0, 0, 0
    local lx, ly, lz = 0.6, 0, 0

    animator:rotateZ(0, 14, angle, rx, ry, rz)
    animator:rotateZ(14, 28, -angle, lx, ly, lz)

    if s == nil then
        s = false
    end

    if strength > 0.4 and not s then
        S:playSound("item.shears.snip", 0.5)
        s = true
    end

    if strength < 0.4 then
        s = false
    end
end

-- glowing

if I:isOf(item, Items:get("minecraft:blaze_powder")) then
    particleManager:addParticle(
        particles, false,
        0.1 * l, -0.1, 0,
        0, 0, 0,
        0, 0, 0, 0, 0, 0,
        3.5,
        Texture:of("minecraft", "textures/particle/o_glow.png"),
        "ITEM", hand, "SPAWN", "ADDITIVE", 0,
        225 + (20 * M:sin(P:getAge(player) * 0.2))
    )
end

if I:isOf(item, Items:get("minecraft:fire_charge")) then
    particleManager:addParticle(
        particles, false,
        0.1 * l, 0, -0.1,
        0, 0, 0,
        0, 0, 0, 0, 0, 0,
        3,
        Texture:of("minecraft", "textures/particle/o_glow.png"),
        "ITEM", hand, "SPAWN", "ADDITIVE", 0,
        225 + (20 * M:sin(P:getAge(player) * 0.2))
    )
end

if I:isOf(item, Items:get("minecraft:glowstone_dust")) then
    particleManager:addParticle(
        particles, false,
        0.1 * l, -0.1, 0,
        0, 0, 0,
        0, 0, 0, 0, 0, 0,
        3.5,
        Texture:of("minecraft", "textures/particle/o_glow.png"),
        "ITEM", hand, "SPAWN", "ADDITIVE", 0,
        225 + (20 * M:sin(P:getAge(player) * 0.2))
    )
end


if I:isOf(item, Items:get("minecraft:enchanted_book")) then
    particleManager:addParticle(
        particles, false,
        0 * l, 0.1, 0,
        0, 0, 0,
        0, 0, 0, 0, 0, 0,
        3.5,
        Texture:of("minecraft", "textures/particle/p_glow.png"),
        "ITEM", hand, "SPAWN", "ADDITIVE", 0,
        225 + (20 * M:sin(P:getAge(player) * 0.2))
    )
end

if I:isOf(item, Items:get("minecraft:redstone")) then
    particleManager:addParticle(
        particles, false,
        0.1 * l, -0.1, 0,
        0, 0, 0,
        0, 0, 0, 0, 0, 0,
        3.5,
        Texture:of("minecraft", "textures/particle/r_glow.png"),
        "ITEM", hand, "SPAWN", "ADDITIVE", 0,
        225 + (20 * M:sin(P:getAge(player) * 0.2))
    )
end


if I:isOf(item, Items:get("minecraft:prismarine_crystals")) then
    particleManager:addParticle(
        particles, false,
        0 * l, 0, 0.1,
        0, 0, 0,
        0, 0, 0, 0, 0, 0,
        2,
        Texture:of("minecraft", "textures/particle/w_glow.png"),
        "ITEM", hand, "SPAWN", "ADDITIVE", 0,
        225 + (20 * M:sin(P:getAge(player) * 0.2))
    )
end

if I:isOf(item, Items:get("minecraft:glow_item_frame")) then
    particleManager:addParticle(
        particles, false,
        0 * l, 0, 0,
        0, 0, 0,
        0, 0, 0, 0, 0, 0,
        3,
        Texture:of("minecraft", "textures/particle/w_glow.png"),
        "ITEM", hand, "SPAWN", "ADDITIVE", 0,
        225 + (20 * M:sin(P:getAge(player) * 0.2))
    )
end

if I:isOf(item, Items:get("minecraft:nether_star")) then
    particleManager:addParticle(
        particles, false,
        0.1 * l, 0.2, 0,
        0, 0, 0,
        0, 0, 0, 0, 0, 0,
        3.5,
        Texture:of("minecraft", "textures/particle/w_glow.png"),
        "ITEM", hand, "SPAWN", "ADDITIVE", 0,
        225 + (20 * M:sin(P:getAge(player) * 0.2))
    )
end

if I:isOf(item, Items:get("minecraft:torch")) then
    particleManager:addParticle(
        particles, false,
        0.1 * l, 0.2, 0,
        0, 0, 0,
        0, 0, 0, 0, 0, 0,
        3.5,
        Texture:of("minecraft", "textures/particle/o_glow.png"),
        "ITEM", hand, "SPAWN", "ADDITIVE", 0,
        100 + (20 * M:sin(P:getAge(player) * 0.2))
    )
end

if I:isOf(item, Items:get("minecraft:copper_torch")) then
    particleManager:addParticle(
        particles, false,
        0.1 * l, 0.2, 0,
        0, 0, 0,
        0, 0, 0, 0, 0, 0,
        3.5,
        Texture:of("minecraft", "textures/particle/g_glow.png"),
        "ITEM", hand, "SPAWN", "ADDITIVE", 0,
        100 + (20 * M:sin(P:getAge(player) * 0.2))
    )
end

if I:isOf(item, Items:get("minecraft:soul_torch")) then
    particleManager:addParticle(
        particles, false,
        0.1 * l, 0.2, 0,
        0, 0, 0,
        0, 0, 0, 0, 0, 0,
        3.5,
        Texture:of("minecraft", "textures/particle/b_glow.png"),
        "ITEM", hand, "SPAWN", "ADDITIVE", 0,
        100 + (20 * M:sin(P:getAge(player) * 0.2))
    )
end

if I:isOf(item, Items:get("minecraft:lantern")) then
    particleManager:addParticle(
        particles, false,
        0 * 2, 0, -0.55,
        0, 0, 0,
        0, 0, 0, 0, 0, 0,
        3.5,
        Texture:of("minecraft", "textures/particle/o_glow.png"),
        "ITEM", hand, "SPAWN", "ADDITIVE", 0,
        150 + (20 * M:sin(P:getAge(player) * 0.2))
    )
end

if I:isOf(item, Items:get("minecraft:soul_lantern")) then
    particleManager:addParticle(
        particles, false,
        0 * 2, 0, -0.55,
        0, 0, 0,
        0, 0, 0, 0, 0, 0,
        3.5,
        Texture:of("minecraft", "textures/particle/b_glow.png"),
        "ITEM", hand, "SPAWN", "ADDITIVE", 0,
        150 + (20 * M:sin(P:getAge(player) * 0.2))
    )
end

if I:isOf(item, Items:get("minecraft:copper_lantern")) or I:isOf(item, Items:get("waxed_copper_lantern")) or I:isOf(item, Items:get("minecraft:exposed_copper_lantern")) or I:isOf(item, Items:get("waxed_exposed_copper_lantern")) or I:isOf(item, Items:get("minecraft:oxidized_copper_lantern")) or I:isOf(item, Items:get("waxed_oxidized_copper_lantern")) or I:isOf(item, Items:get("minecraft:weathered_copper_lantern")) or I:isOf(item, Items:get("minecraft:waxed_weathered_copper_lantern")) then
    particleManager:addParticle(
        particles, false,
        0 * 2, 0, -0.55,
        0, 0, 0,
        0, 0, 0, 0, 0, 0,
        3.5,
        Texture:of("minecraft", "textures/particle/g_glow.png"),
        "ITEM", hand, "SPAWN", "ADDITIVE", 0,
        150 + (20 * M:sin(P:getAge(player) * 0.2))
    )
end
