Package io.github.bakedlibs.dough.items
Class ItemUtils
java.lang.Object
io.github.bakedlibs.dough.items.ItemUtils
A utility class providing some methods to handle
ItemStacks.- Author:
- TheBusyBiscuit
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanstatic voidconsumeItem(ItemStack item, boolean replaceConsumables) This Method will consume the Item in the specified slot.static voidconsumeItem(ItemStack item, int amount, boolean replaceConsumables) This Method consumes a specified amount of items from the specified slot.static voiddamageItem(ItemStack item, boolean ignoreEnchantments) This method damages the specified Item by 1.static voiddamageItem(ItemStack item, int damage, boolean ignoreEnchantments) This method damages the specified Item by the given amount.static StringgetItemName(ItemStack item) This method returns a human-readable version of this item's name.
-
Method Details
-
getItemName
This method returns a human-readable version of this item's name. If the specifiedItemStackhas a Custom Display Name, it will return that. Otherwise it will return the english name of it'sMaterial- Parameters:
item- The Item to format- Returns:
- The formatted Item Name
-
canStack
-
damageItem
This method damages the specified Item by 1. If ignoredEnchantments is set to false, it will factor in the "Unbreaking" Enchantment.- Parameters:
item- The Item to damageignoreEnchantments- Whether the Unbreaking Enchantment should be ignored
-
damageItem
This method damages the specified Item by the given amount. If ignoredEnchantments is set to false, it will factor in the "Unbreaking" Enchantment.- Parameters:
item- The Item to damagedamage- The amount of damage to applyignoreEnchantments- Whether the Unbreaking Enchantment should be ignored
-
consumeItem
This Method will consume the Item in the specified slot. SeeconsumeItem(ItemStack, int, boolean)for further details.- Parameters:
item- The Item to consumereplaceConsumables- Whether Consumable Items should be replaced with their "empty" version, seeconsumeItem(ItemStack, int, boolean)
-
consumeItem
This Method consumes a specified amount of items from the specified slot. The items will be removed from the slot, if the slot does not hold enough items, it will be replaced with null. Note that this does not check whether there are enough Items present, if you specify a bigger amount than present, it will simply set the Item to null. If replaceConsumables is true, the following things will not be replaced with 'null':Buckets -> new ItemStack(Material.BUCKET)Potions -> new ItemStack(Material.GLASS_BOTTLE)- Parameters:
item- The Item to consumeamount- How many Items should be removedreplaceConsumables- Whether Items should be replaced with their "empty" version
-