Class CapabilityProvider<B extends CapabilityProvider<B>>

java.lang.Object
net.minecraftforge.common.capabilities.CapabilityProvider<B>
All Implemented Interfaces:
ICapabilityProvider
Direct Known Subclasses:
Chunk, Entity, ItemStack, TileEntity, World

@MethodsReturnNonnullByDefault @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 CompoundNBT 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 CompoundNBT serializeCaps()
    • deserializeCaps

      protected final void deserializeCaps(CompoundNBT tag)
    • invalidateCaps

      protected void invalidateCaps()
    • reviveCaps

      protected 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
      Returns:
      The requested an optional holding the requested capability.