Bektor Posted April 27, 2017 Posted April 27, 2017 (edited) Hi, I've got some cables which should either extract the energy or send it (haven't decided yet.) So, to make it here easier: When the machines send energy into the cables and the cables send energy around: How does a cable know that the block it should send the energy is the machine in direction A and not the generator in direction B? It would be simple if I would just implement this for my own mod as I could then use a different TileEntityBase for Generators and Machines and check with instanceof, but I don't want my cables to be incompatible with other mods. So how does a cable know the energy should go to this machine. Reveal hidden contents (Optional) If anyone knows: Would also be interesting to know how other mods solved this question/problem. Thx in advance. Bektor Edited August 24, 2017 by Bektor Quote Developer of Primeval Forest.
larsgerrits Posted April 27, 2017 Posted April 27, 2017 There are multiple ways of handling energy. A few I can think of: Have a main "controller" block which handles everything in the network. (e.g. Applied Energistics, Refined Storage) Have the cables extract energy from outputs and move it around per block (to stop energy from bouncing around, save the block latest received from) until it finds an energy user. Have energy users go down a line of cables to find the nearest energy output and extract it from them instantly. This way the cables don't have to do anything and just serve as a guide. Quote Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
Bektor Posted April 27, 2017 Author Posted April 27, 2017 (edited) On 4/27/2017 at 4:18 PM, larsgerrits said: There are multiple ways of handling energy. A few I can think of: Have a main "controller" block which handles everything in the network. (e.g. Applied Energistics, Refined Storage) Have the cables extract energy from outputs and move it around per block (to stop energy from bouncing around, save the block latest received from) until it finds an energy user. Have energy users go down a line of cables to find the nearest energy output and extract it from them instantly. This way the cables don't have to do anything and just serve as a guide. Expand Well, the basic network is already working. I'm now just wondering how my cables (or to be more clear the controller for the cable line at each end of the cable) can determine if the block they are connected to is a machine or a generator. This should be done mod independent. So my cables could be for example connected to an EnderIO generator and EnderIO machine and still work or EnderIO generator and a machine from me and still work. That's why I am wondering how a cable controller can determine if the block it's connceted to is a generator or a machine. Edited April 27, 2017 by Bektor Quote Developer of Primeval Forest.
larsgerrits Posted April 27, 2017 Posted April 27, 2017 As far as I know, there's no way to distinguish them apart except for calling IEnergyStorage#canExtract and IEnergyStorage#canReceive, but that won't guarantee anything (e.g. power banks are both inputs and outputs). Quote Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
Draco18s Posted April 27, 2017 Posted April 27, 2017 In case 2, you should do it as a pull not a push. It is really hard to create infinite loops of "pull from upstream" compared to trying to determine which direction is downstream. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Bektor Posted April 27, 2017 Author Posted April 27, 2017 On 4/27/2017 at 4:54 PM, Draco18s said: In case 2, you should do it as a pull not a push. It is really hard to create infinite loops of "pull from upstream" compared to trying to determine which direction is downstream. Expand What do you mean by "infinite loops of "pull from upstream"" and "do it as a pull"? Quote Developer of Primeval Forest.
Draco18s Posted April 27, 2017 Posted April 27, 2017 (edited) Imagine four cables placed into a square: # 1 2 3 4 Where the # is some producer. The producer pushes to 1, 1 pushes to 2, 2 pushes to 3, and 3 pushes to 1. Infinite loop (well, not necessarily, unless the power producer is removed and there's less total energy than what 4 cables can "hold"). On the other hand if a pull system is used, each of these cables will check all of their neighbors to see if their neighbors have more power than they do, if that neighbor does, extract it, and fill self. If none do, then the state of the system doesn't change. Edited April 27, 2017 by Draco18s Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Recommended Posts
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.