Class IntRange

java.lang.Object
net.minecraft.world.level.storage.loot.IntRange
All Implemented Interfaces:
LootContextUser, Validatable

public class IntRange extends Object implements LootContextUser
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.
  • Field Details

  • Constructor Details

  • Method Details

    • validate

      public void validate(ValidationContext context)
      Description copied from interface: LootContextUser
      Validate that this object is used correctly according to the given ValidationContext.
      Specified by:
      validate in interface LootContextUser
      Specified by:
      validate in interface Validatable
    • exact

      public static IntRange exact(int value)
      Create an IntRange that contains only exactly the given value.
    • range

      public static IntRange range(int min, int max)
      Create an IntRange that ranges from min to max, both inclusive.
    • lowerBound

      public static IntRange lowerBound(int value)
      Create an IntRange with the given minimum (inclusive) and no upper bound.
    • upperBound

      public static IntRange upperBound(int value)
      Create an IntRange with the given maximum (inclusive) and no lower bound.
    • clamp

      public int clamp(LootContext context, int value)
      Clamp the given value so that it falls within this IntRange.
    • test

      public boolean test(LootContext context, int value)
      Check whether the given value falls within this IntRange.
    • unpackExact

      private OptionalInt unpackExact()