Class IntRange
java.lang.Object
net.minecraft.world.level.storage.loot.IntRange
- All Implemented Interfaces:
LootContextUser, Validatable
A possibly unbounded range of integers based on
LootContext. Minimum and maximum are given in the form of NumberProviders.
Minimum and maximum are both optional. If given, they are both inclusive.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static interfaceprivate static interface -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<IntRange> private final IntRange.IntLimiterprivate final @Nullable NumberProviderprivate final @Nullable NumberProviderprivate final IntRange.IntCheckerprivate static final com.mojang.serialization.Codec<IntRange> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateIntRange(Optional<NumberProvider> min, Optional<NumberProvider> max) privateIntRange(@Nullable NumberProvider min, @Nullable NumberProvider max) -
Method Summary
Modifier and TypeMethodDescriptionintclamp(LootContext context, int value) Clamp the given value so that it falls within this IntRange.static IntRangeexact(int value) Create an IntRange that contains only exactly the given value.static IntRangelowerBound(int value) Create an IntRange with the given minimum (inclusive) and no upper bound.static IntRangerange(int min, int max) Create an IntRange that ranges frommintomax, both inclusive.booleantest(LootContext context, int value) Check whether the given value falls within this IntRange.private OptionalIntstatic IntRangeupperBound(int value) Create an IntRange with the given maximum (inclusive) and no lower bound.voidvalidate(ValidationContext context) Validate that this object is used correctly according to the given ValidationContext.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface LootContextUser
getReferencedContextParams
-
Field Details
-
RECORD_CODEC
-
CODEC
-
min
-
max
-
limiter
-
predicate
-
-
Constructor Details
-
IntRange
-
IntRange
-
-
Method Details
-
validate
Description copied from interface:LootContextUserValidate that this object is used correctly according to the given ValidationContext.- Specified by:
validatein interfaceLootContextUser- Specified by:
validatein interfaceValidatable
-
exact
Create an IntRange that contains only exactly the given value. -
range
Create an IntRange that ranges frommintomax, both inclusive. -
lowerBound
Create an IntRange with the given minimum (inclusive) and no upper bound. -
upperBound
Create an IntRange with the given maximum (inclusive) and no lower bound. -
clamp
Clamp the given value so that it falls within this IntRange. -
test
Check whether the given value falls within this IntRange. -
unpackExact
-