package top.r3944realms.lib39.content.item;

import com.mojang.authlib.GameProfile;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.Equipable;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.StandingAndWallBlockItem;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import top.r3944realms.lib39.core.register.Lib39Blocks;
import top.r3944realms.lib39.util.GameProfileHelper;

import java.util.List;

/**
 * The type Doll item.
 */
public class DollItem extends StandingAndWallBlockItem implements Equipable {
    /**
     * Instantiates a new Doll item.
     *
     * @param properties the properties
     */
    public DollItem(Properties properties) {
        super(Lib39Blocks.DOLL.get(), Lib39Blocks.WALL_DOLL.get(), properties, Direction.DOWN);
    }


    @Override
    public void appendHoverText(@NotNull ItemStack stack, @Nullable Level level, @NotNull List<Component> tooltip, @NotNull TooltipFlag flag) {
        GameProfile profileFromItemStack = GameProfileHelper.getProfileFromItemStack(stack);
        if (profileFromItemStack != null && profileFromItemStack.getName() != null) {
            tooltip.add(Component.translatable("tooltip.lib39.content.doll.hover.1", profileFromItemStack.getName()));
        }
        tooltip.add(Component.translatable("tooltip.lib39.content.doll.hover.2"));
    }

    @Override
    public @NotNull EquipmentSlot getEquipmentSlot() {
        return EquipmentSlot.HEAD;
    }
}
