Class VariableAmount.OptionalAmount
- java.lang.Object
-
- org.spongepowered.api.util.weighted.VariableAmount.OptionalAmount
-
- All Implemented Interfaces:
DataSerializable
,VariableAmount
- Enclosing interface:
- VariableAmount
public static class VariableAmount.OptionalAmount extends Object implements VariableAmount
Represents a variable amount which has a base and a chance of varying. This wraps anotherVariableAmount
which it refers to if the chance succeeds.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.spongepowered.api.util.weighted.VariableAmount
VariableAmount.BaseAndAddition, VariableAmount.BaseAndVariance, VariableAmount.Fixed, VariableAmount.OptionalAmount
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
amount(Random rand)
Gets an instance of the variable amount depending on the given random object.int
contentVersion()
Gets the content version of thisDataSerializable
.boolean
equals(Object obj)
int
hashCode()
DataContainer
toContainer()
Serializes this object into a comprehensibleDataContainer
.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.spongepowered.api.util.weighted.VariableAmount
flooredAmount
-
-
-
-
Method Detail
-
amount
public double amount(Random rand)
Description copied from interface:VariableAmount
Gets an instance of the variable amount depending on the given random object.- Specified by:
amount
in interfaceVariableAmount
- Parameters:
rand
- The random object- Returns:
- The amount
-
toContainer
public DataContainer toContainer()
Description copied from interface:DataSerializable
Serializes this object into a comprehensibleDataContainer
.- Specified by:
toContainer
in interfaceDataSerializable
- Specified by:
toContainer
in interfaceVariableAmount
- Returns:
- A newly created DataContainer
-
contentVersion
public int contentVersion()
Description copied from interface:DataSerializable
Gets the content version of thisDataSerializable
. The version may differ between instances of plugins and implementations such that theDataView
fromDataSerializable.toContainer()
may include different information, or remove other information as they are no longer deemed necessary. The version goes hand in hand withDataContentUpdater
as it is required when there exists anyDataView
of thisDataSerializable
with an "older" version.- Specified by:
contentVersion
in interfaceDataSerializable
- Specified by:
contentVersion
in interfaceVariableAmount
- Returns:
- The version of the content being serialized
-
-