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 java.lang.Object implements ICapabilityProvider
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Class<B>
baseClass
private CapabilityDispatcher
capabilities
private boolean
initialized
private boolean
isLazy
private CompoundNBT
lazyData
private java.util.function.Supplier<ICapabilityProvider>
lazyParentSupplier
(package private) static boolean
SUPPORTS_LAZY_CAPABILITIES
private boolean
valid
-
Constructor Summary
Constructors Modifier Constructor Description protected
CapabilityProvider(java.lang.Class<B> baseClass)
protected
CapabilityProvider(java.lang.Class<B> baseClass, boolean isLazy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
areCapsCompatible(CapabilityDispatcher other)
boolean
areCapsCompatible(CapabilityProvider<B> other)
protected void
deserializeCaps(CompoundNBT tag)
private void
doGatherCapabilities(ICapabilityProvider parent)
protected void
gatherCapabilities()
protected void
gatherCapabilities(java.util.function.Supplier<ICapabilityProvider> parent)
protected void
gatherCapabilities(ICapabilityProvider parent)
protected CapabilityDispatcher
getCapabilities()
<T> LazyOptional<T>
getCapability(Capability<T> cap, Direction side)
Retrieves the Optional handler for the capability requested on the specific side.protected void
invalidateCaps()
protected void
reviveCaps()
protected CompoundNBT
serializeCaps()
-
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 Detail
-
SUPPORTS_LAZY_CAPABILITIES
static boolean SUPPORTS_LAZY_CAPABILITIES
-
baseClass
@Nonnull private final java.lang.Class<B extends CapabilityProvider<B>> baseClass
-
capabilities
@Nullable private CapabilityDispatcher capabilities
-
valid
private boolean valid
-
isLazy
private boolean isLazy
-
lazyParentSupplier
private java.util.function.Supplier<ICapabilityProvider> lazyParentSupplier
-
lazyData
private CompoundNBT lazyData
-
initialized
private boolean initialized
-
-
Method Detail
-
gatherCapabilities
protected final void gatherCapabilities()
-
gatherCapabilities
protected final void gatherCapabilities(@Nullable ICapabilityProvider parent)
-
gatherCapabilities
protected final void gatherCapabilities(@Nullable java.util.function.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 interfaceICapabilityProvider
- Returns:
- The requested an optional holding the requested capability.
-
-