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 BigFluidAmount
BOTTLE
static BigFluidAmount
BUCKET
java.math.BigInteger
denominator
Always greater than 0.static BigFluidAmount
NEGATIVE_ONE
java.math.BigInteger
numerator
static BigFluidAmount
ONE
java.math.BigInteger
whole
static BigFluidAmount
ZERO
-
Constructor Summary
Constructors Constructor Description BigFluidAmount(FluidAmount from)
-
Method Summary
Modifier and Type Method Description BigFluidAmount
add(long by)
BigFluidAmount
add(BigFluidAmount by)
BigFluidAmount
add(FluidAmount by)
BigFluidAmount
asBigInt()
double
asInexactDouble()
FluidAmount
asLongIntExact()
FluidAmount
asLongIntRounded()
Converts this into a normal long-basedFluidAmount
.FluidAmount
asLongIntRounded(java.math.RoundingMode rounding)
Converts this into a normal long-basedFluidAmount
.FluidAmount
asLongIntSaturated()
Converts this into a normal long-basedFluidAmount
.int
compareTo(BigFluidAmount o)
Null is treated as zeroBigFluidAmount
div(long by)
BigFluidAmount
div(BigFluidAmount by)
BigFluidAmount
div(FluidAmount by)
boolean
equals(BigFluidAmount other)
boolean
equals(java.lang.Object obj)
boolean
fitsInLongInt()
BigFluidAmount
gcd(BigFluidAmount other)
BigFluidAmount
gcd(FluidAmount other)
BigFluidAmount
getDivisor()
int
hashCode()
boolean
isGreaterThan(BigFluidAmount other)
Null is treated as zeroboolean
isGreaterThanOrEqual(BigFluidAmount other)
Null is treated as zeroboolean
isLessThan(BigFluidAmount other)
Null is treated as zeroboolean
isLessThanOrEqual(BigFluidAmount other)
Null is treated as zeroboolean
isNegative()
boolean
isPositive()
boolean
isZero()
BigFluidAmount
lcm(BigFluidAmount other)
BigFluidAmount
max(BigFluidAmount other)
BigFluidAmount
min(BigFluidAmount other)
BigFluidAmount
mul(long by)
BigFluidAmount
mul(BigFluidAmount by)
BigFluidAmount
mul(FluidAmount by)
BigFluidAmount
negate()
static BigFluidAmount
of(java.math.BigInteger numerator, java.math.BigInteger denominator)
Creates a newFluidAmount
with the given values.static BigFluidAmount
of(java.math.BigInteger whole, java.math.BigInteger numerator, java.math.BigInteger denominator)
Creates a newFluidAmount
with the given values.BigFluidAmount
reciprocal()
int
sign()
BigFluidAmount
sub(long by)
BigFluidAmount
sub(BigFluidAmount by)
BigFluidAmount
sub(FluidAmount by)
java.lang.String
toString()
-
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 newFluidAmount
with 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 newFluidAmount
with 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_BUCKETS
orFluidAmount.MAX_BUCKETS
according this thesign()
. -
asLongIntRounded
Converts this into a normal long-basedFluidAmount
.If
whole
is too large to fit in a long then eitherFluidAmount.MIN_BUCKETS
orFluidAmount.MAX_BUCKETS
is returned (depending on this sign).Otherwise this is approximately rounded to a valid value.
-
asLongIntRounded
Converts this into a normal long-basedFluidAmount
.If
whole
is too large to fit in a long then eitherFluidAmount.MIN_BUCKETS
orFluidAmount.MAX_BUCKETS
is 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:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
equals
- Returns:
- True if the number that this
FluidAmount
represents is equal to the number that the givenFluidAmount
represents.
-
compareTo
Null is treated as zero- Specified by:
compareTo
in 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.
-