Interface IBlockCapabilityProvider<T,C>

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface IBlockCapabilityProvider<T,C>
  • Method Summary

    Modifier and Type
    Method
    Description
    getCapability(Level level, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, C context)
    Returns the capability, or null if not available.
  • Method Details

    • getCapability

      @Nullable T getCapability(Level level, BlockPos pos, BlockState state, @Nullable @Nullable BlockEntity blockEntity, C context)
      Returns the capability, or null if not available.

      If a previously returned capability is not valid anymore, or if a new capability is available, ILevelExtension.invalidateCapabilities(BlockPos) MUST be called to notify the caches (see below).

      Capabilities are automatically invalidated by NeoForge in the following cases:

      • Chunk loads and unloads.
      • Block entity loads and unloads.
      • Block entity placement and destruction.
      In ALL other cases, it is the responsibility of the modder to call ILevelExtension.invalidateCapabilities(BlockPos). For example:
      • If the configuration of a block entity changes.
      • If a plain block is placed or changes state, by overriding onPlace. Be careful that if you don't invalidate for every state change, you should not capture the state parameter because the state might change!
      • If a plain block is removed, by overriding onRemove.
      Parameters:
      level - The level.
      pos - The position.
      state - The block state.
      blockEntity - The block entity, if present. null means that there is no block entity at the target position.
      context - Extra context, capability-dependent.