Jump to content

Debugging Core Mod


FlameAtronach93

Recommended Posts

Hello Minecraft Forge community!

 

It is fairly easy to debug a regular mod in Eclipse. Just hit the Debug button and off you go. However, I couldn't quite figure out how to debug core mods... Also I couldn't find any tutorials on the topic, so I'm stuck with exploring FML's and other mods' source codes.

 

I thought putting a MANIFEST.MF file in the META-INF directory in the project root would suffice my need, but it didn't recognize the mod.

 

Any help / suggestions? Without this core mod, it would be pretty hard to further develop my experimental feature...

 

The main reason why I even need to create a core mod is to inject some function calls / events into the RenderBlocks class. Would be cool if Forge included those anyways... right before and right after a block is rendered. In a nutshell, I am using it to overwrite the block textures of certain flagged sides of blocks. A nice little camouflage feature as I see it... would be a pity if I had to resort to workarounds like using an additional block.

 

Sincerely, Flame

Link to comment
Share on other sites

Why exactly do you need to debug? Do you mean that your coremod isn't loading?

If you mean it's not loading in debug mode, then yes, it's not loading.

 

Well, I like to develop and test my programs in the IDE. I haven't tried yet whether it even loads up in regular Minecraft. Sure I could do it that way too, but I'd like to know if it is possible to get it to run in the IDE, especially since it's much quicker and easier when resolving problems since I don't always have to log a lot of information, recompile, and re-obfuscate all the time. It's just about convenience at this point. ;)

Link to comment
Share on other sites

Why exactly do you need to debug? Do you mean that your coremod isn't loading?

If you mean it's not loading in debug mode, then yes, it's not loading.

 

Well, I like to develop and test my programs in the IDE. I haven't tried yet whether it even loads up in regular Minecraft. Sure I could do it that way too, but I'd like to know if it is possible to get it to run in the IDE, especially since it's much quicker and easier when resolving problems since I don't always have to log a lot of information, recompile, and re-obfuscate all the time. It's just about convenience at this point. ;)

I've never used Debug myself. What exactly does it do?

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Link to comment
Share on other sites

To load your coremod in MCP, you need to make a dummy jar file, put that /META-INF/MANIFEST.MF in that and shove the jar into the /mcp/jars/coremods folder.

Here's my dummy jar, if you want to inspect that: https://dl.dropboxusercontent.com/u/56920617/SAP_ManPackCore_v100_dummy.jar

 

Why exactly do you need to debug? Do you mean that your coremod isn't loading?

If you mean it's not loading in debug mode, then yes, it's not loading.

 

Well, I like to develop and test my programs in the IDE. I haven't tried yet whether it even loads up in regular Minecraft. Sure I could do it that way too, but I'd like to know if it is possible to get it to run in the IDE, especially since it's much quicker and easier when resolving problems since I don't always have to log a lot of information, recompile, and re-obfuscate all the time. It's just about convenience at this point. ;)

I've never used Debug myself. What exactly does it do?

 

In eclipse, it lets you change code in classes and you will immediately see the result, except you add/delete/rename a method, field or class.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

To load your coremod in MCP, you need to make a dummy jar file, put that /META-INF/MANIFEST.MF in that and shove the jar into the /mcp/jars/coremods folder.

Here's my dummy jar, if you want to inspect that: https://dl.dropboxusercontent.com/u/56920617/SAP_ManPackCore_v100_dummy.jar

 

Why exactly do you need to debug? Do you mean that your coremod isn't loading?

If you mean it's not loading in debug mode, then yes, it's not loading.

 

Well, I like to develop and test my programs in the IDE. I haven't tried yet whether it even loads up in regular Minecraft. Sure I could do it that way too, but I'd like to know if it is possible to get it to run in the IDE, especially since it's much quicker and easier when resolving problems since I don't always have to log a lot of information, recompile, and re-obfuscate all the time. It's just about convenience at this point. ;)

I've never used Debug myself. What exactly does it do?

 

In eclipse, it lets you change code in classes and you will immediately see the result, except you add/delete/rename a method, field or class.

Now, that seems handy. That would make logging a whole lot easier. I should use that.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Link to comment
Share on other sites

To load your coremod in MCP, you need to make a dummy jar file, put that /META-INF/MANIFEST.MF in that and shove the jar into the /mcp/jars/coremods folder.

Here's my dummy jar, if you want to inspect that: https://dl.dropboxusercontent.com/u/56920617/SAP_ManPackCore_v100_dummy.jar

 

Why exactly do you need to debug? Do you mean that your coremod isn't loading?

If you mean it's not loading in debug mode, then yes, it's not loading.

 

Well, I like to develop and test my programs in the IDE. I haven't tried yet whether it even loads up in regular Minecraft. Sure I could do it that way too, but I'd like to know if it is possible to get it to run in the IDE, especially since it's much quicker and easier when resolving problems since I don't always have to log a lot of information, recompile, and re-obfuscate all the time. It's just about convenience at this point. ;)

I've never used Debug myself. What exactly does it do?

 

In eclipse, it lets you change code in classes and you will immediately see the result, except you add/delete/rename a method, field or class.

Now, that seems handy. That would make logging a whole lot easier. I should use that.

 

I agree to that... I was wondering how one would go about his :P

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

I agree to that... I was wondering how one would go about his :P

 

And that was exactly my point. :P I couldn't find any hints in the FML source code yet. Still searching for why it even loads mods from memory in the workspace, maybe I can find something relevant there...

 

I managed to separate my code from the minecraft project into a new project, should anyone be interested. It creates the entire Minecraft directory structure in your new project though, but it's quite useful when developing several mods I think.

Link to comment
Share on other sites

I agree to that... I was wondering how one would go about his :P

 

And that was exactly my point. :P I couldn't find any hints in the FML source code yet. Still searching for why it even loads mods from memory in the workspace, maybe I can find something relevant there...

 

I managed to separate my code from the minecraft project into a new project, should anyone be interested. It creates the entire Minecraft directory structure in your new project though, but it's quite useful when developing several mods I think.

 

Pahimar already does that xD that is the way he teaches to set up the workspace, except it only needs one minecraft directory :D

 

And how do you even go about building a core mod anyway? I know I have made one that doesn't do anything... but it didn't load in MC... And I couldn't figure out why :/

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

Pahimar already does that xD that is the way he teaches to set up the workspace, except it only needs one minecraft directory :D

 

And how do you even go about building a core mod anyway? I know I have made one that doesn't do anything... but it didn't load in MC... And I couldn't figure out why :/

 

I'm quite new to these forums as you can deduce from my post counter, I'll look into his method and probably adapt to using it. I couldn't find any solution on the Internet when I searched for it, so I made my own. :P

 

Edit: Couldn't find it... any leads since you pointed it out? :S

 

I've been browsing the FML source for a while now and found that there are two relevant classes:

  • cpw.mods.fml.common.Loader
  • cpw.mods.fml.relauncher.RelaunchLibraryManager

 

The first loads regular mods from either the MC class path or the mods directory in the MC root. The reason why it loads up from Eclipse is because it also supports loading MC from directories and in Eclipse, all sources are class files in directories. So it regards your mod as part of the MC classpath.

 

The second is what we need to load a core mod. The method

discoverCoreMods

is called respectively. Exploring the code, one can find that it only accepts .jar files, not even .zip files, with a single obligation: it must have a Manifest File that has the key

FMLCorePlugin
.

 

Well, sucks, because this means it maybe is only possible to load it up from the IDE if we compile the sources into a jar and place it in the coremods directory there. Which actually is quite convenient with my workspace setup since every project comes with its own coremods directory... anywho!

 

I'll try it out and give you feedback.

 

About your coremod, does it dump any exceptions? o: Have you met all the requirements for a coremod? That's pretty much one of the reasons why I'm trying to load it up in the development environment...

 

 

Final edit:

 

I got it to work. This is how I've done it:

[*]Create a class that implements "IFMLLoadingPlugin"

[*]Create a MANIFEST.MF file with the following contents:

Manifest-Version: 1.0

FMLCorePlugin: <class_you_just_created_including_namespace>

 

The final blank line is required in order to recognize the last attribute. Without that attribute, FML will ignore the coremod.

[*]Use File -> Export -> Java -> JAR file to create an unobfuscated .jar archive from your code and put it in your IDE's coremod directory.

[*]Update JAR entry "META-INF/MANIFEST.MF" as Eclipse overrides it during compilation.

 

Edit: It broke my markup!! O: Fixed it.

Tell me if it works for you. :S

Link to comment
Share on other sites

Edit: Couldn't find it... any leads since you pointed it out? :S

 

try this:

[EDIT oops forgot the link xD]

 

About your coremod, does it dump any exceptions? o: Have you met all the requirements for a coremod? That's pretty much one of the reasons why I'm trying to load it up in the development environment...

 

No. All I was trying to do was make a core mod that did nothing, just so I could then build from there xD

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

Edit: Couldn't find it... any leads since you pointed it out? :S

 

try this:

[EDIT oops forgot the link xD]

 

About your coremod, does it dump any exceptions? o: Have you met all the requirements for a coremod? That's pretty much one of the reasons why I'm trying to load it up in the development environment...

 

No. All I was trying to do was make a core mod that did nothing, just so I could then build from there xD

 

Oh, that explains it. I was searching these forums to find something by him. The search script aborted after 30 seconds. ;)

 

Anywho, check out the update of my previous post. I got something to work. It's loading up now, but crashing since I forgot to update some text references to classes... :P I'll look at Pahimar's way to set up the IDE and adapt this way to debug coremods where necessary.

 

Cheers!

Link to comment
Share on other sites


I got it to work. This is how I've done it:

  1. Create a class that implements "IFMLLoadingPlugin"

[*]Create a MANIFEST.MF file with the following contents:

Manifest-Version: 1.0
FMLCorePlugin: <class_you_just_created_including_namespace>


  • The final blank line is required in order to recognize the last attribute. Without that attribute, FML will ignore the coremod.
  • Use File -> Export -> Java -> JAR file to create an unobfuscated .jar archive from your code and put it in your IDE's coremod directory.
  • Update JAR entry "META-INF/MANIFEST.MF" as Eclipse overrides it during compilation.

 

Tell me if it works for you. :S

 

Ill try it, cheers mate!

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

Edit: Couldn't find it... any leads since you pointed it out? :S

 

try this:

[EDIT oops forgot the link xD]

 

Took a look at the video and it turns out that my approach was quite similar. ;)

 

What I meant with "overhead" was that the entire directory structure of Minecraft would be created in your project. Forge would download the libraries, create log files and everything in the project root, etc. Other than that, my solution imported the Start class of Minecraft and simply redirected the invokation of the entry point to the Start class' one.

 

I even set Minecraft as a dependency project, so it really only differs in the debugging configuration. :P Still like his new solution better, especially since all redundant dependencies and all that stuff would be hidden...

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



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.