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
Modifier and TypeFieldDescriptionstatic final BigFluidAmount
static final BigFluidAmount
final BigInteger
Always greater than 0.static final BigFluidAmount
final BigInteger
static final BigFluidAmount
final BigInteger
static final BigFluidAmount
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionadd
(long by) add
(BigFluidAmount by) add
(FluidAmount by) asBigInt()
double
Converts this into a normal long-basedFluidAmount
.asLongIntRounded
(RoundingMode rounding) Converts this into a normal long-basedFluidAmount
.Converts this into a normal long-basedFluidAmount
.int
Null is treated as zerodiv
(long by) div
(BigFluidAmount by) div
(FluidAmount by) boolean
equals
(BigFluidAmount other) boolean
boolean
gcd
(BigFluidAmount other) gcd
(FluidAmount other) int
hashCode()
boolean
isGreaterThan
(BigFluidAmount other) Null is treated as zeroboolean
Null is treated as zeroboolean
isLessThan
(BigFluidAmount other) Null is treated as zeroboolean
isLessThanOrEqual
(BigFluidAmount other) Null is treated as zeroboolean
boolean
boolean
isZero()
lcm
(BigFluidAmount other) max
(BigFluidAmount other) min
(BigFluidAmount other) mul
(long by) mul
(BigFluidAmount by) mul
(FluidAmount by) negate()
static BigFluidAmount
of
(BigInteger numerator, BigInteger denominator) Creates a newFluidAmount
with the given values.static BigFluidAmount
of
(BigInteger whole, BigInteger numerator, BigInteger denominator) Creates a newFluidAmount
with the given values.int
sign()
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 newFluidAmount
with the given values. This will reduce the fraction into it's simplest form. -
of
Creates a newFluidAmount
with 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_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
-
hashCode
public int hashCode() -
toString
-
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 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.
-