LogisticsPipes icon indicating copy to clipboard operation
LogisticsPipes copied to clipboard

API changes and conversion to Kotlin (interafces only just yet)

Open Michal-MK opened this issue 4 years ago • 1 comments

Kotlinization

  • rewrote Java api interfaces to kotlin with small changes
    • IHUDArmor -> I do not see it's point so I kept it the same
    • ILogisticsPowerProvider -> Doc + rename getPowerLevel to getAvailablePower to be more descriptive (...it is OVER NINE THOUSAND!)
    • ILPPipe -> Doc + isRoutedPipe to isRouted -> sounds more natural and it clearly works with the pipe
    • ILPPipeConfigTool -> Doc (wrenchUsed is WIP)
    • ILPPipeTile -> Doc
    • IProgressProvider -> Doc + suggestion
    • IRoutedPowerProvider -> Doc + blockPos to be consistent -> marked get*() as deprecated, the useEnergy/canUseEnergy are confusing

Code changes

CoreRoutedPipe:

  • added more Nonnull annotations (how about converting to NotNull from jetbrains.annotations as that is the default when using the refactoring shortcuts?
  • simplified canUseEnergy and useEnergy:
  • removed the goto... lel
  • compressed the if to || && expressions
  • some values cannot be null now
  • power blocking check is now a streamed
  • some checks were performed multiple times and I did not find a reason for it

LogisticsHUDRenderer:

  • playerWearsHUD refactored the mess that it was to make it readable

The test setup for usePower refactoring: Image

Michal-MK avatar Jun 25 '21 11:06 Michal-MK

Glancing over this, you have a lot of new ArrayList<>() in there. Some functions are used quite a lot. Maybe check if you can use something like java.util.Collections.emptyList() To reduce the amount of object creation

davboecki avatar Jun 28 '21 12:06 davboecki

Just migrating code to Kotlin is not what we are looking for. We need rewrites of parts of the code to re-license it under dual MMPL and MIT. The later one being the target license for the future.

bziemons avatar Sep 13 '22 15:09 bziemons