Class BaseCapability<T,C>

java.lang.Object
net.neoforged.neoforge.capabilities.BaseCapability<T,C>
Type Parameters:
T - Type of queried objects.
C - Type of the additional context.
Direct Known Subclasses:
BlockCapability, EntityCapability, ItemCapability

public abstract class BaseCapability<T,C> extends Object
Base class to reuse code common between most/all *Capability implementation.

This is only relevant for authors of new capability types (i.e. which are not blocks, entities, or items). Otherwise, use one of the subclasses directly.

  • Field Details

    • name

      private final ResourceLocation name
    • typeClass

      private final Class<T> typeClass
    • contextClass

      private final Class<C> contextClass
  • Constructor Details

  • Method Details

    • name

      public final ResourceLocation name()
      Returns the name of this capability.
      Returns:
      the name of this capability
    • typeClass

      public final Class<T> typeClass()
      Returns the type of queried objects.
      Returns:
      the type of queried objects
    • contextClass

      public final Class<C> contextClass()
      Returns the type of the additional context.
      Returns:
      the type of the additional context