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
,ItemStack
,Level
@ParametersAreNonnullByDefault
public abstract class CapabilityProvider<B extends ICapabilityProviderImpl<B>>
extends Object
implements ICapabilityProviderImpl<B>
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
CapabilityProvider.AsField<B extends ICapabilityProviderImpl<B>>
Special implementation for cases which have a superclass and can't extend CapabilityProvider directly. -
Field Summary
Modifier and TypeFieldDescriptionprivate @Nullable CapabilityDispatcher
private boolean
private boolean
private CompoundTag
private Supplier<ICapabilityProvider>
(package private) static boolean
private boolean
-
Constructor Summary
ModifierConstructorDescriptionprotected
CapabilityProvider
(Class<B> baseClass) protected
CapabilityProvider
(Class<B> baseClass, boolean isLazy) -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
areCapsCompatible
(@Nullable CapabilityDispatcher other) final boolean
areCapsCompatible
(CapabilityProvider<B> other) protected final void
private void
doGatherCapabilities
(@Nullable ICapabilityProvider parent) protected final void
protected final void
gatherCapabilities
(@Nullable Supplier<ICapabilityProvider> parent) protected final void
gatherCapabilities
(@Nullable ICapabilityProvider parent) protected final @Nullable CapabilityDispatcher
<T> @NotNull LazyOptional<T>
getCapability
(@NotNull Capability<T> cap, @Nullable Direction side) Retrieves the Optional handler for the capability requested on the specific side.(package private) B
void
void
protected final @Nullable CompoundTag
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minecraftforge.common.capabilities.ICapabilityProvider
getCapability
-
Field Details
-
SUPPORTS_LAZY_CAPABILITIES
static boolean SUPPORTS_LAZY_CAPABILITIES -
baseClass
-
capabilities
-
valid
private boolean valid -
isLazy
private boolean isLazy -
lazyParentSupplier
-
lazyData
-
initialized
private boolean initialized
-
-
Constructor Details
-
CapabilityProvider
-
CapabilityProvider
-
-
Method Details
-
gatherCapabilities
protected final void gatherCapabilities() -
gatherCapabilities
-
gatherCapabilities
-
doGatherCapabilities
-
getProvider
-
getCapabilities
-
areCapsCompatible
- Specified by:
areCapsCompatible
in interfaceICapabilityProviderImpl<B extends ICapabilityProviderImpl<B>>
-
areCapsCompatible
- Specified by:
areCapsCompatible
in interfaceICapabilityProviderImpl<B extends ICapabilityProviderImpl<B>>
-
serializeCaps
-
deserializeCaps
-
invalidateCaps
public void invalidateCaps()- Specified by:
invalidateCaps
in interfaceICapabilityProviderImpl<B extends ICapabilityProviderImpl<B>>
-
reviveCaps
public void reviveCaps()- Specified by:
reviveCaps
in interfaceICapabilityProviderImpl<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 interfaceICapabilityProvider
- Parameters:
cap
- The capability to checkside
- 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.
-