Jump to content

Recommended Posts

Posted (edited)

Hello all forge modders,

 

How would one create an efficient power network system with cables? I have had multiple thoughts, but don't know the usual/best implementation. The goal is a simple power system similar to IC2, but without different voltages and power falloff over distance. Any cables connected shares power 1:1, meaning a generator (adding power to a neighboring cable) could power an electric furnace (consuming power from neighboring cable), however many blocks away. 

 

My suggestions:

  • Cables being TileEntities distributing power to its neighbors directly. Every cable has a IEnergyStorage. Would require power splitting on multiple neighbors. This would probably be very inefficient (based on other posts in this forum).

 

  • Creating a WorldSavedData class, containing a List<List<BlockPos>> (note; this structure might be inefficient as well. Suggestions here are also welcome  ). Every time a cable block is placed, add it to the WorldSavedData. The First list represents one isolated network, the second all blocks in that network. By adding blocks to the network (and merging/splitting networks when needed), only one IEnergyStorage would be needed for one isolated network. This system would barely use tileEntities. Every cable TileEntity would have to store the corresponding network id (or a search in the List<List<BlockPos>> every time a power generator/consumer is placed). Therefore, this system may be redundant compared to next suggestion.

 

  • Similar to the last one, but instead every Cable TileEntity keeping track of its own networkId. Merging of two networks would become more complex (TileEntities would need to update their neighbors, resulting in a chain reaction). This makes saves smaller. The previous system has an advantage, I believe copying all BlockPos from one net to another is performance-cheaper than executing this chain reaction. Not tested.

 

Do you have any other suggestions? Which of the above would be best scalable for performance (and world save size, but not as big of a priority). 

 

Any help would be appreciated!

Edited by Gaffa

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.