Class IngredientComponent<T,M>
java.lang.Object
org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T,M>
- Type Parameters:
T
- The instance type.M
- The matching condition parameter, may be Void. Instances MUST properly implement the equals method.
- All Implemented Interfaces:
Comparable<IngredientComponent<?,
?>>
public final class IngredientComponent<T,M>
extends Object
implements Comparable<IngredientComponent<?,?>>
A IngredientComponent is a type of component that can be used as ingredients inside recipes.
-
Field Summary
Modifier and TypeFieldDescriptionstatic IngredientComponent<Long,
Boolean> static IngredientComponent<net.minecraftforge.fluids.FluidStack,
Integer> static IngredientComponent<net.minecraft.world.item.ItemStack,
Integer> static net.minecraftforge.registries.IForgeRegistry<IngredientComponent<?,
?>> -
Constructor Summary
ConstructorDescriptionIngredientComponent
(String name, IIngredientMatcher<T, M> matcher, IIngredientSerializer<T, M> serializer, List<IngredientComponentCategoryType<T, M, ?>> categoryTypes) IngredientComponent
(net.minecraft.resources.ResourceLocation name, IIngredientMatcher<T, M> matcher, IIngredientSerializer<T, M> serializer, List<IngredientComponentCategoryType<T, M, ?>> categoryTypes) -
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(IngredientComponent<?, ?> that) protected net.minecraftforge.common.capabilities.CapabilityDispatcher
<TC> net.minecraftforge.common.util.LazyOptional<TC>
getCapability
(net.minecraftforge.common.capabilities.Capability<TC> capability) Get the given capability.static IngredientComponent<?,
?> getIngredientComponentForStorageCapability
(net.minecraftforge.common.capabilities.Capability<?> capability) Get the ingredient component that was attached to the given storage capability.net.minecraft.resources.ResourceLocation
getName()
getStorage
(net.minecraftforge.common.capabilities.ICapabilityProvider capabilityProvider, net.minecraft.core.Direction facing) Get the ingredient storage within the given capability provider.getStorageWrapperHandler
(net.minecraftforge.common.capabilities.Capability<S> capability) Get the storage wrapper handler for this component.Collection<net.minecraftforge.common.capabilities.Capability<?>>
static void
onRegistriesCreate
(net.minecraftforge.registries.NewRegistryEvent event) <S> void
setStorageWrapperHandler
(net.minecraftforge.common.capabilities.Capability<S> capability, IIngredientComponentStorageWrapperHandler<T, M, ? super S> storageWrapperHandler) Set the storage wrapper handler for this component.setTranslationKey
(String translationKey) toString()
Wrap the given instance inside an equals, hashCode and compareTo-safe holder.
-
Field Details
-
REGISTRY
-
ITEMSTACK
-
FLUIDSTACK
-
ENERGY
-
-
Constructor Details
-
IngredientComponent
public IngredientComponent(net.minecraft.resources.ResourceLocation name, IIngredientMatcher<T, M> matcher, IIngredientSerializer<T, M> serializer, List<IngredientComponentCategoryType<T, M, ?>> categoryTypes) -
IngredientComponent
public IngredientComponent(String name, IIngredientMatcher<T, M> matcher, IIngredientSerializer<T, M> serializer, List<IngredientComponentCategoryType<T, M, ?>> categoryTypes)
-
-
Method Details
-
onRegistriesCreate
public static void onRegistriesCreate(net.minecraftforge.registries.NewRegistryEvent event) -
getName
public net.minecraft.resources.ResourceLocation getName() -
toString
-
gatherCapabilities
protected net.minecraftforge.common.capabilities.CapabilityDispatcher gatherCapabilities() -
getCapability
public <TC> net.minecraftforge.common.util.LazyOptional<TC> getCapability(net.minecraftforge.common.capabilities.Capability<TC> capability) Get the given capability.- Type Parameters:
TC
- The capability type.- Parameters:
capability
- The capability to get.- Returns:
- The lazy optional capability instance.
-
setTranslationKey
-
getTranslationKey
- Returns:
- The unlocalized name.
-
getMatcher
- Returns:
- A matcher instance for comparing instances of this component type.
-
getSerializer
- Returns:
- A (de)serializer instance for this component type.
-
getCategoryTypes
- Returns:
- The category types of this component.
-
wrap
Wrap the given instance inside an equals, hashCode and compareTo-safe holder.- Parameters:
instance
- An instance.- Returns:
- The wrapped instance.
-
getPrimaryQuantifier
- Returns:
- The primary quantifier category type, can be null.
-
setStorageWrapperHandler
public <S> void setStorageWrapperHandler(net.minecraftforge.common.capabilities.Capability<S> capability, IIngredientComponentStorageWrapperHandler<T, M, ? super S> storageWrapperHandler) Set the storage wrapper handler for this component.- Type Parameters:
S
- The capability type.- Parameters:
capability
- The capability for the storage wrapper.storageWrapperHandler
- The storage wrapper handler.
-
getStorageWrapperHandler
@Nullable public <S> IIngredientComponentStorageWrapperHandler<T,M, getStorageWrapperHandlerS> (net.minecraftforge.common.capabilities.Capability<S> capability) Get the storage wrapper handler for this component.- Type Parameters:
S
- The external storage type.- Parameters:
capability
- The capability to get the storage wrapper for.- Returns:
- The storage wrapper handler, can be null if none has been assigned.
-
getStorageWrapperHandlerCapabilities
public Collection<net.minecraftforge.common.capabilities.Capability<?>> getStorageWrapperHandlerCapabilities()- Returns:
- All supported capabilities that have registered wrapper handlers
-
getIngredientComponentForStorageCapability
@Nullable public static IngredientComponent<?,?> getIngredientComponentForStorageCapability(net.minecraftforge.common.capabilities.Capability<?> capability) Get the ingredient component that was attached to the given storage capability.- Parameters:
capability
- A storage capability.- Returns:
- The attached ingredient component, or null.
-
getStorage
@Nullable public IIngredientComponentStorage<T,M> getStorage(net.minecraftforge.common.capabilities.ICapabilityProvider capabilityProvider, @Nullable net.minecraft.core.Direction facing) Get the ingredient storage within the given capability provider. This will first check if the capability provider has aIIngredientComponentStorageHandler
capability and it will try to fetch the storage from there. If this fails, then the storage wrapper handlers that are registered in this ingredient component will be iterated and the first successful one will be returned.- Parameters:
capabilityProvider
- A capability provider.facing
- The side to get the storage from.- Returns:
- An ingredient storage, or null if it does not exist.
-
compareTo
- Specified by:
compareTo
in interfaceComparable<T>
-