Infinitas64 Posted August 9, 2022 Share Posted August 9, 2022 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! Quote Link to comment Share on other sites More sharing options...
warjort Posted August 9, 2022 Share Posted August 9, 2022 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. Quote 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. Link to comment Share on other sites More sharing options...
Infinitas64 Posted August 11, 2022 Author Share Posted August 11, 2022 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:( Quote Link to comment Share on other sites More sharing options...
Luis_ST Posted August 11, 2022 Share Posted August 11, 2022 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. Quote Link to comment Share on other sites More sharing options...
Infinitas64 Posted August 11, 2022 Author Share Posted August 11, 2022 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? Quote Link to comment Share on other sites More sharing options...
Infinitas64 Posted August 12, 2022 Author Share Posted August 12, 2022 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"? Quote Link to comment Share on other sites More sharing options...
Luis_ST Posted August 12, 2022 Share Posted August 12, 2022 (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): Edited August 12, 2022 by Luis_ST Quote Link to comment Share on other sites More sharing options...
Infinitas64 Posted August 12, 2022 Author Share Posted August 12, 2022 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. Quote Link to comment Share on other sites More sharing options...
Luis_ST Posted August 12, 2022 Share Posted August 12, 2022 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? Quote Link to comment Share on other sites More sharing options...
Infinitas64 Posted August 12, 2022 Author Share Posted August 12, 2022 (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 August 12, 2022 by Infinitas64 Quote Link to comment Share on other sites More sharing options...
Infinitas64 Posted August 12, 2022 Author Share Posted August 12, 2022 It seems that the method wasn't even used. Why is that? (since I'm new, maybe it's just some stupid problem) Quote Link to comment Share on other sites More sharing options...
Infinitas64 Posted August 12, 2022 Author Share Posted August 12, 2022 I've posted the whole directory at https://github.com/Infinitas64/forge-1.18.2-40.1.0-mdk. Quote Link to comment Share on other sites More sharing options...
Infinitas64 Posted August 12, 2022 Author Share Posted August 12, 2022 2 hours ago, diesieben07 said: Works fine here: I don't understand. Why?? Quote Link to comment Share on other sites More sharing options...
Infinitas64 Posted August 12, 2022 Author Share Posted August 12, 2022 Is it because I'm using 1.18? Quote Link to comment Share on other sites More sharing options...
Luis_ST Posted August 12, 2022 Share Posted August 12, 2022 (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 August 12, 2022 by Luis_ST Quote Link to comment Share on other sites More sharing options...
warjort Posted August 12, 2022 Share Posted August 12, 2022 (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 August 12, 2022 by warjort 1 Quote 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. Link to comment Share on other sites More sharing options...
Infinitas64 Posted August 13, 2022 Author Share Posted August 13, 2022 Thanks a lot. I've cloned the repository and now it works. Should I continue using the cloned repo? And thanks to all of you for enthusiasm to help! Quote Link to comment Share on other sites More sharing options...
Luis_ST Posted August 13, 2022 Share Posted August 13, 2022 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. Quote Link to comment Share on other sites More sharing options...
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.