How to make an item that burns in a furnace (Minecraft mod)
How an item becomes fuel depends on the loader and version. Fabric API up to 1.21.1: FuelRegistry.INSTANCE.add(item, ticks); from 1.21.2 the fuel is added in an event, and on 26.3 it is an item component. NeoForge reads fuel from a data map, data/neoforge/data_maps/item/furnace_fuels.json: {“values”: {“<item>”: {“burn_time”: ticks}}}. Forge has no data map: FurnaceFuelBurnTimeEvent sets the burn time. Coal burns 1600 ticks, enough to smelt 8 items (200 ticks each).
Works on Minecraft 1.20.1 to 26.3 on NeoForge; Minecraft 1.16.5 to 26.3 on Fabric; Minecraft 1.16.5 to 1.20.1 on Forge; Minecraft 1.12.2 on Forge. Each example was compiled against its loader and version before it shipped in Linen.
- Register the item.
- Fabric: add the item as fuel when the mod starts (the call depends on the version, see its notes).
- NeoForge: add the item to data/neoforge/data_maps/item/furnace_fuels.json with its burn_time.
- Forge: set the burn time in a FurnaceFuelBurnTimeEvent handler.
What you can change
Section titled “What you can change”The example uses these values. Change them in the code.
| Setting | In the example | What it does |
|---|---|---|
| ticks | 800 |
How long it burns, in ticks (coal 1600, a stick 100). |
For each loader and version
Section titled “For each loader and version”The example mod is examplemod in the package com.example.examplemod. Use your own mod id and package.
Fabric 1.16.5 to 1.21.1
Section titled “Fabric 1.16.5 to 1.21.1”Uses:
FuelRegistry.INSTANCEItem2ObjectMap.add
In your main mod class, inside onInitialize:
FuelRegistry.INSTANCE.add(ModItems.FUEL_PELLET, 800);It’s registered like any other item: see a new item.
NeoForge 1.20.1 to 26.3
Section titled “NeoForge 1.20.1 to 26.3”Uses:
neoforge:furnace_fuelsdata_maps/item/furnace_fuels.json
In src/main/resources/data/neoforge/data_maps/item/furnace_fuels.json, add this entry to /values:
"examplemod:fuel_pellet": {"burn_time": 800}It’s registered like any other item: see a new item.
Fabric 1.21.2 to 1.21.11
Section titled “Fabric 1.21.2 to 1.21.11”Uses:
FuelRegistryEvents.BUILDFuelValues.Builder.add
Fabric API’s FuelRegistry.INSTANCE is gone: add fuel in the FuelRegistryEvents.BUILD event.
In your main mod class, inside onInitialize:
FuelRegistryEvents.BUILD.register((builder, context) -> builder.add(ModItems.FUEL_PELLET, 800));It’s registered like any other item: see a new item.
Fabric 26.1 to 26.2
Section titled “Fabric 26.1 to 26.2”Uses:
FuelValueEvents.BUILDFuelValues.Builder.add
Fabric API renamed FuelRegistryEvents to FuelValueEvents in 26.1; fuel is still added in its BUILD event.
In your main mod class, inside onInitialize:
FuelValueEvents.BUILD.register((builder, context) -> builder.add(ModItems.FUEL_PELLET, 800));It’s registered like any other item: see a new item.
Fabric 26.3
Section titled “Fabric 26.3”Uses:
Item.Properties.componentDataComponents.COOKING_FUELCookingFuel
Since 26.3 fuel is an item component, not a registry call: the item’s properties carry a CookingFuel with its burn time in ticks and its smelting speed multiplier (1.0 is normal), so FuelValueEvents is gone.
It’s registered like any other item: see a new item.
new Item.Properties().component(DataComponents.COOKING_FUEL, new CookingFuel(new ResolvableInt.Constant(800), new ResolvableFloat.Constant(1.0F)))Forge 1.17.1 to 1.20.1
Section titled “Forge 1.17.1 to 1.20.1”Uses:
FurnaceFuelBurnTimeEvent.setBurnTimeFurnaceFuelBurnTimeEvent.getItemStack
Forge 1.20.1 has no data map for fuel: FurnaceFuelBurnTimeEvent sets the burn time of an item. (An item class can also override IForgeItem#getBurnTime.)
In your main mod class, inside <init>:
MinecraftForge.EVENT_BUS.addListener((FurnaceFuelBurnTimeEvent event) -> { if (event.getItemStack().is(ModItems.FUEL_PELLET.get())) { event.setBurnTime(800); }});It’s registered like any other item: see a new item.
Forge 1.16.5
Section titled “Forge 1.16.5”Uses:
FurnaceFuelBurnTimeEvent.setBurnTimeFurnaceFuelBurnTimeEvent.getItemStack
Forge 1.16.5 has no data map for fuel: FurnaceFuelBurnTimeEvent sets the burn time of an item. (An item class can also override IForgeItem#getBurnTime.)
In your main mod class, inside <init>:
MinecraftForge.EVENT_BUS.addListener((FurnaceFuelBurnTimeEvent event) -> { if (event.getItemStack().getItem() == ModItems.FUEL_PELLET.get()) { event.setBurnTime(800); }});It’s registered like any other item: see a new item.
Forge 1.12.2
Section titled “Forge 1.12.2”Uses:
FurnaceFuelBurnTimeEvent.setBurnTimeFurnaceFuelBurnTimeEvent.getItemStack
FurnaceFuelBurnTimeEvent sets the burn time of an item. (An item class can also implement IFuelHandler.)
src/main/java/com/example/examplemod/event/FuelPelletFuel.java
package com.example.examplemod.event;
import com.example.examplemod.ExampleMod;import net.minecraft.util.ResourceLocation;import net.minecraftforge.event.furnace.FurnaceFuelBurnTimeEvent;import net.minecraftforge.fml.common.Mod;import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
// fuel_pellet burns for 800 ticks in a furnace (200 ticks smelt one item). Forge asks this event for the burn time of every fuel.@Mod.EventBusSubscriber(modid = ExampleMod.MOD_ID)public final class FuelPelletFuel { private FuelPelletFuel() { }
@SubscribeEvent public static void onBurnTime(FurnaceFuelBurnTimeEvent event) { if (new ResourceLocation(ExampleMod.MOD_ID, "fuel_pellet").equals(event.getItemStack().getItem().getRegistryName())) { event.setBurnTime(800); } }}It’s registered like any other item: see a new item.
Sources
Section titled “Sources”- https://docs.fabricmc.net/1.21.1/develop/items/first-item
- https://maven.fabricmc.net/docs/fabric-api-0.116.17+1.21.1/net/fabricmc/fabric/api/registry/FuelRegistry.html
- https://docs.neoforged.net/docs/1.21.1/resources/server/datamaps/builtin
Related how-tos
Section titled “Related how-tos”In Linen
Section titled “In Linen”Linen’s How-tos library has this page too, with the example for your own mod’s loader and Minecraft version. Hover a name in your code and Linen points to the how-tos that explain it. Both are free. Download Linen.