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

Recommended Posts

my mod has a "StructureManager" that overrides the ReloadListener <?> method. How do I register this listener correctly?
I created a Listener based on RecipeManager and saw that it registers to MinecraftServer. However, nothing works for me.
Here is an example of my registration code:

private void server(final FMLServerAboutToStartEvent event){

        LOGGER.info("SERVER ^>>>");

        event.getServer().getResourceManager().addReloadListener(structureManager);

}

Thank you in advance for your cooperation.

Link to post
Share on other sites
4 hours ago, poopoodice said:

Is the event being triggered? What's in your reload listener?

No, nothing starts. As I described the problem, I need a recipe file reloader. A very similar class -> RecipeManager. You gave a class that is not present in 1.15.2. How to be in this version?

Link to post
Share on other sites

The event you are using currently should be fine for 1.15.2. If it is not triggering, you are not registering it correctly. Show how you register your event handler.

Link to post
Share on other sites
3 hours ago, diesieben07 said:

The event you are using currently should be fine for 1.15.2. If it is not triggering, you are not registering it correctly. Show how you register your event handler.

public ArchitectsDream() {

        final IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();

        eventBus.addListener(this::commonRegistry);

        eventBus.addListener(this::clientRegistry);

        eventBus.addListener(this::server);

}

"clientRegistry" and "commonRegistry" work

Link to post
Share on other sites
On 5/9/2021 at 5:18 PM, diesieben07 said:

The event fires on the forge event bus.

Thank you more for your help, I don't even know how to thank you :)

However, in "gratitude" I would like to ask one more question.

The fact is that my Manager supports 3 types of files and for each I have my own deserializer. And this order of events does not quite fit in with the Forge ReloadListener, where the T type is essentially the file extension that is obtained after preparation. (like for example the same RecipeManager passes keys and JsonObject). In this case, is it better to inherit from IFutureReloadListener or can you do something differently?
(To put it simply, I wanted to say that the apply and prepare methods and the type T are not entirely appropriate and unnecessary).

I hope you understand what I mean :)

Link to post
Share on other sites

The ReloadListener is based on two stages. One that reads the files (happens asynchronously on a threadpool) and the actual loading (happens on the main thread). prepare is the first part, apply is the 2nd part.  You can make T whatever type you want. If you need to store three types of files, make T a POJO that has fields for all three.

Link to post
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.

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.



×
×
  • Create New...

Important Information

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