/*
 * 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.item.custom.TombHatItem;
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 TombHatItemRenderer extends GeoItemRenderer<TombHatItem> {
    public TombHatItemRenderer() {
        super(new TombHatModel());
    }
    @Override
    public void renderByItem(ItemStack stack, ItemDisplayContext transformType,
                             PoseStack poseStack, MultiBufferSource bufferSource,
                             int packedLight, int packedOverlay) {
        if (transformType == ItemDisplayContext.HEAD) {
            return;
        }
        poseStack.pushPose();
        switch (transformType) {
            case THIRD_PERSON_RIGHT_HAND://第三人称主手
                poseStack.scale(0.5f, 0.5f, 0.5f);
                poseStack.mulPose(Axis.YP.rotationDegrees(0));
                poseStack.translate(0.5, -1.625, 0.25);
                break;
            case FIRST_PERSON_RIGHT_HAND://第一人称主手
                poseStack.mulPose(Axis.YP.rotationDegrees(180));
                poseStack.translate(-1.75, -2.1, 0.0);
                break;
            case FIRST_PERSON_LEFT_HAND://第一人称副手
                poseStack.mulPose(Axis.YP.rotationDegrees(180));
                poseStack.translate(-0.25, -2.1, -0.0);
                break;
            case THIRD_PERSON_LEFT_HAND://第三人称副手
                poseStack.scale(0.5f, 0.5f, 0.5f);
                poseStack.mulPose(Axis.YP.rotationDegrees(0));
                poseStack.translate(0.5, -1.625, 0.25);
                break;
            case GROUND://掉落物
                poseStack.mulPose(Axis.ZP.rotationDegrees(0));
                poseStack.translate(0.0, -2.0, 0.0);
                break;
            case FIXED:
                poseStack.mulPose(Axis.ZP.rotationDegrees(0));
                poseStack.mulPose(Axis.YP.rotationDegrees(0));
                poseStack.translate(0.0, -1.95, 0.0);
                break;
            default:
                break;
        }

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

        poseStack.popPose();
    }
}