Class BigFluidAmount
java.lang.Object
alexiil.mc.lib.attributes.fluid.amount.BigFluidAmount
- All Implemented Interfaces:
Comparable<BigFluidAmount>
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
FieldsModifier and TypeFieldDescriptionstatic BigFluidAmountstatic BigFluidAmountAlways greater than 0.static BigFluidAmountstatic BigFluidAmountstatic BigFluidAmount -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(long by)add(BigFluidAmount by)add(FluidAmount by)asBigInt()doubleConverts this into a normal long-basedFluidAmount.asLongIntRounded(RoundingMode rounding)Converts this into a normal long-basedFluidAmount.Converts this into a normal long-basedFluidAmount.intNull is treated as zerodiv(long by)div(BigFluidAmount by)div(FluidAmount by)booleanequals(BigFluidAmount other)booleanbooleangcd(BigFluidAmount other)gcd(FluidAmount other)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 zerobooleanbooleanbooleanisZero()lcm(BigFluidAmount other)max(BigFluidAmount other)min(BigFluidAmount other)mul(long by)mul(BigFluidAmount by)mul(FluidAmount by)negate()static BigFluidAmountof(BigInteger numerator, BigInteger denominator)Creates a newFluidAmountwith the given values.static BigFluidAmountof(BigInteger whole, BigInteger numerator, BigInteger denominator)Creates a newFluidAmountwith the given values.intsign()sub(long by)sub(BigFluidAmount by)sub(FluidAmount by)toString()
-
Field Details
-
ZERO
-
ONE
-
NEGATIVE_ONE
-
BUCKET
-
BOTTLE
-
whole
-
numerator
-
denominator
Always greater than 0.
-
-
Constructor Details
-
BigFluidAmount
-
-
Method Details
-
of
Creates a newFluidAmountwith the given values. This will reduce the fraction into it's simplest form. -
of
Creates a newFluidAmountwith the given values. This will reduce the fraction into it's simplest form.- Throws:
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:
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
-
hashCode
public int hashCode() -
toString
-
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 interfaceComparable<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.
-