Class ItemInfo
java.lang.Object
dev.myriadclient.api.item.ItemInfo
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 TypeMethodDescriptionstatic doublearmor(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.EquipmentSlot slot) Armour points it gives worn inslot(a diamond chestplate gives 8); 0 for anything that isn't armour there.static @Nullable net.minecraft.world.entity.EquipmentSlotarmorSlot(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 booleancanGlide(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 intdurability(net.minecraft.world.item.ItemStack stack) Uses left before it breaks;Integer.MAX_VALUEfor items that don't wear out.static floatdurabilityFraction(net.minecraft.world.item.ItemStack stack) Durability left as 0..1 (1 for items that don't wear out).static intenchantmentLevel(net.minecraft.world.item.ItemStack stack, net.minecraft.resources.ResourceKey<net.minecraft.world.item.enchantment.Enchantment> enchantment) The level ofenchantment(e.g.static @Nullable net.minecraft.world.food.FoodPropertiesfood(net.minecraft.world.item.ItemStack stack) Hunger and saturation, or null if it isn't food.static booleanhasEnchantment(net.minecraft.world.item.ItemStack stack, net.minecraft.resources.ResourceKey<net.minecraft.world.item.enchantment.Enchantment> enchantment) Whether the stack hasenchantmentapplied, at any level.static intinventoryIndex(net.minecraft.world.entity.EquipmentSlot armorSlot) The inventory index (Slots.HEADetc.) for an armour slot, orSlots.OFF_HANDfor the off hand; throwsIllegalArgumentExceptionfor the main hand and non-player slots.static booleanisBound(net.minecraft.world.item.ItemStack stack) Whether it has Curse of Binding (or anything else that keeps worn armour from being taken off).static booleanisChestplate(net.minecraft.world.item.ItemStack stack) Whether it's armour for the chest that isn't a glider: a chestplate.static booleanisFood(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 booleanisGlider(net.minecraft.world.item.ItemStack stack) Whether it's something to glide with (an elytra), worn out or not.static booleanisShulkerBox(net.minecraft.world.item.ItemStack stack) Whether it's a shulker box of any colour.static booleanisTool(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 booleanisWeapon(net.minecraft.world.item.ItemStack stack) Whether it's a melee weapon: a sword, axe, trident or mace.static doubletoughness(net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.EquipmentSlot slot) Armour toughness it gives worn inslot(diamond 2, netherite 3).
-
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 ofenchantment(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 hasenchantmentapplied, 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_VALUEfor 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 inslot(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 inslot(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.HEADetc.) for an armour slot, orSlots.OFF_HANDfor the off hand; throwsIllegalArgumentExceptionfor the main hand and non-player slots.
-