Class NeighbouringCapabilityCache<T>

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

public class NeighbouringCapabilityCache<T> extends Object
Capability cache for neighbours of a BlockEntity.
Typical usage is to get(Direction) and use it if it is present, otherwise call set(Capability, BlockEntity, Direction) to update the capability cache.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
    clear(@NotNull net.minecraft.core.Direction dir)
     
    @NotNull net.minecraftforge.common.util.LazyOptional<T>
    get(@NotNull net.minecraft.core.Direction direction)
    Get cached capability for a neighbouring BlockEntity.
    @NotNull net.minecraftforge.common.util.LazyOptional<T>
    set(@NotNull net.minecraftforge.common.capabilities.Capability<T> capability, @NotNull net.minecraft.world.level.block.entity.BlockEntity blockEntity, @NotNull net.minecraft.core.Direction direction)
    Sets the cached capability for a neighbouring BlockEntity.

    Methods inherited from class java.lang.Object

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

    • NeighbouringCapabilityCache

      public NeighbouringCapabilityCache()
  • Method Details

    • get

      @NotNull public @NotNull net.minecraftforge.common.util.LazyOptional<T> get(@NotNull @NotNull net.minecraft.core.Direction direction)
      Get cached capability for a neighbouring BlockEntity.
      Parameters:
      direction - Direction from the original block entity to a neighbouring block entity.
      Returns:
      The cached capability.
    • set

      @NotNull public @NotNull net.minecraftforge.common.util.LazyOptional<T> set(@NotNull @NotNull net.minecraftforge.common.capabilities.Capability<T> capability, @NotNull @NotNull net.minecraft.world.level.block.entity.BlockEntity blockEntity, @NotNull @NotNull net.minecraft.core.Direction direction)
      Sets the cached capability for a neighbouring BlockEntity. Also handles registering an invalidation listener to clear the cached capability.
      Parameters:
      capability - Capability to get and cache.
      blockEntity - Originating BlockEntity.
      direction - Direction from to a neighbouring block entity to look for a capability.
      Returns:
      The cached capability.
    • clear

      public void clear()
    • clear

      public void clear(@NotNull @NotNull net.minecraft.core.Direction dir)