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

import com.remains_cave.RemainsCaveMod;
import com.remains_cave.item.menu.QuiverMenu;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Inventory;

public class QuiverScreen extends AbstractContainerScreen<QuiverMenu> {
    private static final ResourceLocation QUIVER_TEXTURE =
            ResourceLocation.fromNamespaceAndPath(RemainsCaveMod.MODID, "textures/gui/quiver.png");
    private static final ResourceLocation PLAYER_INVENTORY_TEXTURE =
            ResourceLocation.withDefaultNamespace("textures/gui/container/inventory.png");

    public QuiverScreen(QuiverMenu menu, Inventory inventory, Component title) {
        super(menu, inventory, title);
        this.imageWidth = 176;
        this.imageHeight = 32 + 86;
    }

    @Override
    protected void renderBg(GuiGraphics guiGraphics, float partialTick, int mouseX, int mouseY) {
        // 可以留空，或者保留你的纹理绘制代码
        int x = (width - imageWidth) / 2;
        int y = (height - imageHeight) / 2;

        // 绘制箭袋部分
        guiGraphics.blit(QUIVER_TEXTURE, x, y + 12, 0, 0, imageWidth, 32, imageWidth, 32);

        // 绘制背包部分
        int playerInventoryY = y + 32 + 14;
        guiGraphics.blit(PLAYER_INVENTORY_TEXTURE, x, playerInventoryY, 0, 79, 176, 86, 256, 256);
    }

    @Override
    protected void renderLabels(GuiGraphics guiGraphics, int mouseX, int mouseY) {
        // 留空，不渲染任何文字（标题和库存标签均被移除）
    }

    @Override
    public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
        // 移除 renderBackground 调用，这样就不会绘制暗色背景层
        super.render(guiGraphics, mouseX, mouseY, partialTick);
        renderTooltip(guiGraphics, mouseX, mouseY);
    }
}