/*
 * Copyright (c) 2026 盐灯水母
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */

package com.remains_cave.entity.client;

import com.mojang.blaze3d.vertex.*;
import com.mojang.math.Axis;
import com.remains_cave.item.custom.BoneHatchetItem;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import software.bernie.geckolib.renderer.GeoItemRenderer;

public class BoneHatchetRenderer extends GeoItemRenderer<BoneHatchetItem> {
    public BoneHatchetRenderer() {
        super(new BoneHatchetModel());
    }

    @Override
    public void renderByItem(ItemStack stack, ItemDisplayContext transformType,
                             PoseStack poseStack, MultiBufferSource bufferSource,
                             int light, int overlay) {
        poseStack.pushPose();

        // 根据需要保留非 GUI 视角的变换
        if (transformType == ItemDisplayContext.FIRST_PERSON_RIGHT_HAND) {
            poseStack.mulPose(Axis.ZP.rotationDegrees(-8));
            poseStack.mulPose(Axis.YP.rotationDegrees(8));
            poseStack.translate(-0.05, 0.4, 0);
        } else if (transformType == ItemDisplayContext.FIRST_PERSON_LEFT_HAND) {
            poseStack.mulPose(Axis.ZP.rotationDegrees(8));
            poseStack.mulPose(Axis.YP.rotationDegrees(-8));
            poseStack.translate(0.1, 0.28, -0.1);
        } else if (transformType == ItemDisplayContext.GROUND) {
            poseStack.mulPose(Axis.XP.rotationDegrees(45));
            poseStack.translate(0, 0.5, -0.5);
        } else if (transformType == ItemDisplayContext.FIXED) {
            poseStack.mulPose(Axis.YP.rotationDegrees(90));
            poseStack.mulPose(Axis.ZP.rotationDegrees(180));
            poseStack.mulPose(Axis.XP.rotationDegrees(-135));
            poseStack.translate(0, -0.45, -1.2);
        }

        super.renderByItem(stack, transformType, poseStack, bufferSource, light, overlay);
        poseStack.popPose();
    }
}