package net.darkhax.bookshelf.api.util;

import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MobType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper;

/**
 * This class contains static helper methods for working with ItemStacks.
 */
public final class ItemStackHelper {

    /**
     * Calculates the attack damage for an ItemStack when used to attack an unspecified mob. This will include bonus
     * damage sources such as modifiers and enchantments.
     *
     * @param stack The ItemStack to calculate the damage value of.
     * @return The attack damage for an ItemStack with bonus damage modifiers applied.
     */
    public static double getAttackDamage(ItemStack stack) {

        return getAttackDamage(stack, MobType.UNDEFINED);
    }

    /**
     * Calculates the attack damage for an ItemStack when used to attack a specific entity. This will include bonus
     * damage sources such as attribute modifiers and enchantments.
     *
     * @param stack  The ItemStack to calculate the damage value of.
     * @param target The target entity being attacked.
     * @return The attack damage for an ItemStack with bonus damage modifiers applied.
     */
    public static double getAttackDamage(ItemStack stack, Entity target) {

        return getAttackDamage(stack, (target instanceof LivingEntity living) ? living.getMobType() : MobType.UNDEFINED);
    }

    /**
     * Calculates the attack damage for an ItemStack after accounting for bonus damage modifiers such as attribute
     * modifiers and enchantments.
     *
     * @param stack      The ItemStack to calculate the damage value of.
     * @param targetType The type of mob being attacked. Used for some enchantment calculations.
     * @return The attack damage for an ItemStack with bonus damage modifiers applied.
     */
    public static double getAttackDamage(ItemStack stack, MobType targetType) {

        final double damage = AttributeHelper.getAttackDamage(stack);
        final double bonusEnchantmentDamage = EnchantmentHelper.getDamageBonus(stack, targetType);

        return damage + bonusEnchantmentDamage;
    }
}

@@ -34,16 +34,55 @@
 .util;%0A%0A
+import net.minecraft.core.NonNullList;%0A
 import n
@@ -206,16 +206,65 @@
 obType;%0A
+import net.minecraft.world.item.CreativeModeTab;%0A
 import n
@@ -362,16 +362,43 @@
 elper;%0A%0A
+import java.util.Objects;%0A%0A
 /**%0A * T
@@ -2346,10 +2346,491 @@
 ;%0A    %7D%0A
-%7D
 %0A
+    public static ItemStack%5B%5D getTabItems(CreativeModeTab tab) %7B%0A%0A        final NonNullList%3CItemStack%3E stacks = NonNullList.create();%0A        CreativeModeTab.TAB_COMBAT.fillItemList(stacks);%0A        return stacks.toArray(ItemStack%5B%5D::new);%0A    %7D%0A%0A    public static boolean areStacksEquivalent(ItemStack first, ItemStack second) %7B%0A%0A        return first.isEmpty() == second.isEmpty() && first.getCount() == second.getCount() && Objects.equals(first.getTag(), second.getTag());%0A    %7D%0A%7D

Add helpers to read creative tab contents and test ItemStack equivalency.