Class Capability<T>
- java.lang.Object
-
- net.minecraftforge.common.capabilities.Capability<T>
-
public class Capability<T> extends java.lang.ObjectThis is the core holder object Capabilities. Each capability will have ONE instance of this class, and it will the the one passed into the ICapabilityProvider functions. The CapabilityManager is in charge of creating this class.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceCapability.IStorage<T>
-
Constructor Summary
Constructors Constructor Description Capability(java.lang.String name, Capability.IStorage<T> storage, java.util.concurrent.Callable<? extends T> factory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TgetDefaultInstance()A NEW instance of the default implementation.java.lang.StringgetName()Capability.IStorage<T>getStorage()<R> LazyOptional<R>orEmpty(Capability<R> toCheck, LazyOptional<T> inst)voidreadNBT(T instance, Direction side, INBT nbt)Quick access to the IStorage's readNBT.INBTwriteNBT(T instance, Direction side)Quick access to the IStorage's writeNBT.
-
-
-
Field Detail
-
name
private final java.lang.String name
-
storage
private final Capability.IStorage<T> storage
-
factory
private final java.util.concurrent.Callable<? extends T> factory
-
-
Constructor Detail
-
Capability
Capability(java.lang.String name, Capability.IStorage<T> storage, java.util.concurrent.Callable<? extends T> factory)
-
-
Method Detail
-
getName
public java.lang.String getName()
- Returns:
- The unique name of this capability, typically this is the fully qualified class name for the target interface.
-
getStorage
public Capability.IStorage<T> getStorage()
- Returns:
- An instance of the default storage handler. You can safely use this store your default implementation in NBT.
-
readNBT
public void readNBT(T instance, Direction side, INBT nbt)
Quick access to the IStorage's readNBT. SeeIStorage#readNBT(Capability, Object, EnumFacing, NBTBase)for documentation.
-
writeNBT
@Nullable public INBT writeNBT(T instance, Direction side)
Quick access to the IStorage's writeNBT. SeeIStorage#writeNBT(Capability, Object, EnumFacing)for documentation.
-
getDefaultInstance
@Nullable public T getDefaultInstance()
A NEW instance of the default implementation. If it important to note that if you want to use the default storage you may be required to use this exact implementation. Refer to the owning API of the Capability in question.- Returns:
- A NEW instance of the default implementation.
-
orEmpty
@Nonnull public <R> LazyOptional<R> orEmpty(Capability<R> toCheck, LazyOptional<T> inst)
-
-