Jump to content

Recommended Posts

Posted

Yes, sort of.  The FML lifecycle events are for this.  First all the mods go thorugh pre-init, then through init, and then through post-init.

 

So in the init handler you can be confident that all mods have gone through their pre-init, and so forth.

 

I think by the time you get to the server started event you can be sure that they are all loaded.  Anyway play with the FML life cycle events.  I describe them a bit in my events tutorial: http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-event-handling.html

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

@jabelar, no. There is no AllModsLoadedEvent. Please don't confuse people when a specific question was asked.

Such an event would have to be fired after all mods have finished FMLPostInitialization.

 

Anyways, thank you for explaining the FML lifecycle events which I'm pretty sure the poster knows about at least PreInit, Init, and PostInit anyways.

Posted

@jabelar, no. There is no AllModsLoadedEvent. Please don't confuse people when a specific question was asked.

Such an event would have to be fired after all mods have finished FMLPostInitialization.

 

Anyways, thank you for explaining the FML lifecycle events which I'm pretty sure the poster knows about at least PreInit, Init, and PostInit anyways.

 

I know about preInit and Init but I didn't know about PostInit which might do what I want.

 

Hi

 

As you might have guessed from the two posts above, we're not quite sure what you mean by "loaded".

 

What are you trying to do, exactly?

 

-TGG

 

I want to loop through all the available recipes (crafting recipes, furnace recipes, recipe systems of other mods like Buildcraft's Assembly Table, etc...) and sort them according to owning mod. My end goal is to recreate my Resource Calculator as a mod rather than as a website I need to keep maintaining.

I like trains.

Posted

Hi

 

In that case, I reckon there's a good chance that putting that code into PostInit will work, as Jabelar suggested.  Recipes are supposed to be all registered in Init.

From the forge docs...

 

 

PreInitialization - "Run before anything else. Read your config, create blocks, items, etc, and register them with the GameRegistry."

Initialization - "Do your mod setup. Build whatever data structures you care about. Register recipes."

PostInitialization -  "Handle interaction with other mods, complete your setup based on this.

 

-TGG

 

 

Posted

Cool. I was looking at your tutorial and I saw there's events for the server starting and stopping but is there an event for the game (client-side) shutting down? I want to have a built-in HTTP server using netty and I want it running as long as the player has Minecraft running, not necessarily connected to a server.

I like trains.

Posted

@jabelar, no. There is no AllModsLoadedEvent. Please don't confuse people when a specific question was asked.

Such an event would have to be fired after all mods have finished FMLPostInitialization.

 

Actually a specific question was not asked.  You assumed what "loaded" meant, and I gave them options to choose from.  Most people asking about "loaded" have something in mind, and based on the further conversation on this thread, the original poster did not in fact understand that the FML events indicated the state of the various mods loading.

 

In fact there is a FMLLoadCompleteEvent, although I'm not sure it registers to a general event bus or not.  But the LoaderState has an enum of AVAILABLE when all modes are loaded.

 

I'd like to also add that you can (mostly) control the order of the mod loading using the @Mod annotation attribute dependencies = "after:FileName".  I think you can specify that your mod loads after all, but of course if multiple mods did that then I'm not sure you could be fully sure.  But anyway, in the post init, if you made your mod load last, you could be pretty confident that all the mods had done their loading.

 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

You are right about what he wanted to know.

 

There is a caveat to assuming, however, that catching PostInit event means all mods loaded will be available. Since other mods (without forcing your mod to always be last) may still fail during PostInit, you cannot assume the system has stabilized on a set of mods at that point.

 

This is what I imagined the author of the post wanted to know. And the answer is indeed, you cannot know for certain.

Posted

So is there an event of some sort that's triggered when the game itself is shutting down that works client side?

 

That's an interesting question.  There is a server stopping event and a server stopped event, but I'm not sure what that does when you're a client only.  You might still want to try it.

 

I guess it depends on what you specifically want to do.  I mean the client can be stopped in a number of ways, including just hitting the window close to force it to shut down.

 

For example, if you just want to know when a player returns to the main menu, I think you can do that by handling the gui open event and checking for the main menu, or something like that.

 

What exactly do you mean by "game itself is shutting down"?

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

You are right about what he wanted to know.

 

I find that most of the time, people don't ask the question in the way that they need, otherwise they probably would have figured out the solution themselves!  It's like all the forum posts that say "how do you edit base classes" when they mean they just want to change the drops for an entity, etc.  If a person knew to ask: what event do I need to handle to change drops of a living entity, they probably would have found the LivingDropsEvent themselves...

 

So I usually supply people with information "around" the question they asked.

 

But back to your question you're certainly right that you can never be sure that other mods have honored the pre-init, init, and post-init in a way that you can trust.

 

I was looking at this further, and it seems that you can actually poll the FMLClientLoader.isLoading() function.  It returns a boolean called loading which goes to false at the very end of the post-init and in fact happens right around the message in the console that says "Forge Mod Loader has successfully loaded x mods".

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Actually, I think I just found a way to detect when all the mods are loaded!  Right at the point when they are all finished.

 

The new gui factory stuff for enabling the config guis calls the initialize() method for your guifactory right after all the mods are loaded in the finishMinecraftLoading() method in the FMLClientHandler class.  So if you register a gui factory, whatever you do in the initialize() method will be performed right at the moment when all mods are finished loading!

 

Ta da!

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted
What exactly do you mean by "game itself is shutting down"?

 

Clicking "Quit Game" on the main title or clicking the X on the top right corner of the window. I want to start an HTTP server when the game starts and then safely shut it down when the game closes.

I like trains.

Posted

Well I'm using Netty which doesn't push the listening socket onto another thread, but I know how to deal with threads so that's trivial. I'll look into shutdown hooks.

 

[Edit]

 

Yup a shutdown hook will work. Thanks.

I like trains.

Posted

Use postInit and if you have a specific mod that does things in postInit and you need your things to run after that use the dependencies property from the @Mod annotation.

 

That is actually my first suggestion, but Sequiteri didn't like the fact you couldn't make it generic (i.e. if you truly wanted all mods loaded, including ones you didn't know you needed to depend on).

 

First of all: Absolute ugly hack and also only works on the client.

 

The OP already established they were interested on the client side which is why I considered it a suitable suggestion.

 

I also don't think this is an "ugly hack".  It is really a nice hook, just like any other forge hook: basically there is a method call at exactly the right point that is meant for you to have full control over.  It seems pretty elegant to me because it is being used for exactly the same purpose -- the gui factory wants to know when all mods are loaded, just like we're trying to solve for.

 

Anyway, this is obviously academic because what the OP wants to achieve doesn't seem to really need such specific "all mods loaded" solution.

 

 

 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.