Interface IIndividualHandlerItem


public interface IIndividualHandlerItem
The individual handler manages an item's genetic information. It contains the IIndividual and ILifeStage of the item. This class can be thought of as the IIndividual analog of IFluidItemHandler. In 1.21, this will be replaced by Components.
  • Method Details

    • getContainer

      net.minecraft.world.item.ItemStack getContainer()
      Returns:
      The item containing this individual.
    • getSpeciesType

      ISpeciesType<?,?> getSpeciesType()
      Returns:
      The species type of this individual. Used for serialization/deserialization purposes, among other things.
    • getStage

      ILifeStage getStage()
      Returns:
      The life stage of this individual
    • getIndividual

      IIndividual getIndividual()
      Returns:
      The individual contained in this handler
    • isGeneticForm

      boolean isGeneticForm()
      Returns:
      true if this individual is the genetic form. Returns false for things like Vanilla saplings.
    • ifPresent

      static void ifPresent(net.minecraft.world.item.ItemStack stack, BiConsumer<IIndividual,ILifeStage> action)
    • ifPresent

      static void ifPresent(net.minecraft.world.item.ItemStack stack, Consumer<IIndividual> action)
    • isIndividual

      static boolean isIndividual(net.minecraft.world.item.ItemStack stack)
      Returns:
      Whether the given item has an individual capability. (Vanilla saplings have a capability too)
    • filter

      static boolean filter(net.minecraft.world.item.ItemStack stack, Predicate<IIndividual> predicate)
      Checks if the individual in this stack is present and if it matches some predicate.
      Parameters:
      stack - The item to retrieve the individual from.
      predicate - The predicate to test on the individual.
      Returns:
      true if the individual was present and the predicate returned true, false otherwise.
    • filter

      static boolean filter(net.minecraft.world.item.ItemStack stack, BiPredicate<IIndividual,ILifeStage> predicate)
    • get

      @Nullable static IIndividualHandlerItem get(net.minecraft.world.item.ItemStack stack)
      Retrieves the individual handler capability from the item stack if it is present.
      Parameters:
      stack - The item to get the individual handler from.
      Returns:
      The individual handler for this item, or null if none was found.
    • getIndividual

      @Nullable static IIndividual getIndividual(net.minecraft.world.item.ItemStack stack)
    • getSpecies

      static <S extends ISpecies<?>> S getSpecies(net.minecraft.world.item.ItemStack stack, ISpeciesType<S,?> type)
      Gets the species of the current item stack, or returns the default species for the species type.