public class PrefabWeights
Class PrefabWeights. Provides prefabweights functionality for the Hytale server.
java.lang.Object > PrefabWeights
Field Summary
defaultWeight
private
double
defaultWeight
Field defaultWeight.
weightsLookup
private
Object2DoubleMap
weightsLookup
Field weightsLookup.
sum
protected
double
sum
Field sum.
weights
protected
double[]
weights
Field weights.
weightedValue
final
double
weightedValue
Field weightedValue.
sb
final
StringBuilder
sb
Field sb.
name
final
String
name
Field name.
equalsPoint
final
int
equalsPoint
Field equalsPoint.
value
final
String
value
Field value.
weight
final
double
weight
Field weight.
Method Detail
PrefabWeights
public
public
PrefabWeights
()
Method PrefabWeights.
size
public
int
size
()
Method size.
get
public
T
get
(@Nonnull final T[] elements, @Nonnull final Function nameFunc, @Nonnull final Random random)
Method get.
- Parameters:
@Nonnull final T[]elements@Nonnull final FunctionnameFunc@Nonnull final Randomrandom
getWeight
public
double
getWeight
(final String prefab)
Method getWeight.
- Parameters:
final Stringprefab
setWeight
public
void
setWeight
(final String prefab, final double weight)
Method setWeight.
- Parameters:
final Stringprefabfinal doubleweight
removeWeight
public
void
removeWeight
(final String prefab)
Method removeWeight.
- Parameters:
final Stringprefab
getDefaultWeight
public
double
getDefaultWeight
()
Method getDefaultWeight.
setDefaultWeight
public
void
setDefaultWeight
(final double defaultWeight)
Method setDefaultWeight.
- Parameters:
final doubledefaultWeight
getMappingString
public
String
getMappingString
()
Method getMappingString.
toString
public
String
toString
()
Method toString.
initialize
private
void
initialize
(@Nonnull final T[] elements, @Nonnull final Function nameFunc)
Method initialize.
- Parameters:
@Nonnull final T[]elements@Nonnull final FunctionnameFunc
parse
Method parse.
- Parameters:
@Nonnull final StringmappingString
entrySet
public
Set>
entrySet
()
Method entrySet.
checkWeight
static
void
checkWeight
(final String prefab, final double weight)
Method checkWeight.
- Parameters:
final Stringprefabfinal doubleweight
IllegalArgumentException
public
new
IllegalArgumentException
(String.format("Negative weight %.5f assigned to prefab %s", weight, prefab)
Method IllegalArgumentException.
- Parameters:
String.format("Negative weight %.5f assigned to prefab%s"weightweightprefabprefab
KeyedCodec
public
new
KeyedCodec
("Weights", PrefabWeights.MAP_CODEC)
Method KeyedCodec.
- Parameters:
"Weights""Weights"PrefabWeights.MAP_CODECPrefabWeights.MAP_CODEC
WeightMapValidator
public
new
WeightMapValidator
()
Method WeightMapValidator.
accept
public
void
accept
(@Nonnull final Object2DoubleMap stringObject2DoubleMap, final ValidationResults results)
Method accept.
- Parameters:
@Nonnull final Object2DoubleMapstringObject2DoubleMapfinal ValidationResultsresults