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.foodCount = 0.0;
global.foodCountO = 0.0;

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 foodcount = Easings:easeInQuart(context.mainHand and foodCount or foodCountO)

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

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 not 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 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
    particleManager:addParticle(
        particles, false,
        0.02 * l, 0.24, 0.2,
        0, 0, 0,
        0, 0, 0, 0, 0, 0,
        2.5,
        Texture:of("minecraft", "textures/particle/b_glow.png"),
        "ITEM", hand, "SPAWN", "ADDITIVE", 0,
        150 + (20 * M:sin(P:getAge(player) * 0.2))
    )
end
