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 Details

  • Constructor Details

  • Method Details

    • onRegistriesCreate

      public static void onRegistriesCreate(net.minecraftforge.registries.NewRegistryEvent event)
    • getName

      public net.minecraft.resources.ResourceLocation getName()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • 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

      public IngredientComponent<T,M> setTranslationKey(String translationKey)
    • getTranslationKey

      public String getTranslationKey()
      Returns:
      The unlocalized name.
    • getMatcher

      public IIngredientMatcher<T,M> getMatcher()
      Returns:
      A matcher instance for comparing instances of this component type.
    • getSerializer

      public IIngredientSerializer<T,M> getSerializer()
      Returns:
      A (de)serializer instance for this component type.
    • getCategoryTypes

      public List<IngredientComponentCategoryType<T,M,?>> getCategoryTypes()
      Returns:
      The category types of this component.
    • wrap

      public IngredientInstanceWrapper<T,M> wrap(T instance)
      Wrap the given instance inside an equals, hashCode and compareTo-safe holder.
      Parameters:
      instance - An instance.
      Returns:
      The wrapped instance.
    • getPrimaryQuantifier

      @Nullable public IngredientComponentCategoryType<T,M,?> 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,S> getStorageWrapperHandler(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 a IIngredientComponentStorageHandler 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

      public int compareTo(IngredientComponent<?,?> that)
      Specified by:
      compareTo in interface Comparable<T>