package com.r3944realms.leashedplayer.content.items.type;

import com.r3944realms.leashedplayer.content.entities.LeashRopeArrow;
import com.r3944realms.leashedplayer.content.entities.ModEntityRegister;
import net.minecraft.core.Direction;
import net.minecraft.core.Position;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.item.ArrowItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.component.TooltipDisplay;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nullable;
import java.util.function.Consumer;

public class LeashRopeArrowItem extends ArrowItem implements ILeashRopeArrow{
    public static final String descKey = "item.leash_rope_arrow.description",
            DESC_1 = "item.leash_rope_arrow.desc.1",
            DESC_2 = "item.leash_rope_arrow.desc.2",
            DESC_3 = "item.leash_rope_arrow.desc.3",
            DESC_4 = "item.leash_rope_arrow.desc.4",
            DESC_5 = "item.leash_rope_arrow.desc.5";
    public static final String
            DESC_V_1 = "item.variant.leash_rope_arrow.desc.1",
            DESC_V_2 = "item.variant.leash_rope_arrow.desc.2";
    public LeashRopeArrowItem(Properties pProperties) {
        super(pProperties) ;
    }

    public @NotNull AbstractArrow createArrow(@NotNull Level pLevel, @NotNull ItemStack pAmmo, @NotNull LivingEntity pShooter, @Nullable ItemStack pWeapon) {
        return new LeashRopeArrow(ModEntityRegister.LEASH_ROPE_ARROW.get(),pShooter, pLevel, pAmmo.copyWithCount(1), pWeapon);
    }

    @Override
    public @NotNull Projectile asProjectile(@NotNull Level pLevel, @NotNull Position pPos, @NotNull ItemStack pStack, @NotNull Direction pDirection) {
        LeashRopeArrow arrow = new LeashRopeArrow(ModEntityRegister.LEASH_ROPE_ARROW.get(), pPos.x(), pPos.y(), pPos.z(), pLevel, pStack,null, null);
        arrow.pickup = AbstractArrow.Pickup.DISALLOWED;
        return arrow;
    }


    @Override
    public void appendHoverText(@NotNull ItemStack pItemStack, @NotNull TooltipContext pTooltipComponents, @NotNull TooltipDisplay pTooltipDisplay, Consumer<Component> pConsumer, @NotNull TooltipFlag pTooltipFlag) {
        pConsumer.accept(Component.translatable(LeashRopeArrowItem.DESC_1));
        pConsumer.accept(Component.translatable(LeashRopeArrowItem.DESC_2));
        pConsumer.accept(Component.translatable(LeashRopeArrowItem.DESC_3));
        pConsumer.accept(Component.translatable(LeashRopeArrowItem.DESC_4));
        pConsumer.accept(Component.translatable(LeashRopeArrowItem.DESC_5));
    }
}
