@FunctionalInterface public interface VariableAmount extends DataSerializable
Implementors of this interface using it in a fashion in which may ever be
serialized must implement the toContainer()
method.
Modifier and Type | Interface and Description |
---|---|
static class |
VariableAmount.BaseAndAddition
Represents a base amount with a random addition, the final amount will be
the base amount plus a random amount between zero (inclusive) and the
addition (exclusive).
|
static class |
VariableAmount.BaseAndVariance
Represents a base amount with a variance, the final amount will be the
base amount plus or minus a random amount between zero (inclusive) and
the variance (exclusive).
|
static class |
VariableAmount.Fixed
Represents a fixed amount, calls to
VariableAmount.Fixed.getAmount(java.util.Random) will always return
the same fixed value. |
static class |
VariableAmount.OptionalAmount
Represents a variable amount which has a base and a chance of varying.
|
Modifier and Type | Method and Description |
---|---|
static VariableAmount |
baseWithOptionalAddition(double base,
double addition,
double chance)
Creates a new variable about which has a base and a chance to apply a
random additional amount.
|
static VariableAmount |
baseWithOptionalAddition(double base,
VariableAmount addition,
double chance)
Creates a new variable about which has a base and a chance to apply a
random additional amount.
|
static VariableAmount |
baseWithOptionalVariance(double base,
double variance,
double chance)
Creates a new variable about which has a base and a chance to apply a
random variance.
|
static VariableAmount |
baseWithOptionalVariance(double base,
VariableAmount variance,
double chance)
Creates a new variable about which has a base and a chance to apply a
random variance.
|
static VariableAmount |
baseWithRandomAddition(double base,
double addition)
Creates a new variable amount which has a base and an additional amount.
|
static VariableAmount |
baseWithRandomAddition(double base,
VariableAmount addition)
Creates a new variable amount which has a base and an additional amount.
|
static VariableAmount |
baseWithVariance(double base,
double variance)
Creates a new variable about which has a base and variance.
|
static VariableAmount |
baseWithVariance(double base,
VariableAmount variance)
Creates a new variable about which has a base and variance.
|
static VariableAmount |
fixed(double value)
Creates a new 'fixed' variable amount, calls to
getAmount(java.util.Random) will
always return the fixed value. |
double |
getAmount(Random rand)
Gets an instance of the variable amount depending on the given random
object.
|
default int |
getContentVersion()
Gets the content version of this
DataSerializable . |
default int |
getFlooredAmount(Random rand)
Gets the amount as if from
getAmount(Random) but floored to the
nearest integer equivalent. |
static VariableAmount |
range(double min,
double max)
Creates a new variable amount which return values between the given min
(inclusive) and max (exclusive).
|
default DataContainer |
toContainer()
Serializes this object into a comprehensible
DataContainer . |
static VariableAmount fixed(double value)
getAmount(java.util.Random)
will
always return the fixed value.value
- The fixed valuestatic VariableAmount range(double min, double max)
min
- The minimum of the range (inclusive)max
- The maximum of the range (exclusive)static VariableAmount baseWithVariance(double base, double variance)
base
- The base valuevariance
- The variancestatic VariableAmount baseWithVariance(double base, VariableAmount variance)
base
- The base valuevariance
- The variancestatic VariableAmount baseWithRandomAddition(double base, double addition)
base
- The base valueaddition
- The additional amountstatic VariableAmount baseWithRandomAddition(double base, VariableAmount addition)
base
- The base valueaddition
- The additional amountstatic VariableAmount baseWithOptionalVariance(double base, double variance, double chance)
base
- The base valuevariance
- The variancechance
- The chance to apply the variancestatic VariableAmount baseWithOptionalVariance(double base, VariableAmount variance, double chance)
base
- The base valuevariance
- The variancechance
- The chance to apply the variancestatic VariableAmount baseWithOptionalAddition(double base, double addition, double chance)
base
- The base valueaddition
- The additional amountchance
- The chance to apply the additional amountstatic VariableAmount baseWithOptionalAddition(double base, VariableAmount addition, double chance)
base
- The base valueaddition
- The additional amountchance
- The chance to apply the additional amountdouble getAmount(Random rand)
rand
- The random objectdefault int getFlooredAmount(Random rand)
getAmount(Random)
but floored to the
nearest integer equivalent.rand
- The random objectdefault DataContainer toContainer()
DataSerializable
DataContainer
.toContainer
in interface DataSerializable
default int getContentVersion()
DataSerializable
DataSerializable
. The version
may differ between instances of plugins and implementations such that
the DataView
from DataSerializable.toContainer()
may include different
information, or remove other information as they are no longer deemed
necessary. The version goes hand in hand with DataContentUpdater
as it is required when there exists any DataView
of this
DataSerializable
with an "older" version.getContentVersion
in interface DataSerializable