Class CapabilityCache<T>

java.lang.Object
me.desht.pneumaticcraft.common.capabilities.CapabilityCache<T>

public final class CapabilityCache<T> extends Object
Generic capability cache.
Typical usage is to get() and use it if it is present, otherwise call set(LazyOptional) to update the capability cache.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    @NotNull net.minecraftforge.common.util.LazyOptional<T>
    get()
     
    @NotNull net.minecraftforge.common.util.LazyOptional<T>
    set(net.minecraftforge.common.util.LazyOptional<T> cap)
    Sets the cached capability.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CapabilityCache

      public CapabilityCache()
  • Method Details

    • get

      @NotNull public @NotNull net.minecraftforge.common.util.LazyOptional<T> get()
    • set

      @NotNull public @NotNull net.minecraftforge.common.util.LazyOptional<T> set(net.minecraftforge.common.util.LazyOptional<T> cap)
      Sets the cached capability. Also handles registering an invalidation listener to clear the cached capability.
      Parameters:
      cap - Capability to set.
      Returns:
      The capability that was set.
    • clear

      public void clear()