Class BigFluidAmount
java.lang.Object
alexiil.mc.lib.attributes.fluid.amount.BigFluidAmount
- All Implemented Interfaces:
java.lang.Comparable<BigFluidAmount>
public final class BigFluidAmount
extends java.lang.Object
Exact version of
FluidAmount. This is generally intended for calculations if the end result should fit into
a FluidAmount, but the intermediate steps might not.-
Field Summary
Fields Modifier and Type Field Description static BigFluidAmountBOTTLEstatic BigFluidAmountBUCKETjava.math.BigIntegerdenominatorAlways greater than 0.static BigFluidAmountNEGATIVE_ONEjava.math.BigIntegernumeratorstatic BigFluidAmountONEjava.math.BigIntegerwholestatic BigFluidAmountZERO -
Constructor Summary
Constructors Constructor Description BigFluidAmount(FluidAmount from) -
Method Summary
Modifier and Type Method Description BigFluidAmountadd(long by)BigFluidAmountadd(BigFluidAmount by)BigFluidAmountadd(FluidAmount by)BigFluidAmountasBigInt()doubleasInexactDouble()FluidAmountasLongIntExact()FluidAmountasLongIntRounded()Converts this into a normal long-basedFluidAmount.FluidAmountasLongIntRounded(java.math.RoundingMode rounding)Converts this into a normal long-basedFluidAmount.FluidAmountasLongIntSaturated()Converts this into a normal long-basedFluidAmount.intcompareTo(BigFluidAmount o)Null is treated as zeroBigFluidAmountdiv(long by)BigFluidAmountdiv(BigFluidAmount by)BigFluidAmountdiv(FluidAmount by)booleanequals(BigFluidAmount other)booleanequals(java.lang.Object obj)booleanfitsInLongInt()BigFluidAmountgcd(BigFluidAmount other)BigFluidAmountgcd(FluidAmount other)BigFluidAmountgetDivisor()inthashCode()booleanisGreaterThan(BigFluidAmount other)Null is treated as zerobooleanisGreaterThanOrEqual(BigFluidAmount other)Null is treated as zerobooleanisLessThan(BigFluidAmount other)Null is treated as zerobooleanisLessThanOrEqual(BigFluidAmount other)Null is treated as zerobooleanisNegative()booleanisPositive()booleanisZero()BigFluidAmountlcm(BigFluidAmount other)BigFluidAmountmax(BigFluidAmount other)BigFluidAmountmin(BigFluidAmount other)BigFluidAmountmul(long by)BigFluidAmountmul(BigFluidAmount by)BigFluidAmountmul(FluidAmount by)BigFluidAmountnegate()static BigFluidAmountof(java.math.BigInteger numerator, java.math.BigInteger denominator)Creates a newFluidAmountwith the given values.static BigFluidAmountof(java.math.BigInteger whole, java.math.BigInteger numerator, java.math.BigInteger denominator)Creates a newFluidAmountwith the given values.BigFluidAmountreciprocal()intsign()BigFluidAmountsub(long by)BigFluidAmountsub(BigFluidAmount by)BigFluidAmountsub(FluidAmount by)java.lang.StringtoString()
-
Field Details
-
ZERO
-
ONE
-
NEGATIVE_ONE
-
BUCKET
-
BOTTLE
-
whole
public final java.math.BigInteger whole -
numerator
public final java.math.BigInteger numerator -
denominator
public final java.math.BigInteger denominatorAlways greater than 0.
-
-
Constructor Details
-
Method Details
-
of
Creates a newFluidAmountwith the given values. This will reduce the fraction into it's simplest form. -
of
public static BigFluidAmount of(java.math.BigInteger whole, java.math.BigInteger numerator, java.math.BigInteger denominator)Creates a newFluidAmountwith the given values. This will reduce the fraction into it's simplest form.- Throws:
java.lang.IllegalArgumentException- if either whole or numerator are negative, or if denominator is less than or equal to 0.
-
isZero
public boolean isZero() -
isNegative
public boolean isNegative() -
isPositive
public boolean isPositive() -
sign
public int sign()- Returns:
- The sign: Either -1 if this is negative, +1 if this is positive, or 0 if this is zero.
-
getDivisor
- Returns:
- The denominator represented in a new fraction, as 1/this.denominator.
-
lcm
-
negate
-
reciprocal
- Returns:
- This fraction, but inverted. (With the numerator and denominator swapped).
-
asLongIntExact
- Throws:
java.lang.ArithmeticException- if the given values don't fit in aFluidAmount
-
fitsInLongInt
public boolean fitsInLongInt()- Returns:
- True if
asLongIntExact()will not throw an arithmetic exception.
-
asLongIntSaturated
Converts this into a normal long-basedFluidAmount. If this is too big to fit then this returns eitherFluidAmount.MIN_BUCKETSorFluidAmount.MAX_BUCKETSaccording this thesign(). -
asLongIntRounded
Converts this into a normal long-basedFluidAmount.If
wholeis too large to fit in a long then eitherFluidAmount.MIN_BUCKETSorFluidAmount.MAX_BUCKETSis returned (depending on this sign).Otherwise this is approximately rounded to a valid value.
-
asLongIntRounded
Converts this into a normal long-basedFluidAmount.If
wholeis too large to fit in a long then eitherFluidAmount.MIN_BUCKETSorFluidAmount.MAX_BUCKETSis returned (depending on this sign).Otherwise this is approximately rounded to a valid value.
-
asBigInt
-
add
-
add
-
add
-
sub
-
sub
-
sub
-
mul
-
mul
-
mul
-
div
-
div
-
div
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
equals
- Returns:
- True if the number that this
FluidAmountrepresents is equal to the number that the givenFluidAmountrepresents.
-
compareTo
Null is treated as zero- Specified by:
compareToin interfacejava.lang.Comparable<BigFluidAmount>
-
asInexactDouble
public double asInexactDouble() -
isGreaterThan
Null is treated as zero -
isGreaterThanOrEqual
Null is treated as zero -
isLessThan
Null is treated as zero -
isLessThanOrEqual
Null is treated as zero -
gcd
-
gcd
-
min
- Returns:
- The smaller of this value and then given value.
-
max
- Returns:
- The greater of this value and then given value.
-