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

import com.remains_cave.config.RemainsCaveConfig;
import com.remains_cave.entity.projectile.CustomArrowEntity;
import com.remains_cave.util.ConfigHelper;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.item.ArrowItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.neoforged.fml.config.ModConfig;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;


public class CustomArrowItem extends ArrowItem {
    public CustomArrowItem(Properties properties) {
        super(properties);
    }

    @Override
    public @NotNull AbstractArrow createArrow(@NotNull Level level, ItemStack ammoStack, @NotNull LivingEntity shooter, @Nullable ItemStack weapon) {
        // 将武器（弓）传递给箭的构造，以便附魔生效
        double defaultDamage = ConfigHelper.getOrFallback(RemainsCaveConfig.COMMON.ARROW_BASE_DAMAGE::get, 3.0);
        return new CustomArrowEntity(level, shooter, ammoStack.copyWithCount(1), weapon, defaultDamage);
    }
}