Package net.darkhax.bookshelf.api.util
Class ItemStackHelper
java.lang.Object
net.darkhax.bookshelf.api.util.ItemStackHelper
This class contains static helper methods for working with ItemStacks.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidappendLore(net.minecraft.world.item.ItemStack stack, net.minecraft.network.chat.Component... lines) static booleanareCollectionTagsEquivalent(net.minecraft.nbt.CollectionTag<?> a, net.minecraft.nbt.CollectionTag<?> b) static booleanareCompoundTagsEquivalent(net.minecraft.nbt.CompoundTag a, net.minecraft.nbt.CompoundTag b) static booleanareNumericTagsEquivalent(net.minecraft.nbt.NumericTag a, net.minecraft.nbt.NumericTag b) static booleanareStacksContentsEquivalent(net.minecraft.world.item.ItemStack first, net.minecraft.world.item.ItemStack second) static booleanareStacksEquivalent(net.minecraft.world.item.ItemStack first, net.minecraft.world.item.ItemStack second) static booleanareStacksEquivalent(net.minecraft.world.item.ItemStack first, net.minecraft.world.item.ItemStack second, boolean ignoreTags) static booleanareTagsEquivalent(net.minecraft.nbt.Tag a, net.minecraft.nbt.Tag b) static doublegetAttackDamage(net.minecraft.world.item.ItemStack stack) Calculates the attack damage for an ItemStack when used to attack an unspecified mob.static doublegetAttackDamage(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.Entity target) Calculates the attack damage for an ItemStack when used to attack a specific entity.static doublegetAttackDamage(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.MobType targetType) Calculates the attack damage for an ItemStack after accounting for bonus damage modifiers such as attribute modifiers and enchantments.static net.minecraft.world.item.ItemStack[]getTabItems(net.minecraft.world.item.CreativeModeTab tab) static booleanisDecimal(net.minecraft.nbt.NumericTag tag) static voidsetLore(net.minecraft.world.item.ItemStack stack, net.minecraft.network.chat.Component... lines)
-
Constructor Details
-
ItemStackHelper
public ItemStackHelper()
-
-
Method Details
-
getAttackDamage
public static double getAttackDamage(net.minecraft.world.item.ItemStack stack) 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.- Parameters:
stack- The ItemStack to calculate the damage value of.- Returns:
- The attack damage for an ItemStack with bonus damage modifiers applied.
-
getAttackDamage
public static double getAttackDamage(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.Entity target) 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.- Parameters:
stack- The ItemStack to calculate the damage value of.target- The target entity being attacked.- Returns:
- The attack damage for an ItemStack with bonus damage modifiers applied.
-
getAttackDamage
public static double getAttackDamage(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.MobType targetType) Calculates the attack damage for an ItemStack after accounting for bonus damage modifiers such as attribute modifiers and enchantments.- Parameters:
stack- The ItemStack to calculate the damage value of.targetType- The type of mob being attacked. Used for some enchantment calculations.- Returns:
- The attack damage for an ItemStack with bonus damage modifiers applied.
-
getTabItems
public static net.minecraft.world.item.ItemStack[] getTabItems(net.minecraft.world.item.CreativeModeTab tab) -
areStacksEquivalent
public static boolean areStacksEquivalent(net.minecraft.world.item.ItemStack first, net.minecraft.world.item.ItemStack second) -
areStacksContentsEquivalent
public static boolean areStacksContentsEquivalent(net.minecraft.world.item.ItemStack first, net.minecraft.world.item.ItemStack second) -
areStacksEquivalent
public static boolean areStacksEquivalent(net.minecraft.world.item.ItemStack first, net.minecraft.world.item.ItemStack second, boolean ignoreTags) -
areTagsEquivalent
public static boolean areTagsEquivalent(net.minecraft.nbt.Tag a, net.minecraft.nbt.Tag b) -
areCompoundTagsEquivalent
public static boolean areCompoundTagsEquivalent(net.minecraft.nbt.CompoundTag a, net.minecraft.nbt.CompoundTag b) -
areCollectionTagsEquivalent
public static boolean areCollectionTagsEquivalent(net.minecraft.nbt.CollectionTag<?> a, net.minecraft.nbt.CollectionTag<?> b) -
areNumericTagsEquivalent
public static boolean areNumericTagsEquivalent(net.minecraft.nbt.NumericTag a, net.minecraft.nbt.NumericTag b) -
isDecimal
public static boolean isDecimal(net.minecraft.nbt.NumericTag tag) -
setLore
public static void setLore(net.minecraft.world.item.ItemStack stack, net.minecraft.network.chat.Component... lines) -
appendLore
public static void appendLore(net.minecraft.world.item.ItemStack stack, net.minecraft.network.chat.Component... lines)
-