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 Summary
Modifier and TypeFieldDescriptionprivate 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 TypeMethodDescriptionboolean
boolean
areCapsCompatible(CapabilityProvider<B> other)
protected void
deserializeCaps(CompoundTag tag)
private void
doGatherCapabilities(ICapabilityProvider parent)
protected void
protected void
gatherCapabilities(Supplier<ICapabilityProvider> parent)
protected void
gatherCapabilities(ICapabilityProvider parent)
protected CapabilityDispatcher
<T> LazyOptional<T>
getCapability(Capability<T> cap, Direction side)
Retrieves the Optional handler for the capability requested on the specific side.void
void
protected 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
-
getCapabilities
-
areCapsCompatible
-
areCapsCompatible
-
serializeCaps
-
deserializeCaps
-
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 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.
-