Class Capability<T>


  • public class Capability<T>
    extends java.lang.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 Detail

      • name

        private final java.lang.String name
      • 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. See 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 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.