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

Hello I tryed to generate json resources but GatherDataEvent is never called and idk why because it worked before and now it's not beeing called, there is no error in console.

 

DataGenerators.class

@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public class DataGenerators {

    @SubscribeEvent
    public static void gatherData(GatherDataEvent event) {
        DataGenerator generator = event.getGenerator();
        if (event.includeServer()) {
            generator.addProvider(new Recipes(generator));
            generator.addProvider(new LootTables(generator));
        }
    }
}

 

build.gradle

        data {
            workingDirectory project.file('run')

            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
            property 'forge.logging.console.level', 'debug'

            args '--mod', 'indreb', '--all', '--output', file('src/generated/resources/')

            environment 'target', 'fmluserdevdata'

            mods {
                indreb {
                    source sourceSets.main
                }
            }
        }

 

This is likely because the annotation cannot find / generate an instance of your class.  
Try to use an inner static class instead. Like this:  
 

public class DataGenerators {
    
    @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
    public static class GatherDataSubscriber {
        @SubscribeEvent
        public static void gatherData(GatherDataEvent event) {
            DataGenerator generator = event.getGenerator();
            if (event.includeServer()) {
                generator.addProvider(new Recipes(generator));
                generator.addProvider(new LootTables(generator));
            }
        }
    }
}

Or use DeferredRegister instead.

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

2 hours ago, Busti said:

Or use DeferredRegister instead.

 

DeferredRegister has nothing to do w/ it.

 

how do you run the data generator ?

They are subscribing to an event and the event is never called. That is an error that lies in the subscription, IMO and not in the code that is being executed.  
They could also place a println in their subscriber to see if the subscription worked.  
I have previously experienced relatively unpredictable behaviour when using @Mod.EventBusSubscriber on a top-level class. For some event types it works, for some it won't.  
DeferredRegister is a lot better than the annotation system IMO, it feels a lot less finicky. But it might be more complicated for new users, who do not have any FP experience. But that won't stop me from recommending it.  

Edit: I have not used GatherDataEvent or anything related to it yet. So if that's where the problem lies, I won't be able to help here. From the way the post was written it sounded like it was a subscription problem, which is why I replied.

Edited by Busti

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

  • 3 weeks later...

Hi! I had the same problem. I found out that the modid I put in build.gradle wasn't updating the one in the actual run config.

So look your run config and make sure the argument is indeed your modid.

Edited by mooviies

  • 1 year later...
On 3/9/2020 at 8:16 PM, mooviies said:

Hi! I had the same problem. I found out that the modid I put in build.gradle wasn't updating the one in the actual run config.

So look your run config and make sure the argument is indeed your modid.

I can confirm that this also solved the problem for me! In build.gradle there's a line for specifying the modid for data generation.

Just now, C J said:

I can confirm that this also solved the problem for me! In build.gradle there's a line for specifying the modid for data generation.

please create your own thread

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.