Class SlotRange

java.lang.Object
net.xun.lib.common.api.inventory.slot.SlotRange

public class SlotRange extends Object
Flexible slot range that can adapt to different container sizes.
  • Constructor Details

  • Method Details

    • getStart

      public int getStart()
    • getEnd

      public int getEnd()
    • of

      public static SlotRange of(int start, int end)
      Creates a fixed SlotRange from explicit values.
      Parameters:
      start - Starting slot (inclusive)
      end - Ending slot (exclusive)
      Throws:
      IllegalArgumentException - if start > end
    • single

      public static SlotRange single(int slot)
      Creates a single-slot range.
    • contains

      public boolean contains(int slot, net.minecraft.world.Container container)
      Checks if a slot is within this range for a specific container.
    • stream

      public IntStream stream(net.minecraft.world.Container container)
      Gets slots as a stream adjusted for container size.
    • combine

      public static SlotRange combine(SlotRange... ranges)
      Combines multiple slot ranges into one.
    • getSlots

      public Iterable<Integer> getSlots(net.minecraft.world.Container container)
      Gets slots as an iterable sequence adjusted for container size.

      Essential for backward compatibility and iterator-based workflows.

      Parameters:
      container - Target inventory container
      Returns:
      Iterable slot sequence respecting container boundaries