Jump to content

[1.5.2] [Solved] Adding a new Fuel


BlueGhast90

Recommended Posts

package chibill.AdditionalCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.IFuelHandler;

public class FuelHandler implements IFuelHandler {
@Override
public int getBurnTime(ItemStack fuel) {


	int var1 = fuel.itemID;

	if(var1 == Item.book.itemID){
		return 300;
	}else if(var1 == Base.NetherStone.itemID){
		return 40000;
	}else
		return 0;
	}

}

 

In its own class then in base class

 

GameRegistry.registerFuelHandler(new FuelHandler());

Link to comment
Share on other sites

I believe that "Base" is something like, YourModBase...

 

So as a rewrite... :

public class FuelHandler implements IFuelHandler {
@Override
public int getBurnTime(ItemStack fuel) {


	int var1 = fuel.itemID;

	if(var1 == Item.book.itemID){
		return 300;
	}else if(var1 == YourModBase.itemYouWantAsFuel.itemID){
		return 40000;
	}else
		return 0;
	}

}

 

in "YourModBase":

GameRegistry.registerFuelHandler(new FuelHandler());

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

By the way, would it be possible to make a block a fuel (like the Coal Block in 1.6), because i keep getting a cannot make a static reference to a non-static object error

 

That would be a problem with the way you have registered the block then.

 

And it would be something like this:

[EDIT]

public class FuelHandler implements IFuelHandler {
@Override
public int getBurnTime(ItemStack fuel) {

	int var1 = fuel.itemID;

	if(var1 == Item.book.itemID){
		return 300;
	}else if(var1 == YourModBase.itemYouWantAsFuel.itemID){
		return 40000;
	} else if(var1 == YourModBase.blockYouWantAsFuel.blockID){
                        return 12345;
                } else
		return 0;
	}

}

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

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.

Guest
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.

Announcements



×
×
  • Create New...

Important Information

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