Interface IIndividualHandlerItem


public interface IIndividualHandlerItem
Stack helpers for genetic individuals stored in data components. As of 1.21.1, items no longer use capabilities, but Data Components instead.
  • Method Details

    • 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)
    • hasIndividual

      static boolean hasIndividual(net.minecraft.world.item.ItemStack stack)
      Returns:
      Whether the stack carries a genome component. Weaker than isIndividual(net.minecraft.world.item.ItemStack): a stack can hold the component without resolving to an individual, ex. villager trade wildcard bees
    • 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)
    • getIndividual

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

      @Nullable static IGenome getGenome(net.minecraft.world.item.ItemStack stack)
    • getLifeStage

      @Nullable static ILifeStage getLifeStage(net.minecraft.world.item.ItemStack stack)
    • getSpeciesType

      @Nullable static ISpeciesType<?,?> getSpeciesType(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.