/*
 * 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.item.client;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
import com.remains_cave.client.model.TrophyItemModel;
import com.remains_cave.item.custom.TrophyItem;
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 TrophyItemRenderer extends GeoItemRenderer<TrophyItem> {
    public TrophyItemRenderer() {
        super(new TrophyItemModel());
    }

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

        // 根据视角调整（这些数值可能需要微调）
        switch (transformType) {
            case THIRD_PERSON_RIGHT_HAND:
            case THIRD_PERSON_LEFT_HAND:
                poseStack.mulPose(Axis.XP.rotationDegrees(90));
                poseStack.translate(0, -0.15, -1.175);
                break;
            case FIRST_PERSON_RIGHT_HAND:
                poseStack.mulPose(Axis.YP.rotationDegrees(180));
                poseStack.translate(-1.375, -0.2, -0.5);
                break;
            case FIRST_PERSON_LEFT_HAND:
                poseStack.mulPose(Axis.YP.rotationDegrees(180));
                poseStack.translate(-0.625, -0.2, -0.5);
                break;
            case GROUND:
                poseStack.translate(0, 0, 0);
                break;
            case GUI:
                poseStack.mulPose(Axis.YP.rotationDegrees(202.5f));
                poseStack.mulPose(Axis.ZP.rotationDegrees(-22.5F));
                poseStack.translate(-1.75, -1.0, 0);
                poseStack.scale(1.5f, 1.5f, 1.5f);
                break;
            case FIXED:
                poseStack.translate(-0.25, -0.625, -0.5);
                poseStack.scale(1.5f, 1.5f, 1.5f);
                break;
            default:
                break;
        }

        super.renderByItem(stack, transformType, poseStack, bufferSource, packedLight, packedOverlay);
        poseStack.popPose();
    }
}