Class TCompletableScreen<R>
java.lang.Object
com.thecsdev.common.scene.Node<TElement>
com.thecsdev.commonmc.api.client.gui.TElement
com.thecsdev.commonmc.api.client.gui.screen.TScreen
com.thecsdev.commonmc.api.client.gui.screen.promise.TCompletableScreen<R>
- Type Parameters:
R- The type of the result that will be returned when the screen is closed.
- All Implemented Interfaces:
INode<TElement>, INodeBounded<TElement,Bounds2i>, INodeRenderable<TElement, TGuiGraphics>, ILastScreenProvider, Iterable<TElement>, Collection<TElement>
- Direct Known Subclasses:
TFileChooserScreen
@Environment(CLIENT)
public abstract class TCompletableScreen<R>
extends TScreen
implements ILastScreenProvider
A
TScreen that provides a CompletableFuture that yields a result
when the screen is closed. This can be used for screens that require user input
or choices, allowing the caller to await the result asynchronously.
If the screen is closed prematurely without a result, the future is canceled.
- See Also:
-
Field Summary
Fields inherited from class TElement
eInitialized -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedTCompletableScreen(@Nullable net.minecraft.client.gui.screens.Screen lastScreen) -
Method Summary
Modifier and TypeMethodDescriptionprotected final BooleanPropertyBooleanPropertythat indicates whether the result of this screen can be completed asynchronously.protected voidCallback method that is invoked whenever thisTScreenis closed viaGui.setScreen(Screen).
This takes place afterTScreen.close()is invoked.final @Nullable net.minecraft.client.gui.screens.ScreenReturns the lastScreeninstance that was open before this one.final @NotNull CompletableFuture<R> Returns a future that will be completed when thisTScreenis closed.voidrenderCallback(@NotNull TGuiGraphics pencil) Callback method that is invoked when thisNodeis being rendered.Methods inherited from class TScreen
close, createWrapperScreen, focusedElementProperty, getAsScreen, getClient, hoveredElementProperty, initCallback, isAllowingInGameHud, isOpen, isPauseScreen, openCallback, sendInput, titlePropertyMethods inherited from class TElement
addRel, boundsProperty, clearAndInit, clipsDescendantsProperty, contextMenuProperty, dragEndCallback, dragStartCallback, findElementAt, focusableProperty, focusGainedCallback, focusLostCallback, forEachVisible, getBaseType, getBounds, getContentBounds, getCursor, getSelf, getTooltip, hoverableProperty, hoverGainedCallback, hoverLostCallback, inputCallback, invalidateTooltipCache, isFocusable, isFocused, isHoverable, isHovered, isHoveredOrFocused, isVisible, move, moveChildren, moveTo, postRenderCallback, removeRel, screenProperty, setBounds, setBounds, setBounds, showContextMenu, tickCallback, tooltipProperty, toString, visiblePropertyMethods inherited from class Node
add, addAll, childAddedCallback, childRemovedCallback, clear, contains, containsAll, equals, findChild, findParent, findSibling, forEach, get, getFirst, getLast, getParent, hashCode, indexOf, isEmpty, iterator, parentProperty, remove, remove, remove, removeAll, retainAll, rootProperty, size, toArray, toArray
-
Constructor Details
-
TCompletableScreen
protected TCompletableScreen() -
TCompletableScreen
protected TCompletableScreen(@Nullable @Nullable net.minecraft.client.gui.screens.Screen lastScreen)
-
-
Method Details
-
getResult
Returns a future that will be completed when thisTScreenis closed. The future will contain the result of the screen, which can be used to perform actions based on the user's input or choices made within the screen. -
canCompleteAsync
BooleanPropertythat indicates whether the result of this screen can be completed asynchronously. If this property is set totrue, the result can be completed from any thread without scheduling on the main thread. If set tofalse, completion actions will be scheduled on the client's main thread to ensure thread safety. -
getLastScreen
@Nullable public final @Nullable net.minecraft.client.gui.screens.Screen getLastScreen()Description copied from interface:ILastScreenProviderReturns the lastScreeninstance that was open before this one.- Specified by:
getLastScreenin interfaceILastScreenProvider
-
renderCallback
Description copied from interface:INodeRenderableCallback method that is invoked when thisNodeis being rendered.- Specified by:
renderCallbackin interfaceINodeRenderable<TElement, TGuiGraphics>- Overrides:
renderCallbackin classTElement- Parameters:
pencil- The rendering context.
-
closeCallback
Callback method that is invoked whenever thisTScreenis closed viaGui.setScreen(Screen).
This takes place afterTScreen.close()is invoked.This method automatically cancels
getResult()if not already completed. Overrides of this method should callsuperto preserve this behavior.- Overrides:
closeCallbackin classTScreen- See Also:
-