类 Capability<T>

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

public final 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.
  • 字段详细资料

  • 构造器详细资料

    • Capability

      Capability(String name)
  • 方法详细资料

    • getName

      public String getName()
      返回:
      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()
      返回:
      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.
      参数:
      listener - Function to fire when capability is registered.
      返回:
      self, in case people want to use builder pattern.
    • onRegister

      void onRegister()