This is an old revision of the document!
Table of Contents
Items
Items are the pieces of content that appear in your inventory. They can perform actions when you click, act as food, or spawn entities. The following documentation will give you a rundown of the entire Item
class and everything related to it. For a tutorial you can follow along, visit Practical Example: Adding an Item.
Item Settings
The Item
constructor requires an Item.Settings
instance. This builder class defines behavior such as stack size, durability, and whether the item is edible. A full table of available builder methods is shown below:
Method | Args | Description |
---|---|---|
food | FoodComponent | Changes the Item to be edible based on the given FoodComponent . |
maxCount | int | Sets the Item's max stack count. Can't be used in combination with damage. |
maxDamageIfAbsent | int | Sets the Item's maximum damage count if it hasn't already been set. |
maxDamage | int | Sets the Item's max stack durability. |
recipeRemainder | Item | Sets the Item's recipe remainder, which is given back to the player after the Item is used in a recipe. |
group | ItemGroup | Sets the ItemGroup of the Item, which is used for creative tabs. |
rarity | Rarity | Sets the rarity of the Item, which changes its name color. |
Food
public Item.Settings food(FoodComponent foodComponent)
foodComponent
- instance of FoodComponent
. When set, the Item will be edible based on the settings provided by the FoodComponent
builder. For an in-depth explanation of the available options, view the FoodComponent Overview page.
Max Stack Count
public Item.Settings maxCount(int maxCount)
maxCount
- the maximum count of an ItemStack
for the given Item
. If maxDamage
has already been called, a RuntimeException
is thrown, as an Item cannot have both damage and count. Keeping the max count at or below 64 is recommended, as any value above that can lead to various issues.