Class Capability<T>

java.lang.Object
net.minecraftforge.common.capabilities.Capability<T>

public class Capability<T> extends Object
This is the core holder object Capabilities. Each capability will have ONE instance of this class, and it will the the one passed into the ICapabilityProvider functions. The CapabilityManager is in charge of creating this class.
  • Field Details

  • Constructor Details

    • Capability

      Capability(String name)
  • Method Details

    • getName

      public String getName()
      Returns:
      The unique name of this capability, typically this is the fully qualified class name for the target interface.
    • orEmpty

      @NotNull public <R> @NotNull LazyOptional<R> orEmpty(Capability<R> toCheck, LazyOptional<T> inst)
    • isRegistered

      public boolean isRegistered()
      Returns:
      true if something has registered this capability to the Manager. This is a marker that the class for this capability exists, and can be used.
    • addListener

      public Capability<T> addListener(Consumer<Capability<T>> listener)
      Adds a listener to be called when someone registers this capability. May be called instantly if this is already registered.
      Parameters:
      listener - Function to fire when capability is registered.
      Returns:
      self, in case people want to use builder pattern.
    • onRegister

      void onRegister()