AbyssalLib Help

Custom Food

Creating custom food items in AbyssalLib is highly flexible thanks to the DataComponent system. In this guide, we will transform a standard item into something a player can eat to restore hunger and saturation.

To create a custom food, you need to utilize Item#setData and apply both the Food and Consume components.

Adding the Food component

To make the item mathematically "edible" to the server (providing hunger/saturation), we will set the Food DataComponent.

item.setData(new Food(FoodProperties.food() .canAlwaysEat(false) .nutrition(3) .saturation(4.5f) .build()));

Method

Information

canAlwaysEat

Whether or not the player can eat the item while their nutrition is already full.

nutrition

Amount of nutrition to restore.

saturation

Amount of saturation (hidden anti-hunger mechanic) to restore.

While this gives the item food properties, if you try to eat the item in-game now, it will not work because the item lacks the timing needed to be consumed.

Adding the Consumable component

To make the item physically eaten by the player, we add the Consume component similarly to the Food DataComponent.

item.setData(new Consume(Consumable.consumable() .consumeSeconds(0.8f) .build()));

Method

Information

addEffect

Adds a single ConsumeEffect (like gaining a Potion Effect).

addEffects

Adds multiple ConsumeEffect instances.

animation

Sets the ItemUseAnimation to be used during consumption (e.g., eat, drink).

consumeSeconds

Sets the time (in seconds) it takes to finish eating the item.

effects

Sets the ConsumeEffect instances that should occur upon completion.

hasConsumeParticles

Sets whether crumb particles should spawn during consumption.

sound

Sets the sound that should play during consumption.

Bringing it all together

With both components applied, our food item is fully functional. Here is how a complete registration might look:

public static final Item EDIBLE_PAPER = register("edible_paper", item -> { item.setData(new ItemModel(NamespacedKey.minecraft("paper"))); // 1. Give it food properties item.setData(new Food(FoodProperties.food() .canAlwaysEat(true) .nutrition(3) .saturation(4.5f) .build())); // 2. Give it consume properties item.setData(new Consume(Consumable.consumable() .consumeSeconds(0.8f) .hasConsumeParticles(true) .build())); });
05 June 2026