PrefabWeights

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 Function nameFunc
@Nonnull final Random random

getWeight

public double getWeight (final String prefab)

Method getWeight.

Parameters:
final String prefab

setWeight

public void setWeight (final String prefab, final double weight)

Method setWeight.

Parameters:
final String prefab
final double weight

removeWeight

public void removeWeight (final String prefab)

Method removeWeight.

Parameters:
final String prefab

getDefaultWeight

public double getDefaultWeight ()

Method getDefaultWeight.

setDefaultWeight

public void setDefaultWeight (final double defaultWeight)

Method setDefaultWeight.

Parameters:
final double defaultWeight

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 Function nameFunc

parse

static PrefabWeights parse (@Nonnull final String mappingString)

Method parse.

Parameters:
@Nonnull final String mappingString

entrySet

public Set> entrySet ()

Method entrySet.

checkWeight

static void checkWeight (final String prefab, final double weight)

Method checkWeight.

Parameters:
final String prefab
final double weight

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"
weight weight
prefab prefab

KeyedCodec

public new KeyedCodec ("Weights", PrefabWeights.MAP_CODEC)

Method KeyedCodec.

Parameters:
"Weights" "Weights"
PrefabWeights.MAP_CODEC PrefabWeights.MAP_CODEC

WeightMapValidator

public new WeightMapValidator ()

Method WeightMapValidator.

accept

public void accept (@Nonnull final Object2DoubleMap stringObject2DoubleMap, final ValidationResults results)

Method accept.

Parameters:
@Nonnull final Object2DoubleMap stringObject2DoubleMap
final ValidationResults results