Interfacing with mod-added blocks

Discussion in 'Plugin Development' started by CAPS LOCK YEAH, May 14, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    CAPS LOCK YEAH

    Would it be possible, using bukkit plugins, to modify properties of mod-added blocks? I have a private tekkit server, and that has IC2 and RedPower. For example, I would like to be able to edit the amount of power stored in an IC2 Batbox, or even a RedPower Batbox. Maybe even measure the amount of power going through an IC2 wiring system. Is it possible to do this purely from a bukkit plugin? Or even from a ModLoader plugin? I just want to avoid using client mods.
     
  2. You'd be able to do basic bukkit things, like add new recipes involving modded items, add additional functionality to modded items, etc. as long as you referred to them in code by their item ID + datavalue rather than by enum. But since you wouldn't actually have access to any of the methods, classes, etc. from those mods, there isn't really anything more you can do than assign your own behaviour, etc. to configured item IDs & datavalues that are supposed to be used with modded item IDs and datavalues.

    Although there are interesting ways of getting around it; something that makes lockette handy on modded servers is that you can apply lockette locks to any block with a container attached, not just chests, furnaces, etc. - and it works beautifully with the Ironchests mod.

    Some server mods that enable the use of bukkit plugins within forge may provide their own APIs for interfacing with mods, but I don't have any experience with that.
     
  3. Offline

    CAPS LOCK YEAH

    So there's no way to call mod-added methods from within bukkit? Is there a way I would be able to add server-side functions, such as a command to change all batbox energy values?
     
  4. Offline

    agaricus

    Sure it is possible. Just build your plugin against the mod jar as well (in addition to the Bukkit API or CraftBukkit jar), e.g., add it as a library. You should then be able to browse and call the methods from the mod within your plugin.

    However note that if someone tries to run your plugin on a server without the mods, it will crash with NoClassDefFoundErrors. To prevent this, if you want compatibility with vanilla CraftBukkit servers, you could add a try{}catch(NoClassDefFoundError) around your mod-specific code (only the code; the imports are resolved at compile-time so they don't need to be wrapped).
     
    CAPS LOCK YEAH likes this.
  5. Offline

    CAPS LOCK YEAH

    Thank you very much! That's all I wanted to know.
     
  6. Sorry, I was thinking plugins built against the default bukkit/craftbukkit jars.
     
Thread Status:
Not open for further replies.

Share This Page