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 swingProgress = context.swingProgress
local equipProgress = context.equipProgress
local mainHandSwitchEvent = context.mainHandSwitchEvent
local offHandSwitchEvent = context.offHandSwitchEvent

local l = (bl and 1) or -1

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 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

if I:isOf(item, Items:get("minecraft:name_tag")) or I:isOf(item, Items:get("minecraft:vine")) or I:isOf(item, Items:get("minecraft:glow_lichen")) 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:hanging_roots")) or I:isOf(item, Items:get("minecraft:pale_hanging_moss")) or I:isOf(item, Items:get("minecraft:globe_banner_pattern")) or I:isOf(item, Items:get("minecraft:field_masoned_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:mojang_banner_pattern")) or I:isOf(item, Items:get("minecraft:skull_banner_pattern")) or I:isOf(item, Items:get("minecraft:piglin_banner_pattern")) or 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:bordure_indented_banner_pattern")) or I:isIn(item, Tags:getVanillaTag("chains")) then
    M:moveY(matrices, 0.50)
    M:moveZ(matrices, -0.05)
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:moveY(matrices, 0.3)
    M:moveZ(matrices, 0.2)
    M:rotateX(matrices, 15)
    M:rotateY(matrices, 7)
    M:rotateZ(matrices, 2)
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:moveY(matrices, 0.35)
    M:moveZ(matrices, 0.05)
    M:moveX(matrices, 0)
    M:rotateX(matrices, 15)
    M:rotateY(matrices, 4)
    M:rotateZ(matrices, 0)
end

if mainHand and (I:isOf(item, Items:get("minecraft:cocoa_beans")) or (I:isOf(item, Items:get("minecraft:wheat_seeds")) or (I:isOf(item, Items:get("minecraft:torchflower_seeds")) 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:moveY(matrices, 0.3)
    M:moveZ(matrices, 0.2)
    M:rotateX(matrices, 15)
    M:rotateY(matrices, 7)
    M:rotateZ(matrices, 2)
end

if not mainHand and (I:isOf(item, Items:get("minecraft:cocoa_beans")) or (I:isOf(item, Items:get("minecraft:wheat_seeds")) or I:isOf(item, Items:get("minecraft:torchflower_seeds")) 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:moveY(matrices, 0.35)
    M:moveZ(matrices, 0.04)
    M:moveX(matrices, 0)
    M:rotateX(matrices, 15)
    M:rotateY(matrices, 4)
    M:rotateZ(matrices, 0)
end


if mainHand and I:isIn(item, Tags:getVanillaTag("lanterns")) then
    M:moveY(matrices, 0.50)
    M:moveZ(matrices, -0.05)
    M:rotateX(matrices, -15)
    M:rotateY(matrices, 7)
    M:rotateZ(matrices, -2)
end

if not mainHand and I:isIn(item, Tags:getVanillaTag("lanterns")) then
    M:moveY(matrices, 0.35)
    M:moveZ(matrices, -0.2)
    M:rotateX(matrices, -15)
    M:rotateY(matrices, 7)
    M:rotateZ(matrices, -2)
end

if mainHand and I:isOf(item, Items:get("minecraft:glow_item_frame")) then
    M:rotateX(matrices, 20)
    M:rotateZ(matrices, 6)
end

if not mainHand and I:isOf(item, Items:get("minecraft:glow_item_frame")) then
    M:rotateX(matrices, 20)
    M:rotateZ(matrices, -6)
end

if not mainHand and I:isIn(context.item, Tags:getVanillaTag("doors")) then
    M:moveX(matrices, -0.2)
    M:moveY(matrices, -0.1)
    M:rotateY(matrices, 10)
end

if (I:isOf(item, Items:get("minecraft:water_bucket")) or
        I:isOf(item, Items:get("minecraft:bucket")) or
        I:isOf(item, Items:get("minecraft:lava_bucket")) or
        I:isOf(item, Items:get("minecraft:tropical_fish_bucket")) or
        I:isOf(item, Items:get("minecraft:powder_snow_bucket"))) and ${buckets} then
    M:rotateX(matrices, 11)
    M:moveY(matrices, 0.36)
end

GHP_prevIsActive = GHP_isActive
