Jump to content

Is there a way to add something as fuel for the furnace using Minecraft Forge?


Recommended Posts

Posted

I'm here to ask how to develop a mod in which something (diamond, for example) can be added as fuel for the furnace like coal, since I couldn't find where to change the properties of original items in Minecraft.

My first attempt to make a mod, please help!

Posted

Subscribe to the FurnaceFuelBurnTimeEvent

You can find information about events (along with other information) here: https://forge.gemwire.uk/wiki/Main_Page

 

For your own items override getBurnTime() in your Item class.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted
On 8/9/2022 at 3:47 PM, warjort said:

Subscribe to the FurnaceFuelBurnTimeEvent

You can find information about events (along with other information) here: https://forge.gemwire.uk/wiki/Main_Page

 

For your own items override getBurnTime() in your Item class.

Thanks!

The website has a lot of useful information, but I don't quite understand why subscribing to this event can change an item's properties and how to do so. The concept 'Event' is quite hard to understand:(

Posted
1 hour ago, Infinitas64 said:

The website has a lot of useful information, but I don't quite understand why subscribing to this event can change an item's properties and how to do so.

Inside the Event you can set the burn time of an Item which is used by the furnace

1 hour ago, Infinitas64 said:

The concept 'Event' is quite hard to understand:(

To be simple, Events are called at some point x in the vanilla code and let you modify, change or register some stuff.
The event concept is actually quite simple since all Event work the same, you only need to understand how to use them.

Posted

Thanks.

@Mod.EventBusSubscriber(modid = "modid")
public class ModNameEvents {
    @SubscribeEvent
    public static void modifyFuelBurnTime(FurnaceFuelBurnTimeEvent event) {
        ItemStack stack = event.getItemStack();
        Item item = stack.getItem();
        if (item == DIAMOND) {
            event.setBurnTime(2560);
        }
    }
}

Why doesn't this work? Didn't I subscribe to the event?

Posted
20 hours ago, diesieben07 said:

That should work (assuming "DIAMOND" is a static import for net.minecraft.world.item.Items.DIAMOND). Is the method called? Check with the debugger.

That sure is what I imported.

What should the method be called? Is there a problem with my way of registering the event?

I'm currently using IntelliJ IDEA, how can I find the problem using "debug"?

Posted (edited)
2 hours ago, Infinitas64 said:

What should the method be called? Is there a problem with my way of registering the event?

I'm currently using IntelliJ IDEA, how can I find the problem using "debug"?

The debugger is a feature of your IDE, you can use it to debug code you create by putting a breakpoint at the code.
Then start the debugger (which starts the game), then do the stuff you want to test. In your case join a World and put a Diamound in the fuel slot of the Furnace.
If the code is called the game will stop running and the breakpoint will be marked (the IDE stops the code there).

I'm not familiar with IntelliJ IDEA but first of all you need to gen the launch configs via the gradle task genIntellijRuns.
You then can select them in Intellij. I know D7 post somewhere on Discord a image where you need to run them (found it):

unknown.png

Edited by Luis_ST
Posted
3 minutes ago, Luis_ST said:

The debugger is a feature of your IDE, you can use it to debug code you create by putting a breakpoint at the code.
Then start the debugger (which starts the game), then do the stuff you want to test. In your case join a World and put a Diamound in the fuel slot of the Furnace.
If the code is called the game will stop running and the breakpoint will be marked (the IDE stops the code there).

I'm not familiar with IntelliJ IDEA but first of all you need to gen the launch configs via the gradle task genIntellijRuns.
You then can select them in Intellij. I know D7 post somewhere on Discord a image where you need to run them, i will search for this image and edit this post if i found it.

Thanks a lot. I tried debugging but it didn't even hit the breakpoint, while the diamond cannot be put into the fuel slot.

I suppose the problem may be because the structure of my code? Still trying to find a way to solve that.

Posted
1 minute ago, Infinitas64 said:

Thanks a lot. I tried debugging but it didn't even hit the breakpoint, while the diamond cannot be put into the fuel slot.

In which line did you put the breakpoint?

Posted (edited)
6 minutes ago, Luis_ST said:

In which line did you put the breakpoint?

Here, 

23 hours ago, Infinitas64 said:
public class ModNameEvents {

here,

23 hours ago, Infinitas64 said:
    public static void modifyFuelBurnTime(FurnaceFuelBurnTimeEvent event) {

and here.

23 hours ago, Infinitas64 said:
        if (item == DIAMOND) {
Edited by Infinitas64
Posted (edited)
39 minutes ago, Infinitas64 said:

Is it because I'm using 1.18?

The version does not matter, since if we clone your repo it's always 1.18.

Did you tried a new World?

Edited by Luis_ST
Posted (edited)

You should try cloning your own repository to a different folder then seeing if that works.

It's likely the stuff in your real folder doesn't match what is on github in some important way.

Try running a "git diff" and "git status" to see if there are uncommitted changes.

Edited by warjort
  • Thanks 1

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted
8 hours ago, Infinitas64 said:

Should I continue using the cloned repo?

If there are no changes in the main repo you can continue with this repo, if there are changes you need to compare the repos.

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.