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 Summary
Static MethodsModifier and TypeMethodDescriptionstatic booleanfilter(net.minecraft.world.item.ItemStack stack, BiPredicate<IIndividual, ILifeStage> predicate) static booleanfilter(net.minecraft.world.item.ItemStack stack, Predicate<IIndividual> predicate) Checks if the individual in this stack is present and if it matches some predicate.static IGenomegetGenome(net.minecraft.world.item.ItemStack stack) static IIndividualgetIndividual(net.minecraft.world.item.ItemStack stack) static ILifeStagegetLifeStage(net.minecraft.world.item.ItemStack stack) static <S extends ISpecies<?>>
SgetSpecies(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.static ISpeciesType<?, ?> getSpeciesType(net.minecraft.world.item.ItemStack stack) static booleanhasIndividual(net.minecraft.world.item.ItemStack stack) static voidifPresent(net.minecraft.world.item.ItemStack stack, BiConsumer<IIndividual, ILifeStage> action) static voidifPresent(net.minecraft.world.item.ItemStack stack, Consumer<IIndividual> action) static booleanisIndividual(net.minecraft.world.item.ItemStack stack)
-
Method Details
-
ifPresent
static void ifPresent(net.minecraft.world.item.ItemStack stack, BiConsumer<IIndividual, ILifeStage> action) -
ifPresent
-
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
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:
trueif 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
-
getGenome
-
getLifeStage
-
getSpeciesType
-
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.
-