Package net.minecraft.screen
Interface ScreenHandlerContext
public interface ScreenHandlerContext
Screen handler contexts allow screen handlers to interact with the
logical server's world safely.
-
Field Summary
Fields Modifier and Type Field Description static ScreenHandlerContextEMPTYThe dummy screen handler context for clientside screen handlers. -
Method Summary
Modifier and Type Method Description static ScreenHandlerContextcreate(World world, BlockPos pos)Returns an active screen handler context.<T> Optional<T>get(BiFunction<World,BlockPos,T> getter)Gets an optional value from this context's world and position with aBiFunctiongetter.default <T> Tget(BiFunction<World,BlockPos,T> getter, T defaultValue)Gets a value from this context's world and position with aBiFunctiongetter.default voidrun(BiConsumer<World,BlockPos> function)Runs aBiConsumerwith this context's world and position if this context is active.
-
Field Details
-
EMPTY
The dummy screen handler context for clientside screen handlers.
-
-
Method Details
-
create
Returns an active screen handler context. Used on the logical server. -
get
Gets an optional value from this context's world and position with aBiFunctiongetter.- Parameters:
getter- a function that gets a non-null value from this context's world and position- Returns:
- a present
Optionalwith the getter's return value, orOptional.empty()if this context is empty
-
get
Gets a value from this context's world and position with aBiFunctiongetter.- Parameters:
getter- a function that gets a non-null value from this context's world and positiondefaultValue- 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
Runs aBiConsumerwith this context's world and position if this context is active.
-