Class NeighbouringCapabilityCache<T>
java.lang.Object
me.desht.pneumaticcraft.common.capabilities.NeighbouringCapabilityCache<T>
Capability cache for neighbours of a
Typical usage is to
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()voidclear(@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 neighbouringBlockEntity.@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 neighbouringBlockEntity.
-
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 neighbouringBlockEntity.- 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 neighbouringBlockEntity. Also handles registering an invalidation listener to clear the cached capability.- Parameters:
capability- Capability to get and cache.blockEntity- OriginatingBlockEntity.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)
-