Jump to content

[1.11.2] [SOLVED] Identify type of Energy Acceptor


Bektor

Recommended Posts

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.

Spoiler

(Optional) If anyone knows: Would also be interesting to know how other mods solved this question/problem.

 

Thx in advance.

Bektor

Edited by Bektor

Developer of Primeval Forest.

Link to comment
Share on other sites

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.

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/

Link to comment
Share on other sites

6 minutes ago, 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.

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 by Bektor

Developer of Primeval Forest.

Link to comment
Share on other sites

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).

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/

Link to comment
Share on other sites

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. 

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.

Link to comment
Share on other sites

2 minutes ago, 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. 

What do you mean by "infinite loops of "pull from upstream"" and "do it as a pull"?

Developer of Primeval Forest.

Link to comment
Share on other sites

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 by Draco18s

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.

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.