Package net.minecraft.screen
Interface ScreenHandlerContext
public interface ScreenHandlerContext
A screen handler context allows running code on the server side only. Screen
handlers are designed to be used on both sides; any action modifying the world has
to be wrapped in a call to the context. This guarantees that no casting error occurs
inside the screen handler code.
A context with the world is passed to the screen handler on creation on the server. On the server, the context executes the function with the world and the position. On the client, the empty context is used.
- Mappings:
Namespace Name named net/minecraft/screen/ScreenHandlerContext
intermediary net/minecraft/class_3914
official cpu
-
Field Summary
Modifier and TypeFieldDescriptionstatic final ScreenHandlerContext
The dummy screen handler context for clientside screen handlers. -
Method Summary
Modifier and TypeMethodDescriptionstatic ScreenHandlerContext
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 aBiFunction
getter.default <T> T
get
(BiFunction<World, BlockPos, T> getter, T defaultValue) Gets a value from this context's world and position with aBiFunction
getter.default void
run
(BiConsumer<World, BlockPos> function) Runs aBiConsumer
with this context's world and position if this context is active.
-
Field Details
-
EMPTY
The dummy screen handler context for clientside screen handlers.- Mappings:
Namespace Name Mixin selector named EMPTY
Lnet/minecraft/screen/ScreenHandlerContext;EMPTY:Lnet/minecraft/screen/ScreenHandlerContext;
intermediary field_17304
Lnet/minecraft/class_3914;field_17304:Lnet/minecraft/class_3914;
official a
Lcpu;a:Lcpu;
-
-
Method Details
-
create
Returns an active screen handler context. Used on the logical server.- Mappings:
Namespace Name Mixin selector named create
Lnet/minecraft/screen/ScreenHandlerContext;create(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/screen/ScreenHandlerContext;
intermediary method_17392
Lnet/minecraft/class_3914;method_17392(Lnet/minecraft/class_1937;Lnet/minecraft/class_2338;)Lnet/minecraft/class_3914;
official a
Lcpu;a(Ldcg;Lja;)Lcpu;
-
get
Gets an optional value from this context's world and position with aBiFunction
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, orOptional.empty()
if this context is empty - Mappings:
Namespace Name Mixin selector named get
Lnet/minecraft/screen/ScreenHandlerContext;get(Ljava/util/function/BiFunction;)Ljava/util/Optional;
intermediary method_17395
Lnet/minecraft/class_3914;method_17395(Ljava/util/function/BiFunction;)Ljava/util/Optional;
official a
Lcpu;a(Ljava/util/function/BiFunction;)Ljava/util/Optional;
-
get
Gets a value from this context's world and position with aBiFunction
getter.- 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
- Mappings:
Namespace Name Mixin selector named get
Lnet/minecraft/screen/ScreenHandlerContext;get(Ljava/util/function/BiFunction;Ljava/lang/Object;)Ljava/lang/Object;
intermediary method_17396
Lnet/minecraft/class_3914;method_17396(Ljava/util/function/BiFunction;Ljava/lang/Object;)Ljava/lang/Object;
official a
Lcpu;a(Ljava/util/function/BiFunction;Ljava/lang/Object;)Ljava/lang/Object;
-
run
Runs aBiConsumer
with this context's world and position if this context is active.- Mappings:
Namespace Name Mixin selector named run
Lnet/minecraft/screen/ScreenHandlerContext;run(Ljava/util/function/BiConsumer;)V
intermediary method_17393
Lnet/minecraft/class_3914;method_17393(Ljava/util/function/BiConsumer;)V
official a
Lcpu;a(Ljava/util/function/BiConsumer;)V
-