Jump to content

Interfacing mod power systems


Reika

Recommended Posts

I want to make an interface between my mod's power system and BuildCraft's MJ system. However, I have no idea how to do this.

I have dug into other mods' code, but they all seem to hardcode everything, using reflection to fetch classes, then variables, then values. To me, this seems like a stupid idea, as as soon as anything in the target mod changes, I need to rewrite my system.

 

Is there a better way? Note: I need full control over things like conversion ratio and behavior of converting machine. Ideally with my own TileEntity that takes in my power (already done) and produces MJ.

Link to comment
Share on other sites

https://github.com/BuildCraft/BuildCraft/tree/master/common/buildcraft/api/power

 

Maybe you should start by taking a look at the BuildCraft API. Hint: implement IPowerProvider

 

How can I use any of its classes directly without making them required for my mod to compile (and therefore making RotaryCraft dependent on BuildCraft)?

Link to comment
Share on other sites

Import the API into your environment, then configure ant builds to exclude BuildCraft API packages and files.

 

For a peek at ant build configuration, look at pretty much any popular mod. A good mod to look at is EE-3, Pahimar has quite wonderfully documented how to use Ant. Start here, and follow the instructions.

Link to comment
Share on other sites

Import the API into your environment, then configure ant builds to exclude BuildCraft API packages and files.

 

For a peek at ant build configuration, look at pretty much any popular mod. A good mod to look at is EE-3, Pahimar has quite wonderfully documented how to use Ant. Start here, and follow the instructions.

 

You misunderstood. If I make a direct reference to a BuildCraft class, my mod becomes dependent on the existence of that class (users without will with crash with NoClassDefFound).

Link to comment
Share on other sites

In fact, it won't. As long as you check to confirm that BuildCraft exists before calling any of their methods, you'll have absolutely no problems.

 

Proof:

Check out my mod's (TukMC) source. I have references to classes in the ThirstMod and IC2, and not once have I ever experienced any issues.

Link to comment
Share on other sites

In fact, it won't. As long as you check to confirm that BuildCraft exists before calling any of their methods, you'll have absolutely no problems.

 

Proof:

Check out my mod's (TukMC) source. I have references to classes in the ThirstMod and IC2, and not once have I ever experienced any issues.

 

I cannot make an implements conditional. And that class needs to exist in "vanilla RotaryCraft" as well.

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.

Announcements



×
×
  • Create New...

Important Information

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