Class BlockHandlerCache<T>

java.lang.Object
net.ixdarklord.coolcatcore.api.handler.BlockHandlerCache<T>

public final class BlockHandlerCache<T> extends Object
One position's handler, looked up once and kept until it may have changed: when the block state there changes, when the block entity is removed or replaced (chunk unloads included), or when HandlerType.invalidate(Level, BlockPos) is called for the position. Made by HandlerType.createCache(Level, BlockPos, Direction).

The invalidation callback runs for removed block entities and explicit invalidations; a changed block state is noticed by the next get().

  • Method Details

    • get

      @Nullable public T get()
      The handler, or null if there's none (or the position isn't loaded).
    • invalidate

      public void invalidate()
      Drops the cached handler; the next get() looks again. Runs the invalidation callback.
    • type

      public HandlerType<T> type()
    • level

      public net.minecraft.world.level.Level level()
    • pos

      public net.minecraft.core.BlockPos pos()
    • side

      @Nullable public @Nullable net.minecraft.core.Direction side()