Interface ScreenHandlerContext


public interface ScreenHandlerContext
Screen handler contexts allow screen handlers to interact with the logical server's world safely.
  • Field Details

    • EMPTY

      static final ScreenHandlerContext EMPTY
      The dummy screen handler context for clientside screen handlers.
  • Method Details

    • create

      static ScreenHandlerContext create​(World world, BlockPos pos)
      Returns an active screen handler context. Used on the logical server.
    • get

      <T> Optional<T> get​(BiFunction<World,​BlockPos,​T> getter)
      Gets an optional value from this context's world and position with a BiFunction getter.
      Parameters:
      getter - a function that gets a non-null value from this context's world and position
      Returns:
      a present Optional with the getter's return value, or Optional.empty() if this context is empty
    • get

      default <T> T get​(BiFunction<World,​BlockPos,​T> getter, T defaultValue)
      Gets a value from this context's world and position with a BiFunction getter.
      Parameters:
      getter - a function that gets a non-null value from this context's world and position
      defaultValue - a fallback default value, used if this context is empty
      Returns:
      the getter's return value if this context is active, the default value otherwise
    • run

      default void run​(BiConsumer<World,​BlockPos> function)
      Runs a BiConsumer with this context's world and position if this context is active.