Class WeightedRandomSelector<T>
java.lang.Object
com.pixelmonmod.pixelmon.api.selector.type.WeightedRandomSelector<T>
- Type Parameters:
T
- The type being selected
This represents a random selector implementation of
Selector
where each value in the list has an assigned weight that dictates
how likely that value is to be selected-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Builder for creating aWeightedRandomSelector
static final record
Represents an instanceof the type with a weight -
Field Summary
Modifier and TypeFieldDescriptionprotected final List<WeightedRandomSelector.WeightedObject<T>>
protected final RandomWeightedSet<T>
-
Constructor Summary
ModifierConstructorDescriptionprotected
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> WeightedRandomSelector.Builder<T>
builder
(T value, double weight) Creates a new builder instance<A> Function<com.mojang.serialization.Codec<A>,
com.mojang.serialization.Codec<? extends Selector<A>>> codec()
Gets the codec for this selectorstatic <A> com.mojang.serialization.Codec<WeightedRandomSelector<A>>
codec
(com.mojang.serialization.Codec<A> codec) Factory for creating an instanced version of this classGets a random elementiterator()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
values
-
originalCache
-
-
Constructor Details
-
WeightedRandomSelector
-
-
Method Details
-
getRandom
Description copied from interface:Selector
Gets a random element -
iterator
-
codec
public <A> Function<com.mojang.serialization.Codec<A>,com.mojang.serialization.Codec<? extends Selector<A>>> codec()Description copied from interface:Selector
Gets the codec for this selector -
codec
public static <A> com.mojang.serialization.Codec<WeightedRandomSelector<A>> codec(com.mojang.serialization.Codec<A> codec) Factory for creating an instanced version of this class- Type Parameters:
A
- The type- Parameters:
codec
- The type's codec- Returns:
- The codec for the instanced selector
-
builder
Creates a new builder instance- Type Parameters:
T
- The type- Parameters:
value
- One of the valuesweight
- The weight of the value- Returns:
- The builder
-