Jump to content

[1.7.X.]Using a Block as Fuel


Recommended Posts

First off, I know how to code java so do not tell me to "go learn java" this should be exemplified in my code.


My problem is simply how do I use a block as a furnace fuel? I came across the problem while making my core mod and thought I could find the answer here.


So, this is the corresponding code but it registers items as furnace fuel:


public class VinillaItemFurnaceFuelHandler implements IFuelHandler{

public static HashMap<Item, Integer> FurnaceFuel = new HashMap<Item, Integer>();

public static void RegisterFurnaceFuel(Item fuel, Integer burnTime){

	FurnaceFuel.put(fuel, burnTime);
public int getBurnTime(ItemStack fuel) {

	Item ItemInFuelSlot = fuel.getItem();
	Integer BurnTime = FurnaceFuel.get(ItemInFuelSlot);

	if (BurnTime == null){
		return 0;
	} else return BurnTime;	


Now I predict my problem with the upcoming code is I do not know how to get a Block for an ItemStack so if you know how to do so please say.


public class VinillaItemFurnaceFuelHandler implements IFuelHandler{

public static HashMap<Item, Integer> FurnaceFuel = new HashMap<Item, Integer>();

public static void RegisterFurnaceFuel(Item fuel, Integer burnTime){

	FurnaceFuel.put(fuel, burnTime);

public int getBurnTime(ItemStack fuel) {
	 //Here forward I am confused and do not know what to do
	Item ItemInFuelSlot = fuel.getItem(); //I need to get the Block
	Integer BurnTime = FurnaceFuel.get(ItemInFuelSlot);

                //Here forward I am not confused

	if (BurnTime == null){
		return 0;
	} else return BurnTime;	


Thank You In Advanced,


Link to comment
Share on other sites

Perhaps I can help. I've created my own class(Which so happens is also called 'FurnaceFuel') and I use it to make blocks and items burnable in a furnace all the time. Here's my FurnaceFuel class, and then below that the code in one of my block classes that adds itself as a burnable item:




package com.gmail.br45entei.main;


import java.util.Map;

import java.util.HashMap;


import net.minecraft.init.Blocks;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import cpw.mods.fml.common.IFuelHandler;

import cpw.mods.fml.common.registry.GameRegistry;


/**@author Brian_Entei */

public class FurnaceFuel implements IFuelHandler {


public FurnaceFuel() {Main.logger.info(Main.modLogger, "FurnaceFuel Test");}


public void initialize() {

/*Wooden Slabs - 150

Anything made out of wood - 300

Wooden Tools - 200

Sticks - 100

Coal - 1600

Lava Bucket - 20000

Sapling - 100

Blaze Rod - 2400*/

addBurnableItem(new ItemStack(Blocks.wooden_slab), 150);

addBurnableItem(new ItemStack(Blocks.chest), 300);

addBurnableItem(new ItemStack(Blocks.crafting_table), 300);

addBurnableItem(new ItemStack(Blocks.dark_oak_stairs), 300);

addBurnableItem(new ItemStack(Blocks.double_wooden_slab), 300);

addBurnableItem(new ItemStack(Blocks.fence), 300);

addBurnableItem(new ItemStack(Blocks.fence_gate), 300);

addBurnableItem(new ItemStack(Blocks.jungle_stairs), 300);

addBurnableItem(new ItemStack(Blocks.ladder), 300);

addBurnableItem(new ItemStack(Blocks.log), 300);

addBurnableItem(new ItemStack(Blocks.log2), 300);

addBurnableItem(new ItemStack(Blocks.oak_stairs), 300);

addBurnableItem(new ItemStack(Blocks.piston_head), 300);

addBurnableItem(new ItemStack(Blocks.planks), 300);

addBurnableItem(new ItemStack(Blocks.sapling), 100);

addBurnableItem(new ItemStack(Blocks.torch), 300);

addBurnableItem(new ItemStack(Blocks.tnt), 100000);//XD lol it's going to exploooode! xD

addBurnableItem(new ItemStack(Blocks.trapdoor), 300);

addBurnableItem(new ItemStack(Blocks.trapped_chest), 300);

addBurnableItem(new ItemStack(Blocks.wall_sign), 300);

addBurnableItem(new ItemStack(Blocks.web), 75);

addBurnableItem(new ItemStack(Blocks.wooden_button), 300);

addBurnableItem(new ItemStack(Blocks.wooden_door), 300);

addBurnableItem(new ItemStack(Blocks.wooden_pressure_plate), 300);

addBurnableItem(new ItemStack(Blocks.wooden_slab), 300);

addBurnableItem(new ItemStack(Blocks.wool), 300);

addBurnableItem(new ItemStack(Items.blaze_powder), 1250);

addBurnableItem(new ItemStack(Items.blaze_rod), 2400);

addBurnableItem(new ItemStack(Items.bowl), 300);

addBurnableItem(new ItemStack(Items.coal), 1600);

addBurnableItem(new ItemStack(Items.filled_map), 100);

addBurnableItem(new ItemStack(Items.map), 100);

addBurnableItem(new ItemStack(Items.fishing_rod), 150);

addBurnableItem(new ItemStack(Items.lava_bucket), 20000);

addBurnableItem(new ItemStack(Items.lead), 100);

addBurnableItem(new ItemStack(Items.leather), 300);

addBurnableItem(new ItemStack(Items.leather_boots), 310);

addBurnableItem(new ItemStack(Items.leather_chestplate), 450);

addBurnableItem(new ItemStack(Items.leather_helmet), 320);

addBurnableItem(new ItemStack(Items.leather_leggings), 360);

addBurnableItem(new ItemStack(Items.magma_cream), 1200);

addBurnableItem(new ItemStack(Items.name_tag), 100);

addBurnableItem(new ItemStack(Items.nether_star), 60000);

addBurnableItem(new ItemStack(Items.painting), 100);

addBurnableItem(new ItemStack(Items.saddle), 500);

addBurnableItem(new ItemStack(Items.sign), 300);

addBurnableItem(new ItemStack(Items.stick), 100);

addBurnableItem(new ItemStack(Items.string), 50);

addBurnableItem(new ItemStack(Items.wheat), 75);

addBurnableItem(new ItemStack(Items.wheat_seeds), 10);

addBurnableItem(new ItemStack(Items.wooden_axe), 200);

addBurnableItem(new ItemStack(Items.wooden_door), 300);

addBurnableItem(new ItemStack(Items.wooden_hoe), 200);

addBurnableItem(new ItemStack(Items.wooden_pickaxe), 200);

addBurnableItem(new ItemStack(Items.wooden_shovel), 200);

addBurnableItem(new ItemStack(Items.wooden_sword), 200);

addBurnableItem(new ItemStack(Items.writable_book), 75);

addBurnableItem(new ItemStack(Items.written_book), 80);







private static Map<ItemStack, Integer> customBurnableItems = new HashMap<ItemStack, Integer>();

public static void addBurnableItem(ItemStack item, int burnTime) {

customBurnableItems.put(item, Integer.valueOf(burnTime));



public static void removeBurnableItem(ItemStack item) {





public int getBurnTime(ItemStack item) {

Item fuel = item.getItem();

int fuelID = Item.getIdFromItem(fuel);

for(Map.Entry<ItemStack, Integer> entry : FurnaceFuel.customBurnableItems.entrySet()) {

Item curItem = entry.getKey().getItem();


int burnTime = entry.getValue();

if(fuelID == Item.getIdFromItem(curItem)) {

return burnTime;



return 0;










public BlockModBaseBlockMultiTextured setCanBeFurnaceFuel(boolean canBeFurnaceFuel, int burnTime) {

if(canBeFurnaceFuel) {

FurnaceFuel.addBurnableItem(new ItemStack(this), burnTime);

this.burnTime = burnTime;

} else {

FurnaceFuel.removeBurnableItem(new ItemStack(this));

this.burnTime = 0;


this.canBeFurnaceFuel = canBeFurnaceFuel;

return this;





However, I think that my code won't really help you as it looks like you need a block from an itemstack. You can do that like so:


Block yourBlock = Block.getBlockFromItem(someItemStack.getItem());


I hope this helps :)

Link to comment
Share on other sites

implement IFuelHandler in your block class and create the method "int getBurnTime(ItemStack stack)". The register the block as a Fuel Handler with: GameRegistry.registerFuelHandler( MyBlocks.myFuelBlock );

Of course, replace the argument with your own block instance.


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

By using this site, you agree to our Terms of Use.