FoodItem

class FoodItem(name: String, material: Material = Material.COOKED_BEEF)

Represents a custom food item with customizable properties and effects.

This class allows the creation of food items that can restore hunger and saturation, apply potion effects upon consumption, and have additional features like the ability to always be eaten or conversion into another item. The created food item can be used as a CustomItem, which can be registered and given to players.

Parameters

name

The name of the food item.

material

The Material of the food item (default is COOKED_BEEF).

Constructors

Link copied to clipboard
constructor(name: String, material: Material = Material.COOKED_BEEF)

Functions

Link copied to clipboard
fun addEffect(effect: PotionEffect, probability: Float): FoodItem

Adds a potion effect to the food item, which will be applied with a certain probability upon consumption.

Link copied to clipboard

Builds and returns the CustomItem representation of the food item.

Link copied to clipboard

Makes the food item always consumable, even when the player is not hungry.

Link copied to clipboard
fun eatingConvertsTo(item: ItemStack): FoodItem

Sets the item that the food will convert to once it is eaten.

Link copied to clipboard
fun eatSeconds(seconds: Float): FoodItem

Sets the time (in seconds) it takes to eat the food item.

Link copied to clipboard
fun glow(): FoodItem

Adds a glowing effect to the food item.

Link copied to clipboard
fun hunger(points: Int): FoodItem

Sets the number of hunger points the food item restores.

Link copied to clipboard
fun lore(vararg lines: String): FoodItem

Adds lore to the food item.

Link copied to clipboard
fun saturation(amount: Float): FoodItem

Sets the saturation the food item provides.

Link copied to clipboard

Marks the food item as unbreakable.