Package forestry.api.genetics.capability
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 Summary
Modifier 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 IIndividualHandlerItemget(net.minecraft.world.item.ItemStack stack) Retrieves the individual handler capability from the item stack if it is present.net.minecraft.world.item.ItemStackstatic IIndividualgetIndividual(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.ISpeciesType<?,?> getStage()static voidifPresent(net.minecraft.world.item.ItemStack stack, BiConsumer<IIndividual, ILifeStage> action) static voidifPresent(net.minecraft.world.item.ItemStack stack, Consumer<IIndividual> action) booleanstatic booleanisIndividual(net.minecraft.world.item.ItemStack stack)
-
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:
trueif 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
-
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
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) -
get
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
-
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.
-