Class ChatPreviewer
ChatScreen, so closing the chat screen and
reopening it would create a new chat previewer. ChatPreviewRequester
handles the actual requesting.
The response to the query can be "consumed" by calling tryConsumeResponse(java.lang.String).
If the response is still valid (i.e. the input has not changed since the query was sent),
consuming the response will return the response and clear it. Note that to prevent race
condition between the player sending the chat message and the response's arrival, responses
can only be consumed after the cooldown (by default, 200L milliseconds)
has passed. It is also possible to get the response text without consuming by calling
getPreviewText().
- Mappings:
Namespace Name official egjintermediary net/minecraft/class_7479named net/minecraft/client/network/ChatPreviewer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final recordA response to the preview query. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final longHow long the previewer should wait before consuming the response since the response arrived at the client in milliseconds.private @Nullable ChatPreviewer.ResponseThe message that is waiting for the previewer to request (i.e.private final ChatPreviewRequesterprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidclear()Clears the last response and the requester's state.voidSetsshouldRenderPreviewtofalseand clears this previewer.Returns the preview text (also known as the last response text), ornullif the server responded as such.(package private) static StringReturns themessagenormalized by trimming it and then normalizing spaces.voidonResponse(int id, @Nullable Text response) Called when the preview response was received.booleanReturns whether the preview should be rendered.tryConsumeResponse(String message) Returns the consumed response text, ornullif the server responded as such, or if the response could not be consumed.voidtryRequest(String message) Tries to send the request to previewmessage.private voidtryRequestInternal(String message) voidSends the message that was waiting for its request delay to pass, if it is able to.
-
Field Details
-
CONSUME_COOLDOWN
private static final long CONSUME_COOLDOWNHow long the previewer should wait before consuming the response since the response arrived at the client in milliseconds. Is 200L.- See Also:
- Mappings:
Namespace Name Mixin selector official aLegj;a:Jintermediary field_39328Lnet/minecraft/class_7479;field_39328:Jnamed CONSUME_COOLDOWNLnet/minecraft/client/network/ChatPreviewer;CONSUME_COOLDOWN:J
-
shouldRenderPreview
private boolean shouldRenderPreview- Mappings:
Namespace Name Mixin selector official bLegj;b:Zintermediary field_39429Lnet/minecraft/class_7479;field_39429:Znamed shouldRenderPreviewLnet/minecraft/client/network/ChatPreviewer;shouldRenderPreview:Z
-
lastPreviewedMessage
- Mappings:
Namespace Name Mixin selector official cLegj;c:Ljava/lang/String;intermediary field_39430Lnet/minecraft/class_7479;field_39430:Ljava/lang/String;named lastPreviewedMessageLnet/minecraft/client/network/ChatPreviewer;lastPreviewedMessage:Ljava/lang/String;
-
pendingRequestMessage
The message that is waiting for the previewer to request (i.e. the next query to be sent). Can benullif there is no such query.- Implementation Note:
- If the message is sent instantly, this field is not set.
- Mappings:
Namespace Name Mixin selector official dLegj;d:Ljava/lang/String;intermediary field_39431Lnet/minecraft/class_7479;field_39431:Ljava/lang/String;named pendingRequestMessageLnet/minecraft/client/network/ChatPreviewer;pendingRequestMessage:Ljava/lang/String;
-
requester
- Mappings:
Namespace Name Mixin selector official eLegj;e:Legi;intermediary field_39432Lnet/minecraft/class_7479;field_39432:Lnet/minecraft/class_7516;named requesterLnet/minecraft/client/network/ChatPreviewer;requester:Lnet/minecraft/client/network/ChatPreviewRequester;
-
lastResponse
- Mappings:
Namespace Name Mixin selector official fLegj;f:Legj$a;intermediary field_39334Lnet/minecraft/class_7479;field_39334:Lnet/minecraft/class_7479$class_7481;named lastResponseLnet/minecraft/client/network/ChatPreviewer;lastResponse:Lnet/minecraft/client/network/ChatPreviewer$Response;
-
-
Constructor Details
-
ChatPreviewer
- Mappings:
Namespace Name Mixin selector official <init>Legj;<init>(Leex;)Vintermediary <init>Lnet/minecraft/class_7479;<init>(Lnet/minecraft/class_310;)Vnamed <init>Lnet/minecraft/client/network/ChatPreviewer;<init>(Lnet/minecraft/client/MinecraftClient;)V
-
-
Method Details
-
tryRequestPending
public void tryRequestPending()Sends the message that was waiting for its request delay to pass, if it is able to.- Mappings:
Namespace Name Mixin selector official aLegj;a()Vintermediary method_44031Lnet/minecraft/class_7479;method_44031()Vnamed tryRequestPendingLnet/minecraft/client/network/ChatPreviewer;tryRequestPending()V
-
tryRequest
Tries to send the request to previewmessage. If the delay has passed, it will send instantly; otherwise, it will setpendingRequestMessagewhich can be requested by callingtryRequestPending().- Mappings:
Namespace Name Mixin selector official aLegj;a(Ljava/lang/String;)Vintermediary method_44274Lnet/minecraft/class_7479;method_44274(Ljava/lang/String;)Vnamed tryRequestLnet/minecraft/client/network/ChatPreviewer;tryRequest(Ljava/lang/String;)V
-
tryRequestInternal
- Mappings:
Namespace Name Mixin selector official cLegj;c(Ljava/lang/String;)Vintermediary method_44276Lnet/minecraft/class_7479;method_44276(Ljava/lang/String;)Vnamed tryRequestInternalLnet/minecraft/client/network/ChatPreviewer;tryRequestInternal(Ljava/lang/String;)V
-
disablePreview
public void disablePreview()SetsshouldRenderPreviewtofalseand clears this previewer.- Mappings:
Namespace Name Mixin selector official bLegj;b()Vintermediary method_44275Lnet/minecraft/class_7479;method_44275()Vnamed disablePreviewLnet/minecraft/client/network/ChatPreviewer;disablePreview()V
-
clear
private void clear()Clears the last response and the requester's state.- Mappings:
Namespace Name Mixin selector official eLegj;e()Vintermediary method_44036Lnet/minecraft/class_7479;method_44036()Vnamed clearLnet/minecraft/client/network/ChatPreviewer;clear()V
-
onResponse
Called when the preview response was received.- Implementation Note:
- This sets the last response if the requester successfully handled the response.
- Mappings:
Namespace Name Mixin selector official aLegj;a(ILrm;)Vintermediary method_44032Lnet/minecraft/class_7479;method_44032(ILnet/minecraft/class_2561;)Vnamed onResponseLnet/minecraft/client/network/ChatPreviewer;onResponse(ILnet/minecraft/text/Text;)V
-
getPreviewText
Returns the preview text (also known as the last response text), ornullif the server responded as such.This does not consume the response.
- Returns:
- the preview text (also known as the last response text), or
nullif the server responded as such - Mappings:
Namespace Name Mixin selector official cLegj;c()Lrm;intermediary method_44038Lnet/minecraft/class_7479;method_44038()Lnet/minecraft/class_2561;named getPreviewTextLnet/minecraft/client/network/ChatPreviewer;getPreviewText()Lnet/minecraft/text/Text;
-
tryConsumeResponse
Returns the consumed response text, ornullif the server responded as such, or if the response could not be consumed.If the response is still valid (i.e. the input has not changed since the query was sent), consuming the response will return the response and clear it. Note that to prevent race condition between the player sending the chat message and the response's arrival, responses can only be consumed after the cooldown (by default, 200L milliseconds) has passed. It is also possible to get the response text without consuming by calling
getPreviewText().- Returns:
- the consumed response text, or
nullif the server responded as such, or if the response could not be consumed - Mappings:
Namespace Name Mixin selector official bLegj;b(Ljava/lang/String;)Lrm;intermediary method_44037Lnet/minecraft/class_7479;method_44037(Ljava/lang/String;)Lnet/minecraft/class_2561;named tryConsumeResponseLnet/minecraft/client/network/ChatPreviewer;tryConsumeResponse(Ljava/lang/String;)Lnet/minecraft/text/Text;
-
shouldRenderPreview
public boolean shouldRenderPreview()Returns whether the preview should be rendered.- Returns:
- whether the preview should be rendered
- Implementation Note:
- A preview should be rendered if there is a response, a pending query, or a query waiting for the response.
- Mappings:
Namespace Name Mixin selector official dLegj;d()Zintermediary method_44040Lnet/minecraft/class_7479;method_44040()Znamed shouldRenderPreviewLnet/minecraft/client/network/ChatPreviewer;shouldRenderPreview()Z
-
normalize
Returns themessagenormalized by trimming it and then normalizing spaces.- Returns:
- the
messagenormalized by trimming it and then normalizing spaces - Mappings:
Namespace Name Mixin selector official dLegj;d(Ljava/lang/String;)Ljava/lang/String;intermediary method_44039Lnet/minecraft/class_7479;method_44039(Ljava/lang/String;)Ljava/lang/String;named normalizeLnet/minecraft/client/network/ChatPreviewer;normalize(Ljava/lang/String;)Ljava/lang/String;
-