public class Capability<T>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
Capability.IStorage<T> |
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.Callable<? extends T> |
factory |
private java.lang.String |
name |
private Capability.IStorage<T> |
storage |
Constructor and Description |
---|
Capability(java.lang.String name,
Capability.IStorage<T> storage,
java.util.concurrent.Callable<? extends T> factory) |
Modifier and Type | Method and Description |
---|---|
<R> R |
cast(T instance)
Use this inside ICapabilityProvider.getCapability to avoid unchecked cast warnings.
|
T |
getDefaultInstance()
A NEW instance of the default implementation.
|
java.lang.String |
getName() |
Capability.IStorage<T> |
getStorage() |
void |
readNBT(T instance,
EnumFacing side,
NBTBase nbt)
Quick access to the IStorage's readNBT.
|
NBTBase |
writeNBT(T instance,
EnumFacing side)
Quick access to the IStorage's writeNBT.
|
private final java.lang.String name
private final Capability.IStorage<T> storage
private final java.util.concurrent.Callable<? extends T> factory
Capability(java.lang.String name, Capability.IStorage<T> storage, java.util.concurrent.Callable<? extends T> factory)
public java.lang.String getName()
public Capability.IStorage<T> getStorage()
public void readNBT(T instance, EnumFacing side, NBTBase nbt)
Capability.IStorage.readNBT(Capability, Object, EnumFacing, NBTBase)
for documentation.@Nullable public NBTBase writeNBT(T instance, EnumFacing side)
Capability.IStorage.writeNBT(Capability, Object, EnumFacing)
for documentation.@Nullable public T getDefaultInstance()
public <R> R cast(T instance)