Jump to content

Recommended Posts

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

 

Posted

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.

  • Confused 1

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

Posted (edited)

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...
Posted (edited)

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
  • Thanks 1
  • 1 year later...
Posted
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.

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

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