Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I'm having an issue finding the correct method and/or functions to make my custom item to be used as fuel as well as setting a burn time. I've tried creating an item that extends ItemCoal to simply test if I could get it to work. I've looked through materials of vanilla burnable items and could not locate where this is adjusted. I'm almost certain I'll need to make a material for this but I am unsure. Any help would be appreciated.

  • Author

Ok so I've come up with this:

package com.INTENSS.BTP;

import com.INTENSS.BTP.Blocks.PyroxBlock;
import com.INTENSS.BTP.Items.PyroxIngot;
import net.minecraft.block.Block;
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;

public class FurnaceFuel implements IFuelHandler {



@Override
public int getBurnTime(ItemStack fuel) {

	Block blockFuel = Block.getBlockFromItem(fuel.getItem());
	Item itemFuel = fuel.getItem();

	if (blockFuel == PyroxBlock.pyroxBlock) {
		return 640;
	} else if (itemFuel == PyroxIngot.pyroxIngot) {
		return 160;
	} else {
		return 0;
	}
}
}

 

Which this works great if I want to enter multiple lines of code per item. I'd like to use an Array. Now I am not new to Java but I am to minecraft modding, what would I set this? I've tried standard approaches when it comes to creating the array but I cant seem to get it to call the item/block and the burn times and I'm not exactly sure why

 

1. What do you mean "enter multiple lines of code per item", you can add more code before the return statement in each case of the if loop.

2. What appraoches have you tried?

3. What do you mean "I cant seem to get it to call the item/block and the burn times"?

Don't make mods if you don't know Java.

Check out my website: http://shadowfacts.net

Developer of many mods

  • Author

for one the if/else statement is not a loop, but that's getting off topic, here is standard VERY basic string array.

String[] burnList;  
burnList = new String[1000];
burnLis[0] = item; 
burnLis[1] = item; 
burnLis[2] = item;

 

Now I would run through the array with a for LOOP.

 

for (int i = 0; i < burnList.length(); i++) { 
// if STATEMENTS go here
}

 

What I mean by multiple lines of codes is, which I should have clarified this, I do not want to add a bunch of "&&" in the if statement. If I can run 1 basic if statement and cycle through the array with a for loop to verify if an item can be used as fuel. Hope I'm making sense I am NO GOOD at explaining things through text.

If what you're trying to accomplish is making it easier to add furnace fuels, you could have an interface which you implement that requires a method like int getBurnTime(), then in the IFuelHandler you could check if the block/item is an instance of your interface, if so, cast it and return the burn time from getBurnTime().

 

A side note: Using your example you could use something like this to make it a little easier:

ArrayList<ItemStack> burnList = new ArrayList<ItemStack>();
for (ItemStack stack : burnList) {
    // do stuff...
}

Don't make mods if you don't know Java.

Check out my website: http://shadowfacts.net

Developer of many mods

  • 3 years later...

hello, im currently working in mc forge version "forge-1.12.2-14.23.4.2729-mdk"

the IFuelHandler has become 

deprecated

ive tried adding an array list, if/and/else/ore and case statements while using an interface which ive built based upon the information provided by forge. 

i can not for the life of me find a way to add fuel values to blocks and items...
i have deleted my interface and im trying something new by accessing the furnace code and now im really lost. could anyone help me a bit??

i would like to be able to use an array list where i can call the modded object and then set the burn time.

something like 

 

public static final List<Fuel> FUELS = new ArrayList<Fuel>();
//fuel/block or item name/new fuel (furnace burn time,can set fire in world)
//if its an item, if set to not burn in world, then the item will not be destroyed by lava or fire
//if its a block and set to burn in world, then it will be destroyed by fire and lava like wood.
public static final Fuel GENERIC_BLOCK = new FUELS(300,true){};
public static final Fuel GENERIC_ITEM = new FUELS(100,false){};

dont mind the comments, that is for ideas and hopeful future implimentations.

Edited by reapersremorse
i did not add all information in my paste

3 minutes ago, reapersremorse said:

the IFuelHandler has become

Please don't necropost and make your own topic. This thread will be locked by a moderator later.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.