MultiLoader 26.1+ · Part 14

Custom Food Items (MultiLoader 26.1+)

BEGINNER MULTILOADER 26.1-26.1.2 12 min read · Jun 12, 2026
MultiLoader 26.1+ · 17 parts
1 Getting Started with MultiLoader 26.1+ 2 Setting Up RegistrationUtils (MultiLoader 26.1+) 3 Creating Items (MultiLoader 26.1+) 4 Creating Blocks (MultiLoader 26.1+) 5 Data Generation: Block & Item Models (MultiLoader 26.1+) 6 Data Generation: Block Loot Tables (MultiLoader 26.1+) 7 Data Generation: Crafting Recipes (MultiLoader 26.1+) 8 Data Generation: Block & Item Tags (MultiLoader 26.1+) 9 Data Generation: Language Files (MultiLoader 26.1+) 10 Data Generation: Advancements (MultiLoader 26.1+) 11 Data Generation: Sound Definitions (MultiLoader 26.1+) 12 Data Generation: Particle Descriptions (MultiLoader 26.1+) 13 Data Generation: Enchantments (MultiLoader 26.1+) 14 Custom Food Items (MultiLoader 26.1+) 15 Custom Tools (MultiLoader 26.1+) 16 Custom Armour (MultiLoader 26.1+) 17 Block Entities (MultiLoader 26.1+)

Food items are one of the most common additions to any mod. In Minecraft, any item can be made edible by attaching a FoodProperties instance to its properties. This tutorial walks through defining nutrition, saturation, and optional status effects, all from the common module, then wires up the model and creative tab entries through datagen. We will be creating a Tomato.

NOTE
Complete the Creating Items tutorial before continuing. We add a new entry to the existing ItemRegistry.

Food Properties

Food behaviour is defined through a FoodProperties object built with its inner Builder. Declare a public static final constant in ItemRegistry so the same properties object can be reused:

java
public static final FoodProperties TOMATO_PROPERTIES = new FoodProperties.Builder()
.nutrition(4)
.saturationModifier(0.3f)
.build();

The two required values are:

  • nutrition(int): the number of hunger points restored (each shank is 2 points, so 4 restores two full shanks).
  • saturationModifier(float): the saturation multiplier. Actual saturation gained is nutrition × saturationModifier × 2, so 4 × 0.3 × 2 = 2.4 saturation points.

Two optional modifiers worth knowing about are:

  • .alwaysEdible(): allows eating even when the hunger bar is full, like golden apples.
  • .fast(): shortens the eating animation to match dried kelp.

Registering the Item

Register the food item by passing TOMATO_PROPERTIES to Item.Properties.food():

java
public static final RegistryObject<Item, Item> TOMATO = ITEMS.register("tomato",
() -> new Item(getItemProperties("tomato").food(TOMATO_PROPERTIES)));

No subclass is needed for a basic food item. The food() call on the properties object is all that is required to make a plain Item edible.

Status Effects on Eating

To apply a status effect when the food is eaten, add one or more .effect() calls to the builder. Each call takes a MobEffectInstance and a probability between 0.0 (never) and 1.0 (always):

java
public static final FoodProperties TOMATO_PROPERTIES = new FoodProperties.Builder()
.nutrition(4)
.saturationModifier(0.3f)
.effect(new MobEffectInstance(MobEffects.MOVEMENT_SPEED, 200, 0), 1.0f)
.effect(new MobEffectInstance(MobEffects.POISON, 60, 0), 0.1f)
.build();

The MobEffectInstance constructor takes the effect, duration in ticks, and amplifier (0 for level I, 1 for level II, and so on). The example above always grants Speed I for 10 seconds and has a 10% chance of inflicting Poison I for 3 seconds.

Creative Tab and Language File

Open CreativeTabRegistry and add the new food item to the display items list of your existing tab:

java
.displayItems((params, output) -> {
output.accept(ItemRegistry.IRON_STICK.get());
output.accept(ItemRegistry.TOMATO.get());
})

Add a display name by opening ExampleLanguageProvider and adding a line to addTranslations():

java
add(ItemRegistry.TOMATO.get(), "Tomato");

Datagen

Food items use the flat 2D inventory model, so they are handled by registerSimpleFlatItemModel. Open ExampleModelProvider and add the tomato to registerModels:

java
@Override
protected void registerModels(BlockModelGenerators blockModels, ItemModelGenerators itemModels) {
blockModels.createTrivialCube(BlockRegistry.NEW_DIRT.get());
blockModels.registerSimpleItemModel(
BlockRegistry.NEW_DIRT.get(),
ModelLocationUtils.getModelLocation(BlockRegistry.NEW_DIRT.get()));
blockModels.registerSimpleFlatItemModel(ItemRegistry.IRON_STICK.get());
blockModels.registerSimpleFlatItemModel(ItemRegistry.TOMATO.get());
}

Create a 16x16 PNG texture at common/src/main/resources/assets/examplemod/textures/item/tomato.png and run NeoForge Data to generate the model files.

Testing In-Game

Launch the client and find the food item in your creative tab. Switch to survival mode (or use /gamemode survival) and lower your hunger bar with /effect give @s minecraft:hunger 10 4, then eat the item. Verify that the hunger and saturation bars increase correctly and that the Speed effect appears in the active effects overlay.

TIP
You can inspect saturation (which is invisible by default) by pressing F3 in-game and looking for saturation in the debug screen overlay, or by using a mod such as AppleSkin.

You can find the source for this tutorial here:

View Source on GitHub
NEXT IN SERIES

Custom Tools (MultiLoader 26.1+)

Implement a custom Tier with a dedicated incorrect-blocks tag, register sword, pickaxe, and axe items, generate handheld item models, and verify harvest level ordering with datagen block tags.

Continue →