Class ItemInfo

java.lang.Object
dev.myriadclient.api.item.ItemInfo

public final class ItemInfo extends Object
Questions about item stacks that features keep asking: enchantments, food, contents, durability, gear kind, armour. Every method takes ItemStack.EMPTY and answers as for an item that has nothing (no enchantments, not food, not armour).
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    armor(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.EquipmentSlot slot)
    Armour points it gives worn in slot (a diamond chestplate gives 8); 0 for anything that isn't armour there.
    static @Nullable net.minecraft.world.entity.EquipmentSlot
    armorSlot(net.minecraft.world.item.ItemStack stack)
    The armour slot it's worn in (head, chest, legs, feet; elytra is chest), or null if it isn't armour.
    static boolean
    canGlide(net.minecraft.world.item.ItemStack stack)
    Whether you could glide with it worn on your chest now: a glider that isn't about to break.
    static List<net.minecraft.world.item.ItemStack>
    contents(net.minecraft.world.item.ItemStack stack)
    What's stored in a container item (a shulker box, or any item carrying contents), slot by slot; empty if it has none.
    static int
    durability(net.minecraft.world.item.ItemStack stack)
    Uses left before it breaks; Integer.MAX_VALUE for items that don't wear out.
    static float
    durabilityFraction(net.minecraft.world.item.ItemStack stack)
    Durability left as 0..1 (1 for items that don't wear out).
    static int
    enchantmentLevel(net.minecraft.world.item.ItemStack stack, net.minecraft.resources.ResourceKey<net.minecraft.world.item.enchantment.Enchantment> enchantment)
    The level of enchantment (e.g.
    static @Nullable net.minecraft.world.food.FoodProperties
    food(net.minecraft.world.item.ItemStack stack)
    Hunger and saturation, or null if it isn't food.
    static boolean
    hasEnchantment(net.minecraft.world.item.ItemStack stack, net.minecraft.resources.ResourceKey<net.minecraft.world.item.enchantment.Enchantment> enchantment)
    Whether the stack has enchantment applied, at any level.
    static int
    inventoryIndex(net.minecraft.world.entity.EquipmentSlot armorSlot)
    The inventory index (Slots.HEAD etc.) for an armour slot, or Slots.OFF_HAND for the off hand; throws IllegalArgumentException for the main hand and non-player slots.
    static boolean
    isBound(net.minecraft.world.item.ItemStack stack)
    Whether it has Curse of Binding (or anything else that keeps worn armour from being taken off).
    static boolean
    isChestplate(net.minecraft.world.item.ItemStack stack)
    Whether it's armour for the chest that isn't a glider: a chestplate.
    static boolean
    isFood(net.minecraft.world.item.ItemStack stack)
    Whether it can be eaten (it has food properties), whether or not you're hungry enough to eat it now.
    static boolean
    isGlider(net.minecraft.world.item.ItemStack stack)
    Whether it's something to glide with (an elytra), worn out or not.
    static boolean
    isShulkerBox(net.minecraft.world.item.ItemStack stack)
    Whether it's a shulker box of any colour.
    static boolean
    isTool(net.minecraft.world.item.ItemStack stack)
    Whether it's a mining tool: a pickaxe, axe, shovel, hoe or shears (axes are both weapon and tool).
    static boolean
    isWeapon(net.minecraft.world.item.ItemStack stack)
    Whether it's a melee weapon: a sword, axe, trident or mace.
    static double
    toughness(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.EquipmentSlot slot)
    Armour toughness it gives worn in slot (diamond 2, netherite 3).

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • enchantmentLevel

      public static int enchantmentLevel(net.minecraft.world.item.ItemStack stack, net.minecraft.resources.ResourceKey<net.minecraft.world.item.enchantment.Enchantment> enchantment)
      The level of enchantment (e.g. Enchantments.EFFICIENCY) applied to the stack, 0 if it doesn't have it. Stored enchantments on an enchanted book don't count.
    • hasEnchantment

      public static boolean hasEnchantment(net.minecraft.world.item.ItemStack stack, net.minecraft.resources.ResourceKey<net.minecraft.world.item.enchantment.Enchantment> enchantment)
      Whether the stack has enchantment applied, at any level.
    • isFood

      public static boolean isFood(net.minecraft.world.item.ItemStack stack)
      Whether it can be eaten (it has food properties), whether or not you're hungry enough to eat it now.
    • food

      public static @Nullable net.minecraft.world.food.FoodProperties food(net.minecraft.world.item.ItemStack stack)
      Hunger and saturation, or null if it isn't food.
    • isShulkerBox

      public static boolean isShulkerBox(net.minecraft.world.item.ItemStack stack)
      Whether it's a shulker box of any colour.
    • contents

      public static List<net.minecraft.world.item.ItemStack> contents(net.minecraft.world.item.ItemStack stack)
      What's stored in a container item (a shulker box, or any item carrying contents), slot by slot; empty if it has none. The stacks are copies: changing them changes nothing.
    • durability

      public static int durability(net.minecraft.world.item.ItemStack stack)
      Uses left before it breaks; Integer.MAX_VALUE for items that don't wear out.
    • durabilityFraction

      public static float durabilityFraction(net.minecraft.world.item.ItemStack stack)
      Durability left as 0..1 (1 for items that don't wear out).
    • isWeapon

      public static boolean isWeapon(net.minecraft.world.item.ItemStack stack)
      Whether it's a melee weapon: a sword, axe, trident or mace.
    • isTool

      public static boolean isTool(net.minecraft.world.item.ItemStack stack)
      Whether it's a mining tool: a pickaxe, axe, shovel, hoe or shears (axes are both weapon and tool).
    • armorSlot

      public static @Nullable net.minecraft.world.entity.EquipmentSlot armorSlot(net.minecraft.world.item.ItemStack stack)
      The armour slot it's worn in (head, chest, legs, feet; elytra is chest), or null if it isn't armour.
    • armor

      public static double armor(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.EquipmentSlot slot)
      Armour points it gives worn in slot (a diamond chestplate gives 8); 0 for anything that isn't armour there.
    • toughness

      public static double toughness(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.EquipmentSlot slot)
      Armour toughness it gives worn in slot (diamond 2, netherite 3).
    • isGlider

      public static boolean isGlider(net.minecraft.world.item.ItemStack stack)
      Whether it's something to glide with (an elytra), worn out or not.
    • canGlide

      public static boolean canGlide(net.minecraft.world.item.ItemStack stack)
      Whether you could glide with it worn on your chest now: a glider that isn't about to break.
    • isChestplate

      public static boolean isChestplate(net.minecraft.world.item.ItemStack stack)
      Whether it's armour for the chest that isn't a glider: a chestplate.
    • isBound

      public static boolean isBound(net.minecraft.world.item.ItemStack stack)
      Whether it has Curse of Binding (or anything else that keeps worn armour from being taken off).
    • inventoryIndex

      public static int inventoryIndex(net.minecraft.world.entity.EquipmentSlot armorSlot)
      The inventory index (Slots.HEAD etc.) for an armour slot, or Slots.OFF_HAND for the off hand; throws IllegalArgumentException for the main hand and non-player slots.