Class Capability<T>

java.lang.Object
net.minecraftforge.common.capabilities.Capability<T>

public class Capability<T> extends Object
This 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.
  • Field Details

  • Constructor Details

  • Method Details

    • getName

      public 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. See Capability.IStorage.readNBT(Capability, Object, EnumFacing, NBTBase) for documentation.
    • writeNBT

      @Nullable public INBT writeNBT(T instance, Direction side)
      Quick access to the IStorage's writeNBT. See Capability.IStorage.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)