Jump to content

[1.12] Using Forge Energy (FE) - help still needed!


Sommanker

Recommended Posts

Hi,

I'm trying to implement energy into my mod and have decided to use Forge Energy. I am struggling to do this, however. I know that I need to create an energy class extending EnergyStorage for the storage, but even after watching a tutorial I found and studying the source code of existing mods (mainly because most mods have complex systems and implementations and I can't figure out which parts of their code are necessary for this), I am finding it difficult to figure out how to actually do this and get it to work, and so am looking for some in-depth assistance or tutorial, that assumes no prior knowledge when it comes to energy (as I have never used any kind of energy API at all before - some explanations of FE I found assume that the reader has experience with RF).

What functions do I need to override, what classes do I need to create to get a basic system working? I'm looking to include storage blocks, producing blocks and energy-using blocks (and items) and I think I want energy to be transmitted wirelessly.

 

Thank you! :)

Edited by Sommanker
Link to comment
Share on other sites

I would highly recommend learning to use the RF Api by TeamCOFH. It is widely used and means you're mod would be much more compatible with others, which is always a plus. Though I've never worked with energy before, I would strongly suggest RF as the route you should take. There's more likely to be tutorials for the API compared to FE since it is so wide spread too.

 

P.S. After some quick search I found the GitHub for the Redstone Flux API, which seems to include small implementations of how to use the basic system

Edited by mysticalherobine
Link to comment
Share on other sites

1 minute ago, mysticalherobine said:

I would highly recommend learning to use the RF Api by TeamCOFH. It is widely used and means you're mod would be much more compatible with others, which is always a plus. Though I've never worked with energy before, I would strongly suggest RF as the route you should take. There's more likely to be tutorials for the API compared to FE since it is so wide spread too.

Thanks for the recommendation, but from what I've seen recently, many mods are starting to drop support for RF and are starting to use FE/Tesla more and more instead, sources being things like this https://www.reddit.com/r/feedthebeast/comments/5defce/redstone_flux_and_energy_apis_in_111/?st=j6b7xwui&sh=9d527ad5 .

Admittedly, there are more tutorials so it would be far easier for me to get started with RF, but equally I think I would rather, if at all possible, go straight to what appears to be becoming the future popular API to use, and if not FE, then Tesla.

 

 

Link to comment
Share on other sites

15 hours ago, mysticalherobine said:

I would highly recommend learning to use the RF Api by TeamCOFH

I would rather start with FE and not use RF, because the FE API is build into Forge itself and thus it is always available. You would also not run into problems when the RF API doesn't update anymore. Like I remember a time where the mods by TeamCOFH got the 1.7.10 version 2014 and three years later followed 1.10.2 skipping 1.8.9 etc.

Also most mods which support RF also support FE. More explanation on wether to use FE or RF or both might be found here:

https://minecraft.curseforge.com/projects/redstone-flux

 

16 hours ago, Sommanker said:

mainly because most mods have complex systems and implementations

Most mods have this complex implementations because they are supporting multiply energy APIs while converting the energy internally to the one which is requested as an output or they got their own energy API for internal uses and convert to RF or FE or whatever is required by the connected machines.

When searching for mods which support energy and don't have complex systems I would start searching for mods which just support FE or maybe even support FE and Tesla, but I would also suggest looking into mods which got a fresh rewrite as otherwhise it might be that at one point they added support for FE into their existing systems and later on removed all the other APIs which aren't needed and such code is harder to read when you've got no idea how it works.

 

15 hours ago, Sommanker said:

Admittedly, there are more tutorials so it would be far easier for me to get started with RF, but equally I think I would rather, if at all possible, go straight to what appears to be becoming the future popular API to use, and if not FE, then Tesla.

 

WARNING: I might have missed some things in the following description as my own energy system also supports Tesla and thus is a bit more complicated.

 

As a starting point for FE, I would highly suggest to learn about the Capability System by Forge, if you haven't already done this.

https://mcforge.readthedocs.io/en/latest/datastorage/capabilities/

This is required as the Forge Energy system is based around capabilities.

 

The next point would be create a new class extended from EnergyStorage or just implement all the code yourself using the IEnergyStorage interface which I would suggest if you plan on overwritting all methods provided in EnergyStorage anyway. This class should also implement the interface INBTSerializable<NBTTagCompound> if you want to store your energy data (I assume here that you are already familiar with Java Generics).

In this class, save your data and read it in using normal NBT read and write methods (serializeNBT and deserializeNBT). This methods will later be called in for example our TileEntity's NBT read and write methods. In a more advanced system you might also use the capability methods to call wrapper classes around FE and Tesla and other capability based energy systems in this class, but this is out of scope of this basic overview.

 

At next, you should create a TileEntity.

This TileEntity needs your EnergyManager class you created before (the class which extends EnergyStorage or implements IEnergyStorage ). 

In here you add the read and write methods for NBT data and call the serializeNBT and deserializeNBT methods of your EnergyManager.

For example:

this.container.deserializeNBT(compound.getCompoundTag("Energy"));

(container is here the instance of EnergyManager.)

 

Then you also need the hasCapability and getCapability methods. I think you figure yourself out what to put in there.

In the update method of your TileEntity you might want to put your logic about energy production or extraction in.

 

this.container.receiveEnergy(int maxReceive, boolean simulate);
this.container.extractEnergy(int maxExtract, boolean simulate);

 

If you want to extract or receive energy from another TileEntity, you first need to get it at the specific location and than get the capability at the specific side. (Note: If a machine only sends energy in other machines underneath, then it might only return a capability for EnumFacing.DOWN.) An EnumFacing with null is also possible and might be used for internal purposes if I recall correctly.

 

Do note that it is recommended for the most compatibility between mods to let your machines send the energy into the cables instead of letting the cables extract the energy out of your machines.

https://github.com/SleepyTrousers/EnderIO/issues/4081#issuecomment-284911416

 

I hope this gives you a basic overview of how energy systems actually work. For items, I currently having figured it out myself as I've not worked with items and capabilities so far and transmitting energy wirelessly shouldn't be a challange after reading this. The basics are always the same, just how much more you put around those basic is different.

Edited by Bektor
  • Like 2
  • Thanks 1

Developer of Primeval Forest.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • SLOT DANA : Situs Slot Gacor Nagaliga Deposit Via DANA 10.000
    • NAGALIGA :  Agen Taruhan Mix Parlay Bola EURO Terpercaya Di Indonesia Nagaliga merupakan situs taruhan  judi bola euro dan slot gacor terbaik menyediakan link alternatif terbaik dan pastinya bisa di akses di seluruh penjuru dunia. Ayo meriahkan EURO bersama situs Nagaliga kemenangan berapapun pasti dibayar lunas tanpa ada kendala.
    • I have no idea how a UI mod crashed a whole world but HUGE props to you man, just saved me +2 months of progress!  
    • So i know for a fact this has been asked before but Render stuff troubles me a little and i didnt find any answer for recent version. I have a custom nausea effect. Currently i add both my nausea effect and the vanilla one for the effect. But the problem is that when I open the inventory, both are listed, while I'd only want mine to show up (both in the inv and on the GUI)   I've arrived to the GameRender (on joined/net/minecraft/client) and also found shaders on client-extra/assets/minecraft/shaders/post and client-extra/assets/minecraft/shaders/program but I'm lost. I understand that its like a regular screen, where I'd render stuff "over" the game depending on data on the server, but If someone could point to the right client and server classes that i can read to see how i can manage this or any tip would be apreciated
    • Let me try and help you with love spells, traditional healing, native healing, fortune telling, witchcraft, psychic readings, black magic, voodoo, herbalist healing, or any other service your may desire within the realm of african native healing, the spirits and the ancestors. I am a sangoma and healer. I could help you to connect with the ancestors , interpret dreams, diagnose illness through divination with bones, and help you heal both physical and spiritual illness. We facilitate the deepening of your relationship to the spirit world and the ancestors. Working in partnership with one\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’s ancestors is a gift representing a close link with the spirit realm as a mediator between the worlds.*   Witchdoctors, or sorcerers, are often purveyors of mutis and charms that cause harm to people. we believe that we are here for only one purpose, to heal through love and compassion.*   African people share a common understanding of the importance of ancestors in daily life. When they have lost touch with their ancestors, illness may result or bad luck. Then a traditional healer, or sangoma, is sought out who may prescribe herbs, changes in lifestyle, a career change, or changes in relationships. The client may also be told to perform a ceremony or purification ritual to appease the ancestors.*   Let us solve your problems using powerful African traditional methods. We believe that our ancestors and spirits give us enlightenment, wisdom, divine guidance, enabling us to overcome obstacles holding your life back. Our knowledge has been passed down through centuries, being refined along the way from generation to generation. We believe in the occult, the paranormal, the spirit world, the mystic world.*   The services here are based on the African Tradition Value system/religion,where we believe the ancestors and spirits play a very important role in society. The ancestors and spirits give guidance and counsel in society. They could enable us to see into the future and give solutions to the problems affecting us. We use rituals, divination, spells, chants and prayers to enable us tackle the task before us.*   I have experience in helping and guiding many people from all over the world. My psychic abilities may help you answer and resolve many unanswered questions
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.