API questions with regards to Modular Powersuits

  • Hello everybody,


    I'm still in the stone ages with 1.7.10 because that's where all my mods work the best (or at least did, and now there's too much time sunk to upgrade), and I've got these mods installed:
    IC2: 2-2.2.821-experimental
    MMPS: 0.11.0.300
    and others too, that I don't think are contributing to the problem.


    I am having an issue where the IC2 power tools will not drain power from the power suits, ever. I've tried all three of the drills and have tried adjusting the IC2 battery tier options in the powersuits. Moreover, the reason I think this is an IC2 issue is because MMPS's source is available and all of the code is there to make the items provide power to the tools. I suspect that the API has changed and MachineMuse has not/will not update the API calls. I am not a Minecraft modder, but a general programmer. I could update the API calls myself, but I don't know literally anything about the process.


    As a result, I am asking here in hopes that someone can either directly point me to the updated API docs so I can fix them in MMPS, or, explain to me what the problem really is. I don't actually know if it's because the MMPS API is out of date or what.


    Many thanks,
    electrum

    • Official Post

    The armor has to allow external discharging to be able to power ic2 tools, i.e. it has to return a value greater than 0 in IElectricItemManager.discharge() with the externally parameter being true. MPS afaik uses its own electric item manager, if it just uses IElectricItem the property gets delegated to IElectricItem.canProvideEnergy().

  • This is what I've found:


    Code
    def drainEnergy(requested: Double): Double = museEnergyFromEU(ElectricItem.manager.discharge(stack, museEnergyToEU(requested), getTier, true, false, false))


    It appears that the external boolean is set to false, meaning any of these items shouldn't be able to provide battery to tools, right?
    Further, it seems that he's using ElectricItem and not IElectricItem, which could be a problem. He doesn't provide the .jar for ElectricItem, and the only classes that are instantiated are for IElectricItem.


    I'm trying to follow the classes back up to figure out where the disconnect is, but like I said, I'm unfamiliar with modding in general.


    EDIT: After finding the API linked by Greg, I'm pretty sure I've determined that the API calls are all correct. If the item calls ElectricItem.manager.discharge() like you say, then the items should recharge from it.


    I do note that the power armor traces back up to an overridden version of discharge, implemented in MuseElectricItem, but it looks like that one is kosher, too. I'm not seeing anywhere that there are glaring code errors. Does anyone have another suggestion? Maybe some in-game diagnostics I could do to determine what's happening?


  • Hmm no, the item needs to call IElectricItemManager.use, discharge is the raw discharging, which bypasses batpacks etc. My previous post was about the armor side's implementation requirement, not the tool that uses the energy.


    Excellent. I reread your earlier post, and I think that it's because when MachineMuse wraps the IC2 discharge function in his drainEnergy, he sets the externally param to false. I don't know if this is intended, but I think I have an avenue for fixing this.


    Now, I have to figure out how to recompile the .jar, which I could do but I'm having a gradlew problem that google doesn't recognize. Any chance someone else could recompile it for me? I totally understand if not.

  • Huh, well. Then I don't really know what to do here. I've done lots of searches and no one seems to have this issue. The other steps I've tried to resolve this:
    1. Remove other mods
    2. Tinker with configs
    3. Try a single-player game


    This is out of my scope, so I suppose I'll try to get into contact with MachineMuse and hope he responds. Is there a way I could try to follow the function call when the drill mines to see how it traces through? Sort of like gdb?

  • You may be right. If so, that's a shame, because in previous versions of the mod IIRC the armor did power tools. Further, it seems like a waste of code to me to include all the necessary API calls to charge the armor and disallow it from charging the power tools.


    At any rate, thank you for your help!