Class CapabilityProvider<B extends ICapabilityProviderImpl<B>>

java.lang.Object
net.minecraftforge.common.capabilities.CapabilityProvider<B>
All Implemented Interfaces:
ICapabilityProvider, ICapabilityProviderImpl<B>
Direct Known Subclasses:
BlockEntity, CapabilityProvider.AsField, Entity, Level

@ParametersAreNonnullByDefault public abstract class CapabilityProvider<B extends ICapabilityProviderImpl<B>> extends Object implements ICapabilityProviderImpl<B>
  • Field Details

    • SUPPORTS_LAZY_CAPABILITIES

      @VisibleForTesting static boolean SUPPORTS_LAZY_CAPABILITIES
    • baseClass

      @NotNull private final @NotNull Class<B extends ICapabilityProviderImpl<B>> baseClass
    • capabilities

      @Nullable private @Nullable CapabilityDispatcher capabilities
    • valid

      private boolean valid
    • isLazy

      private boolean isLazy
    • lazyParentSupplier

      private Supplier<ICapabilityProvider> lazyParentSupplier
    • lazyData

      private CompoundTag lazyData
    • registryAccess

      private HolderLookup.Provider registryAccess
    • initialized

      private boolean initialized
  • Constructor Details

    • CapabilityProvider

      protected CapabilityProvider(Class<B> baseClass)
    • CapabilityProvider

      protected CapabilityProvider(Class<B> baseClass, boolean isLazy)
  • Method Details

    • gatherCapabilities

      protected final void gatherCapabilities()
    • gatherCapabilities

      protected final void gatherCapabilities(@Nullable @Nullable ICapabilityProvider parent)
    • gatherCapabilities

      protected final void gatherCapabilities(@Nullable @Nullable Supplier<ICapabilityProvider> parent)
    • doGatherCapabilities

      private void doGatherCapabilities(@Nullable @Nullable ICapabilityProvider parent)
    • getProvider

      @NotNull B getProvider()
    • getCapabilities

      @Nullable protected final @Nullable CapabilityDispatcher getCapabilities()
    • serializeCaps

      @Nullable protected final @Nullable CompoundTag serializeCaps(HolderLookup.Provider registryAccess)
    • deserializeCaps

      protected final void deserializeCaps(HolderLookup.Provider registryAccess, CompoundTag tag)
    • invalidateCaps

      public void invalidateCaps()
      Specified by:
      invalidateCaps in interface ICapabilityProviderImpl<B extends ICapabilityProviderImpl<B>>
    • reviveCaps

      public void reviveCaps()
      Specified by:
      reviveCaps in interface ICapabilityProviderImpl<B extends ICapabilityProviderImpl<B>>
    • getCapability

      @NotNull public <T> @NotNull LazyOptional<T> getCapability(@NotNull @NotNull Capability<T> cap, @Nullable @Nullable Direction side)
      Description copied from interface: ICapabilityProvider
      Retrieves the Optional handler for the capability requested on the specific side. The return value CAN be the same for multiple faces. Modders are encouraged to cache this value, using the listener capabilities of the Optional to be notified if the requested capability get lost.
      Specified by:
      getCapability in interface ICapabilityProvider
      Parameters:
      cap - The capability to check
      side - The Side to check from, CAN BE NULL. Null is defined to represent 'internal' or 'self'
      Returns:
      The requested an optional holding the requested capability.