Interface ClampedInt
- All Superinterfaces:
Comparable<ValueProvider>, IntProvider, ValueProvider, Wrapper
Samples a
source() provider and hard-clamps the result into
[IntProvider.minInclusive(), IntProvider.maxInclusive()]. Because it clamps rather
than rerolls, probability mass outside the bounds piles up on the bounds, so a
clamped uniform is not uniform: the endpoints become disproportionately likely.- Since:
- 3.0.0
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface IntProvider
IntProvider.IntProviderBuilder<T,S> -
Method Summary
Modifier and TypeMethodDescriptionstatic ClampedInt.Builderbuilder()Creates a new builder.static ClampedIntof(IntProvider source, int min, int max) Creates a new clamped int provider.source()The source provider whose sampled value is clamped.default ClampedInt.BuilderConverts this object back to a builder.Methods inherited from interface IntProvider
clamp, max, maxInclusive, min, minInclusiveMethods inherited from interface ValueProvider
compareToMethods inherited from interface Wrapper
asHandle, toMinecraft, unwrap
-
Method Details
-
source
The source provider whose sampled value is clamped.- Returns:
- the source provider
- Since:
- 3.0.0
-
toBuilder
Converts this object back to a builder.- Returns:
- a builder with the same values as this object
- Since:
- 3.0.0
-
of
Creates a new clamped int provider.- Parameters:
source- the source provider to clampmin- the minimum allowed valuemax- the maximum allowed value- Returns:
- the clamped int provider
- Since:
- 3.0.0
-
builder
Creates a new builder.- Returns:
- a new builder
- Since:
- 3.0.0
-