MinecraftModDevelopmentMods / Tesla-Core-Lib

Minecraft library useful in creating power hungry machines
https://minecraft.curseforge.com/projects/tesla-core-lib
MIT License
6 stars 8 forks source link

ElectricGenerator doesn't properly split energy between consumers #55

Open springheeljack opened 4 years ago

springheeljack commented 4 years ago

Re-posting this issue here as I think I have found the problem.

Industrial Foregoing Version: industrialforegoing-1.12.2-1.12.13-237 TeslaCoreLib Version: tesla-core-lib-1.12.2-1.0.15

Attaching any energy acceptors (machines, capacitor bank) to multiple sides of any generator causes extra RF to be generated. For example, burning a block of coal in a Petrified Fuel Generator with an EnderIO capacitor bank on the left and right sides of the generator will result in 800rf/t going into one bank and 400rf/t going into the other. The same thing happens when using more capacitor banks, with a third bank receiving 266rf/t, fourth receiving 200rf/t etc.

I'm not well versed with modding Minecraft but it seems that the issue is at line 198 in ElectricGenerator.kt, consumerCount is decremented which increases perConsumer each time round the loop. It looks like perConsumer should just be calculated once before the loop, and then consumerCount can be removed.