Jump to content

Recommended Posts

Posted

I want to add a power system, like MJ, EU, RF, CA(Compressed Air), whatever EnderIO uses, but for my mod. With power generators, and machines that require this power to operate.

This is for my mod LabStuff, so LabVolts, or LV.

I have an idea, where the cables hold an int of power level, and when a generator turns on or ticks into a new stage of power generation (Buildcrafts engines going up in color), they add onto the int of the cable connected, which would transfer down the line, and when a machine uses some LV, a generator turns off, or is disconnected, the int is subtracted from, but that would lead to having the problem of deciding which int is right, and which to override.

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Posted

A power system is a very complex topic and I don't recommend trying to make one unless you are very experienced in Java and have been making mods for Minecraft for a decent amount of time.  However, what I would recommend is having the thing that extracts power handle everything and then have the thing that extracts power check how long the line is and if anything is requesting power send power.  That is a very simple explanation but hopefully you can get somewhere from there.  I will help you more if you make some progress by yourself  :).

Posted

Another good option to go with is to use an existing api such as the cofh RF api that way not only will it be extremely easy to implement but it will be compatible with a lot of other mods out there. The only down side is if there are no other mods installed that have rf transport you wont be able to use cables to transfer power from point A to point B but once you have enough experience you can make your own power cables using the RF api.

 

NOTE: Using the RF api dos NOT make you dependent on any other mods. 

I am the author of Draconic Evolution

Posted

Instead of a setPowerLevel method, I could have a addToPowerLevel and  a subtractFromPowerLevel method. And when one method is called on a cable, it initiates the method on all connected cables, except on the one that initiated the method, that would clear up my 'which ones right' problem. And since generators constantly put out new power, the generators would use add every tick, and while a machine is running, it needs a supply of power, so as long a sit needs it, it uses subtract every tick. Its rudimentary, and seems a lot simpler than you two make it out to be. Also, I dont feel like using extra APIs, I know that makes it easier, but I want to take on this challenge on my own, well, with this threads help. Improve my modding and java skills you know.

 

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Posted

I don't think power systems are THAT difficult.  The main idea is that you have a bunch of different custom blocks (generators, conduits/cables, and machines that use the power).  Each block would have a couple pieces of data needed, possibly small enough to be kept in metadata but if not you can add some tile entities (or if that is too much of performance issue you can have one common class with some arrays that keeps track of info for all placed custom blocks).  For example, in a generator you might have a boolean value to indicate if it is on or off, and an int value to indicate how much power it produces.  In a cable you might have an int that indicates how far it is from the power source (if you want an effect like redstone that dies out over distance).  In a machine you might just have a boolean for on and off, and int to indicate direction.

 

Then, all you need to do in each block is monitor neighbors.  The generator doesn't actually need to do much.  A cable will check to see first to see if it is next to a generator and if it is it will set the distance variable to 1, otherwise it will check to see if it is next to any other powered cables (cables that have non-zero distance variable) and if it is it will set its distance to 1 more than the least of any neighboring cables, and if it isn't next to any it will set distance to 0 (not powered).  The machines would check if it is next to any generator or next to any powered cable and set it's on / off state accordingly.

 

That's pretty much all the power system does.  You can of course get fancy with textures to show power levels and stuff.  But mostly it is just a matter of each block "inspecting" surrounding blocks and picking up on anything that is powered around it.

 

Hope that makes sense.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Take a look at my source, i created a custom power system: https://github.com/Larsg310/PowerCraft/blob/master/src/main/java/larsg310/mods/powercraft/energy/EnergyNet.java In that class is a utility method for distributing enrgy to surrounding block/cables. It also uses my IEnergy interface that have some methods for connecting and distributing, and my EnergyBar class which actually holds the max power it can hold, the current power it holds and some method for manipulating the energy.

 

P.S. If you see something wrong with my system, please say so so i can make it better.

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/

Posted

@jaeblar

I don't want a loss effect, so a think the power level integer is a good replacement. And your right, I don't get how its so hard. If you want to do buildcraft kinesis pipes, have fun. That's why I'm making my pipes either have liqid in them, ir they don't.

 

@larsgerrits

Ill look at yours if I cant get my to work

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

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

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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