How to make a energy/electricity plugin

Discussion in 'Plugin Development' started by VortexGmer, Oct 25, 2015.

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


    I want to make a plugin that is like the mod Industrial Craft but don't know how to make energy nets and blocks that generate and use energy.
    @mrCookieSlime It's kind of like your sensible toolbox plugin

    Any help is appreciated!
  2. Offline

    bwfcwalshy Retired Staff

  3. Offline

    mrCookieSlime Retired Staff

    To be fair, it is impossible to explain you what you need to do. An Energy System is extremely complex.

    You need to
    a) store the Energy Value for each Machine
    b) store the Energy Capacity for each Machine
    c) [If you want to add Machines] store the Inventory for each Machine
    d) run Code every X ticks for each Machine with less Performance Impact as possible
    e) calculate how Energy is distributed (aka Make sure each Machine knows what Energy Net it belongs to and make the Energy Net know what Machines are in the Network)
    f) segregate between Energy Consumption and Energy Generation
    g) [If you want to make your Machines have Recipes] a Recipe System
    h) store the Energy Value and Capacity on the Hard Drive when its needed to ensure the Values are kept over Restarts.
    i) decide whether you are doing this Async or on the Main Thread, if your Machines are goint to affect the World in any way (Particles, Block Changes, etc...) it has to run on the Main Thread

    If you cannot think of a way to accomplish something on that list I would suggest you to just not attempt to start the development of this Project, something like an Energy Net is something for advanced Users.

    TL;DR: This is nothing lightweight and if you need to ask how to accomplish this you should re-think if you want to attempt developing something like this.
  4. Offline


    The only question I have is the wires, How to make sure that it won't go into an infinite loop?
  5. Offline



    A simple way of doing so would be to either mark the blocks you've already visited (I'm not exactly sure how you would do this in Bukkit) or by keeping track of them some how (probably a HashMap of their vectors, as existence checks would be O(1)).
  6. Offline


    Or have an upper limit on the length of your wires.
    For example, if you have an upper limit on the length of your wires (15 blocks long, or something), then the 'infinite' loops would suddenly stop after 15 blocks around
Thread Status:
Not open for further replies.

Share This Page