INTENSS Posted January 17, 2015 Posted January 17, 2015 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. Quote
INTENSS Posted January 18, 2015 Author Posted January 18, 2015 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 Quote
shadowfacts Posted January 18, 2015 Posted January 18, 2015 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"? Quote Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
INTENSS Posted January 18, 2015 Author Posted January 18, 2015 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. Quote
shadowfacts Posted January 18, 2015 Posted January 18, 2015 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... } Quote Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
reapersremorse Posted August 4, 2018 Posted August 4, 2018 (edited) 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 August 4, 2018 by reapersremorse i did not add all information in my paste Quote
Animefan8888 Posted August 4, 2018 Posted August 4, 2018 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. Quote 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.
reapersremorse Posted August 4, 2018 Posted August 4, 2018 ok thank you, i will go make a separate post. Quote
Recommended Posts
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.