Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

IFuelHandler deprecated??


reapersremorse
 Share

Recommended Posts

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.

 

any help would be most welcomed.

Link to comment
Share on other sites

1 minute ago, reapersremorse said:

any help would be most welcomed.

If you were to look at GameRegistry.addFuelHandler it would point you to Item#getItemBurnTIme which is a method you need to override in your Item class.

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.

Link to comment
Share on other sites

GameRegistry.addFuelHandler does not exist in my dev environment ive seen a lot of tutorials referring to this but i believe its for an older version of forge because i can not find it anywhere.


im modding for minecraft version 1.12.2 with forge version "forge-1.12.2-14.23.4.2729-mdk"

 

i only find information in the FurnaceFuelBurnTimeEvent.java
 

public class FurnaceFuelBurnTimeEvent extends Event
{
    @Nonnull
    private final ItemStack itemStack;
    private int burnTime;

    public FurnaceFuelBurnTimeEvent(@Nonnull ItemStack itemStack, int burnTime)
    {
        this.itemStack = itemStack;
        this.burnTime = burnTime;
    }

when i try to find the information on FuelHandeler, it brings me to the deprecated class called IFuelHandler

Link to comment
Share on other sites

2 minutes ago, reapersremorse said:

im modding for minecraft version 1.12.2 with forge version "forge-1.12.2-14.23.4.2729-mdk"

Yes I understand, and that is why I said this.

26 minutes ago, Animefan8888 said:

Item#getItemBurnTIme which is a method you need to override in your Item class.

 

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.

Link to comment
Share on other sites

ive implemented this in my item class, it would seem if i wish to do this, i will have to add a class for every block or item that i wish to have a fuel value.
 

@Override
public int getItemBurnTime(ItemStack itemStack)
{
    return 200;
}

i use my item class as a prefab class so every item in my mod uses the same class. now they all have a burn value of 200. i was trying not to go this rout but if i have to make a custom class for ever burn value item then i will.

i tried setting a variable and calling within the super as a function but that would not work.

if i could get this to work in the super then i could set the burn value along with all the other information that i set dynamically.

thank you for all the help so far.

2018-08-04_16.52.44.png

Link to comment
Share on other sites

{
    //Creating the variables
    String name;
    int maxUses;
    int harvestLevel;
    float efficiency;

    public BasicItemPrefab
            (
                    String name,
                    int maxUses,
                    String tool,
                    int toollevel,
                    int stacksize,
                    int BurnTime

            )
    {
        super();
        setUnlocalizedName(name);
        setRegistryName(name);
        setMaxStackSize(1);
        setCreativeTab(UTOTabs.UTOItems);//sets creative tab, change later
        //setDamage(,);
        setMaxDamage(maxUses);
        setHarvestLevel(tool,toollevel);
        setMaxStackSize(stacksize);
        BasicItemRegistry.ITEMS.add(this);
        getItemBurnTime(BurnTime);
        //Assigning value to these variables
        //this.name = Material.();
        //this.maxUses = Material();
        //this.harvestLevel = Material();
        //this.efficiency = Material.getEfficiency();
        


        BasicItemRegistry.ITEMS.add(this);
    }
    int BurnTime;
    @Override
    public int getItemBurnTime(ItemStack itemStack)
    {
        return BurnTime;
    }
    @Override
    public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
        //Making the tooltips
        //For colors use for example: tooltip.add("Max Uses: " + TextFormatting.BLUE + maxUses);
        tooltip.add("Name: " + TextFormatting.LIGHT_PURPLE +name);
        tooltip.add("Max Uses: " + TextFormatting.LIGHT_PURPLE +maxUses);
        tooltip.add(TextFormatting.BLACK +"=========");
        tooltip.add("Harvest Level: " + TextFormatting.BLUE +harvestLevel);
        tooltip.add(TextFormatting.BLACK +"=========");
        tooltip.add("Efficiency: " + TextFormatting.RED +efficiency);
    }
    @Override
    public void registerModels(){UTOMod.proxy.registerItemRenderer(this,  0, "inventory");}
}

i must be an idiot, i cant get the variables to work together properly in the methods. i probibly just need to sleep. this problem has made me feel like an idiot for far too long

Link to comment
Share on other sites

2 minutes ago, reapersremorse said:

i probibly just need to sleep.

Probably

2 minutes ago, reapersremorse said:

getItemBurnTime(BurnTime);

Your IDE should be saying that this is an error because getItemBurnTime takes an ItemStack not an int.

3 minutes ago, reapersremorse said:

int BurnTime

And this is a local variable instead of a class field. This should be returned in getItemBurnTime.

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.

Link to comment
Share on other sites


 

if i set the Burntime within this override, it complains and says it needs an int
 

@Override
public int getItemBurnTime(ItemStack itemStack)
{
    return Burntime;
}

but the super needs an itemstack

public class BasicItemPrefab extends Item implements IHasModel

{
    //Creating the variables
    String name;
    int maxUses;
    int harvestLevel;
    float efficiency;
    public ItemStack BurnTime;

    public BasicItemPrefab
            (
                    String name,
                    int maxUses,
                    String tool,
                    int toollevel,
                    int stacksize,
                    ItemStack BurnTime

            )
    {
        super();
        setUnlocalizedName(name);
        setRegistryName(name);
        setMaxStackSize(1);
        setCreativeTab(UTOTabs.UTOItems);//sets creative tab, change later
        //setDamage(,);
        setMaxDamage(maxUses);
        setHarvestLevel(tool,toollevel);
        setMaxStackSize(stacksize);
        BasicItemRegistry.ITEMS.add(this);
        getItemBurnTime(BurnTime);
        //Assigning value to these variables
        //this.name = Material.();
        //this.maxUses = Material();
        //this.harvestLevel = Material();
        //this.efficiency = Material.getEfficiency();



        BasicItemRegistry.ITEMS.add(this);
    }
    @Override
    public int getItemBurnTime(ItemStack itemStack)
    {
        return Burntime;//this keeps throwing an error
    }
    @Override
    public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
        //Making the tooltips
        //For colors use for example: tooltip.add("Max Uses: " + TextFormatting.BLUE + maxUses);
        tooltip.add("Name: " + TextFormatting.LIGHT_PURPLE +name);
        tooltip.add("Max Uses: " + TextFormatting.LIGHT_PURPLE +maxUses);
        tooltip.add(TextFormatting.BLACK +"=========");
        tooltip.add("Harvest Level: " + TextFormatting.BLUE +harvestLevel);
        tooltip.add(TextFormatting.BLACK +"=========");
        tooltip.add("Efficiency: " + TextFormatting.RED +efficiency);
    }
    @Override
    public void registerModels(){UTOMod.proxy.registerItemRenderer(this,  0, "inventory");}
}

it keeps throwing an error, illegal start of expression. in my item reg class

public static final Item BASE_HAMMER = new BasicItemPrefab
        ("base_hammer",-1,"base_multi_tool",0,1,200);//200 is the burntime that keeps asking for an itemstack.
Link to comment
Share on other sites

An ItemStack is passed to getItemBurnTime. You need to compare the itemstack's item to see if it's yours.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

23 minutes ago, reapersremorse said:

sorry im really not great with java, ive been learning while making this mod.wish i had more time off work.

public class ItemExample extends Item {
	
private int burnTime; // This is a field/variable created in a class not a local field/varaible. 
// You should take an int into your constructor that allows that this field is set to. 
// And then override getItemBurnTime and return this value
  
}

 

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.

Link to comment
Share on other sites

public class TestingItemClass extends Item implements IHasModel
{ //Creating the variables
    String name;
    private int BurnTime;
    /*
    i have my variable BurnTime set to a private int
    when i try to use this in my constructor below, the variable will not talk to it. 
    i need an ItemStack in the constructor.
    but when i set the @Override portion, it needs an int because its returning an int.
    
     */
    public TestingItemClass
            (
                    String name,
                    int BurnTime//does not work, if i change to ItemStack,
                    // i cant set int value in my registry, it asks for an itemstack 
                    // and when i try to set an itemstack it complains that i need the itemstack and another
            )
    { //when i try to add anything to the super, it complains about the
        super();
        setUnlocalizedName(name);
        setRegistryName(name);
        setCreativeTab(UTOTabs.UTOItems);
        getItemBurnTime(i have no clue what goes here now);//i tried converting to int and ItemStack, neither work when i input info
        BasicItemRegistry.ITEMS.add(this);
    }
    @Override public int getItemBurnTime(ItemStack itemStack){return BurnTime;}
    //the code above this comment uses an int because the ItemStack has been transformed into an int
    @Override public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) { tooltip.add("This is a basic item test item");}
    @Override public void registerModels(){UTOMod.proxy.registerItemRenderer(this,  0, "inventory");}
}
Link to comment
Share on other sites

21 hours ago, Draco18s said:

An ItemStack is passed to getItemBurnTime. You need to compare the itemstack's item to see if it's yours.

 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

25 minutes ago, diesieben07 said:

I don't know where you got this from, but this is not true.

It must be leftover/obsolete code in my own mod, then. Because I know that at one point it was necessary.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

@diesieben07
first of all, i stated that im learning java while making this mod, second i tried that and it did not work. the game will not load it and when i add it correctly. it will give all my items the same burn value. that is why im trying to set it in my constructor. that is why im doing this in a way that makes no since. nevertheless im still trying, you only gain knowledge from experience and the tutorials for java are way too boring for me. ive learned mountains more while making this mod then i ever did while watching those tutorials and reading books. im not able to soak up the knowledge without doing something that is entertaining.

and now that is out, i found a way to add the fuel values without adding to my items or block prefab classes. 
i enter a line in my main class under the init and it adds the value to the object within the game.

 

{@Override public int getBurnTime(ItemStack fuel){if(Item.getItemFromBlock(BasicBlockRegistry.BASE_BLOCK) == fuel.getItem())return 16000;return 0;}});}

 

in the game this makes it so my BASE_BLOCK has a burn value of 16000, same as coal block.

 

itried to make a class outside of here to deal with this but when i do, it keeps argueing with me over the depracated classes used 
Warning:(14, 37) java: net.minecraftforge.fml.common.IFuelHandler in net.minecraftforge.fml.common has been deprecated

 

this works but only when i use the depracated class within my init within my main class

if i try this or anything revolved around adding a fuel in another class without directly stating what int to return, the mod will not run.

just too restate i can use this in any class.
 

@Override public int getItemBurnTime(ItemStack itemStack){return 16000;}

 

but when i try to compare and convert from itemstack to int and dynamically call and set the int within another class.

 

the game will not run and the game tells me exactly what you are saying but i cant get it to work that way without information i apparently do not know because i am not knowledgeable enough

 

i must reiterate that the line of code ive added to my init in the main class is the only way ive been able to give any specified item or block a burn value without adding the same burn value to every item that the class is used for.
 

Link to comment
Share on other sites

6 minutes ago, reapersremorse said:

i stated that im learning java while making this mod

Great. Learning to drive a car while driving a bus of children around is an equally good way to learn.

 

7 minutes ago, reapersremorse said:

it will give all my items the same burn value

Then you passed the same value to all the constructors.

 

7 minutes ago, reapersremorse said:

{@Override public int getBurnTime(ItemStack fuel){if(Item.getItemFromBlock(BasicBlockRegistry.BASE_BLOCK) == fuel.getItem())return 16000;return 0;}});}

This is ugly as all hell.

 

7 minutes ago, reapersremorse said:

itried to make a class outside of here to deal with this but when i do, it keeps argueing with me over the depracated classes used 
Warning:(14, 37) java: net.minecraftforge.fml.common.IFuelHandler in net.minecraftforge.fml.common has been deprecated

 

this works but only when i use the depracated class within my init within my main class

This is not helpful. Post code if you have errors.

Link to comment
Share on other sites

6 minutes ago, diesieben07 said:

Then you passed the same value to all the constructors.

 

i understand that, i was trying to get around that in the first place. i tried setting the constructor to look at a variable. the variable was not working as ive shown in past posts. 

 

8 minutes ago, diesieben07 said:

This is not helpful. Post code if you have errors.

this whole post is fool of code, showing the reason why i could not do what you told me to do. the closest ive gotten to comparing an item with my items or even setting a value to each item would be the code you referred to as ugly.

9 minutes ago, diesieben07 said:

This is ugly as all hell.

i know it is ugly, but i got it to work, 

 

i was using the class below inorder to add my fuels when i started this, i just rewrote it. i stopped using this because i couldnt call items.
i created this class because i feel i have no other option. i do not want to use the IFuelHandler because its depracated. 
this only works for blocks, it will not use my items

 

this is the class that has the issues, but the issues happen because of the fuel handler. the fuel handler is deprecated.
nothing i try works to add items without directly adding them to my main class like i showed you and you said 

3 hours ago, diesieben07 said:

This is ugly as all hell.

well this is the class that i cant get to work, this is the class that made me go to this forum. this is the class that im having trouble with. ugly or not, this class is broken but only partially. i can give any block a fuel value. but when i try to add an item, it will not work. the code shows no signs of being in error for the items.

the only error i get while adding fuel values is the error involving 
Warning:(7, 37) java: net.minecraftforge.fml.common.IFuelHandler in net.minecraftforge.fml.common has been deprecated
Warning:(16, 43) java: net.minecraftforge.fml.common.IFuelHandler in net.minecraftforge.fml.common has been deprecated

Warning:(16, 18) java: registerFuelHandler(net.minecraftforge.fml.common.IFuelHandler) in net.minecraftforge.fml.common.registry.GameRegistry has been deprecated

 

line 7 is the import

line 16 is {GameRegistry.registerFuelHandler(new IFuelHandler()

public class FurnaceFuels
public static void FurnaceFuelsGameRegistryregisterFuelHandlernew IFuelHandler@Override public int getBurnTime
                        ItemStack //only the blocks work
                    if ItemgetItemFromBlockBasicBlockRegistryBASE_BLOCKreturn 16000;//works
                    else if ItemgetItemFromBlockBasicBlockRegistryBASE_BRICKreturn 100;//works
                    else if ItemgetItemFromBlockBasicBlockRegistryBASE_BLOCK_GLASSreturn 200;//works
                    //i have tried to add items, i can not get it to work.
                    else if ItemgetByNameOrId"uto:base_ingot"return 1600;//does not work
                    else if ItemgetByNameOrId"4523"return 400;//does not work
                    else if BasicItemRegistryCRAFTING_ITEM return ;//does not work
                    //else if (Item.getIdFromItem() == fuel.getItem()) return 32;//does not work at all
                    return 0;
                ;
    

 

by all intensive purposes, this code should work for the items but it only works when i get getItemFromBlock.

Link to comment
Share on other sites

Make a github, the formatting is unreadable here. Consider also using an autoformatter.

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

10 minutes ago, reapersremorse said:

for some reason when i pasted the code, it did not copy the parenthesis and a few other things. this image is the class itself

Why are you still using the deprecated IFuelHandler?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

17 minutes ago, Draco18s said:

Why are you still using the deprecated IFuelHandler?

Have we given him an alternative?

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

4 minutes ago, Cadiboo said:

Have we given him an alternative?

thank you, i honestly do not know another way to do it. when i tried to access the furnace class that handles fuel, this is all i could do.

 

im just an idiot and im trying to learn while i make. but ive learned so much more while making this mod than i ever did when watching/reading and making those boring args classes.....

 

 

im setting up mu github. i messed it up because i have more than 100 files...

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

 Share




×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.