Slimefun4
Slimefun4 copied to clipboard
Evenly divide generated energy over all connected energy networks
Description
When a generator was connected to multiple networks it supplied its full generated output to all connected networks.
Proposed changes
Evenly divide generated energy over all connected energy networks. output / networks.size * networks.size = output, so the generator will now produce the correct amount of energy when connected to multiple networks.
Related Issues (if applicable)
Resolves #3260
Checklist
- [x] I have fully tested the proposed changes and promise that they will not break everything into chaos.
- [ ] I have also tested the proposed changes in combination with various popular addons and can confirm my changes do not break them.
- [x] I have made sure that the proposed changes do not break compatibility across the supported Minecraft versions (1.16.* - 1.20.*).
- [x] I followed the existing code standards and didn't mess up the formatting.
- [x] I did my best to add documentation to any public classes or methods I added.
- [x] I have added
Nonnull
andNullable
annotations to my methods to indicate their behaviour for null values - [ ] I added sufficient Unit Tests to cover my code.
Pro Tip! You can help us label your Pull Requests by using the following branch naming convention next time you create a pull request. โค๏ธ
Branch naming convention | Label |
---|---|
feature/** |
๐ Feature |
fix/** |
โจ Fix |
chore/** |
๐งน Chores |
api/** |
๐ง API |
performance/** |
๐ก Performance Optimization |
compatibility/** |
๐ค Compatibility |
If your changes do not fall into any of these categories, don't worry. You can just ignore this message in that case! ๐
Slimefun preview build
A Slimefun preview build is available for testing! Commit: 6e91c98f
https://preview-builds.walshy.dev/download/Slimefun/3943/6e91c98f
Note: This is not a supported build and is only here for the purposes of testing. Do not run this on a live server and do not report bugs anywhere but this PR!
What happens when an energy Network is fully saturated with power, I wouldn't expect the output of power to be divided like this if only one of the connected Networks is able to accept power?
What happens when an energy Network is fully saturated with power, I wouldn't expect the output of power to be divided like this if only one of the connected Networks is able to accept power?
Oooh that's a great point, glad you brought that up
Hmm. Yes. It'll still give the saturated energy network it's 'share' but that energy will just be voided. That definitely needs to be fixed.
Fixed, right now it divides only among non saturated networks. However the supply holograms for the saturated networks show the supply the non saturated networks are getting. I was wondering if they should be like this or if they should display the supply they would be getting if they weren't saturated.
What if the connected energy network count exceeds the generator's power rate? It'll become 0. Not sure whether that is desired or not, but it could be an intended mechanic perhaps.
I would say that would be intended. If there are more networks connected to a generator that the amount of the Joules it generates, each network would get <1 Joule which is floored to 0. You could also ceil the result of the division. The difference would be 1 Joule per network (max 6) which isn't very significant.
I don't think the drop off is a problem. If we were to min it at 1 then that could lead to low level duplication if a generator only generated like 1-5 joules and gets split 6 ways.
Plus if we want to give reasoning we can just say it's energy resistance being more an issue when using multiple regulators
Anyone up for testing this ๐
this still needs work. in placing 4 regulators and a lava generator, while all 4 went up nearly even, it was well above the rate that the lava generator produced. each went up 8 j/t, while the gen makes 10 total per tick, which created an excess of 22 per tick. additionally it sped up how fast the generator used up the lava. it's supposed to last 40 seconds, it lasted 10. then the amount of power in each network was way above what it should have been. this needs a lot more work
this still needs work. in placing 4 regulators and a lava generator, while all 4 went up nearly even, it was well above the rate that the lava generator produced. each went up 8 j/t, while the gen makes 10 total per tick, which created an excess of 22 per tick. additionally it sped up how fast the generator used up the lava. it's supposed to last 40 seconds, it lasted 10. then the amount of power in each network was way above what it should have been. this needs a lot more work
Sooooooo not sure how you got those results. This PR can not affect how long the lava lasts. And I've tested this previously without issue. Are you sure you used the right tier of lava generator?
I found out why. The pr didn't change how long the lava lasts, this was already the behavior before this pr. As for the excess power, that is because I only tested this for machines with no buffer ๐
. The generated power is divided evenly floor(10/4)
then stored in the buffer 4 times meaning the buffer increases by 8 every tick. But the whole buffer is still accessible by all networks.
The easiest fix imo is keeping EnergyNetProvider
s that implement MachineProcessHolder<FuelOperation>
the same as they are now (4x the full output but fuel goes 4x faster) and EnergyNetProvider
s that do not will have their generated output evenly distributed. And if generators have a buffer also evenly distribute that.
The best fix imo would be changing the fuel consumption rate back to expected amount and evenly distributing it aswell, however this would be harder to make.
this still needs work. in placing 4 regulators and a lava generator, while all 4 went up nearly even, it was well above the rate that the lava generator produced. each went up 8 j/t, while the gen makes 10 total per tick, which created an excess of 22 per tick. additionally it sped up how fast the generator used up the lava. it's supposed to last 40 seconds, it lasted 10. then the amount of power in each network was way above what it should have been. this needs a lot more work
The reason the lava went 4x as quick was because each energy net ticked it down. That happens regardless of this pr like iTwins said. Honestly I think that should be the behavior
this still needs work. in placing 4 regulators and a lava generator, while all 4 went up nearly even, it was well above the rate that the lava generator produced. each went up 8 j/t, while the gen makes 10 total per tick, which created an excess of 22 per tick. additionally it sped up how fast the generator used up the lava. it's supposed to last 40 seconds, it lasted 10. then the amount of power in each network was way above what it should have been. this needs a lot more work
The reason the lava went 4x as quick was because each energy net ticked it down. That happens regardless of this pr like iTwins said. Honestly I think that should be the behavior
that would be fine if the power spread evenly as it should, and the total produced matched what the fuel would produce if just on one network
iTwins if you can vc in a little bit to talk about some of this / make the changes necessary I'd be down.