Class CapabilityProvider<B extends CapabilityProvider<B>>

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

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

    • SUPPORTS_LAZY_CAPABILITIES

      static boolean SUPPORTS_LAZY_CAPABILITIES
    • baseClass

      @Nonnull private final Class<B extends CapabilityProvider<B>> baseClass
    • capabilities

      @Nullable private CapabilityDispatcher capabilities
    • valid

      private boolean valid
    • isLazy

      private boolean isLazy
    • lazyParentSupplier

      private Supplier<ICapabilityProvider> lazyParentSupplier
    • lazyData

      private CompoundTag lazyData
    • 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 ICapabilityProvider parent)
    • gatherCapabilities

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

      private void doGatherCapabilities(@Nullable ICapabilityProvider parent)
    • getCapabilities

      @Nullable protected final CapabilityDispatcher getCapabilities()
    • areCapsCompatible

      public final boolean areCapsCompatible(CapabilityProvider<B> other)
    • areCapsCompatible

      public final boolean areCapsCompatible(@Nullable CapabilityDispatcher other)
    • serializeCaps

      @Nullable protected final CompoundTag serializeCaps()
    • deserializeCaps

      protected final void deserializeCaps(CompoundTag tag)
    • invalidateCaps

      public void invalidateCaps()
    • reviveCaps

      public void reviveCaps()
    • getCapability

      @Nonnull public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @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.