MCPcopy Create free account
hub / github.com/GregTech6/gregtech6 / units

Method units

src/main/java/gregapi/util/UT.java:1677–1683  ·  view source on GitHub ↗

Translates Amount of aUnit1 to Amount of aUnit2.

(long aAmount, long aOriginalUnit, long aTargetUnit, boolean aRoundUp)

Source from the content-addressed store, hash-verified

1675
1676 /** Translates Amount of aUnit1 to Amount of aUnit2. */
1677 public static long units(long aAmount, long aOriginalUnit, long aTargetUnit, boolean aRoundUp) {
1678 if (aTargetUnit == 0) return 0;
1679 if (aOriginalUnit == aTargetUnit || aOriginalUnit == 0) return aAmount;
1680 if (aOriginalUnit % aTargetUnit == 0) {aOriginalUnit /= aTargetUnit; aTargetUnit = 1;} else
1681 if (aTargetUnit % aOriginalUnit == 0) { aTargetUnit /= aOriginalUnit; aOriginalUnit = 1;}
1682 return Math.max(0, ((aAmount * aTargetUnit) / aOriginalUnit) + (aRoundUp && (aAmount * aTargetUnit) % aOriginalUnit > 0 ? 1 : 0));
1683 }
1684
1685 /** Translates Amount of aUnit1 to Amount of aUnit2. With additional checks to avoid 64 Bit Overflow. */
1686 public static long units_(long aAmount, long aOriginalUnit, long aTargetUnit, boolean aRoundUp) {

Callers 15

mulMethod · 0.95
mulMethod · 0.95
onPlayerInteractionMethod · 0.80
getBurnTimeMethod · 0.80
handleItemTooltipMethod · 0.80
liquidMethod · 0.80
gasMethod · 0.80
plasmaMethod · 0.80
getItemData_Method · 0.80
addInformationMethod · 0.80
onItemUseFirstMethod · 0.80
addToolTipsEfficiencyMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected