Class BaseCapability<T,C extends @Nullable Object>

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 @Nullable Object> 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 net.minecraft.resources.ResourceLocation name
    • typeClass

      private final Class<T> typeClass
    • contextClass

      private final Class<C extends @Nullable Object> contextClass
  • Constructor Details

    • BaseCapability

      protected BaseCapability(net.minecraft.resources.ResourceLocation name, Class<T> typeClass, Class<C> contextClass)
  • Method Details

    • name

      public final net.minecraft.resources.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