Emitting logic overhaul (#5422)

* First pass improving performance of EnergyNetwork emitting
Only sends power once per tick per accept now. Lots of comments of design included so that I have a backup of my thought process/solutions if I run into some blocker.

* Optimized implementation slightly, still more to be done

* Cleanup some comments

* Move send energy to acceptor logic to CableUtils
Replace old emit logic in CableUtils with using the newer logic

* Inline getConnections to slightly cut down on number of operations ran

* Fix a couple bugs with targets that have multiple sides
Also improve performance reducing frequency at amountPerChanged needs to be ran

* Improve performance of CableUtils.emit by faking we have one 6 sided target as opposed to having 6 one sided targets

* Allow simulating insertion into the EnergyAcceptorWrapper for IC2

* Fix using wrong value for total acceptor count when acceptors have multiple sides

* Use an EnumMap instead of a HashMap for the Target

* First pass converting gas and fluid network emission to target system

* Improve general fluid and gas emitting using the utility method
Change a couple things to using Sets rather than lists for emitting so that we can ensure each side is only done once.

* Document and cleanup method/variable names of target classes

* Start deduplicating emitting code into a EmitUtils file
Logic for Gas and Fluid emitting fully generic now

* Partially extract how we keep track of the split to make it easier to deduplicate the common code

* Start moving shifting needed to given to the targets themselves

* Use generics to deduplicate a lot of the remaining duplication in the new emitting code

* Fix having broke energy emitting and also further cleanup some code

* Half the number of loops the HeatNetwork does onUpdate

* Fix potentially divide by zero errors

* Deprecate and remove implementations of getAcceptors as it is no longer needed

* Never round up from doubles for sending power stops energy networks going negative.

* Fix more spots where we were accidentally rounding upwards/clamping improperly for energy

* Cleanup impl to use less memory and adjust better as sending if
the possible amount changed/should be adjusted
Also removed the need for a specific IntegerTypeTarget intermediary class

* Cleanup the docs of some of the changed things

* Given tickEmit is private now we already know it is only being called serverside

* Improve documentation slightly and rename a method to be more accurate

* Remove limit on IC2 given it uses doubles as well now

* Rename amountPer to amountPerTarget
This commit is contained in:
Richard Freimer authored and GitHub committed 2019-04-30 10:25:23 -04:00
1 parent 445556fef7
commit b3663a37a9
37 files changed
+689 -641

No files matched your search

@@ -244,7 +244,7 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS
setEnergy(theItem, getEnergy(theItem) + toReceive);
}
return (int) Math.round(toReceive * MekanismConfig.current().general.TO_RF.val());
return MekanismUtils.clampToInt(toReceive * MekanismConfig.current().general.TO_RF.val());
}
return 0;
@@ -261,7 +261,7 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS
setEnergy(theItem, getEnergy(theItem) - toSend);
}
return (int) Math.round(toSend * MekanismConfig.current().general.TO_RF.val());
return MekanismUtils.clampToInt(toSend * MekanismConfig.current().general.TO_RF.val());
}
return 0;