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 ehg
intermediary net/minecraft/class_7479
named net/minecraft/client/network/ChatPreviewer
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final record
A response to the preview query. -
Field Summary
Modifier and TypeFieldDescriptionprivate static final long
How long the previewer should wait before consuming the response since the response arrived at the client in milliseconds.private @Nullable ChatPreviewer.Response
The message that is waiting for the previewer to request (i.e.private final ChatPreviewRequester
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns whether the previewer cannot consume the preview (because the preview response hasn't arrived or because of the cooldown).private void
clear()
Clears the last response and the requester's state.void
Clears this previewer.boolean
equalsLastPreviewed
(String text) Returns whether normalizedtext
equals the last previewed text.Returns the preview text (also known as the last response text), ornull
if the server responded as such.(package private) static String
Returns themessage
normalized by trimming it and then normalizing spaces.void
onResponse
(int id, @Nullable Text previewText) Called when the preview response was received.tryConsumeResponse
(String message) Returns the consumed response text, ornull
if the server responded as such, or if the response could not be consumed.void
tryRequest
(String message) Tries to send the request to previewmessage
.private void
tryRequestInternal
(String message) void
Sends 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 a
Lehg;a:J
intermediary field_39328
Lnet/minecraft/class_7479;field_39328:J
named CONSUME_COOLDOWN
Lnet/minecraft/client/network/ChatPreviewer;CONSUME_COOLDOWN:J
-
lastPreviewedMessage
- Mappings:
Namespace Name Mixin selector official b
Lehg;b:Ljava/lang/String;
intermediary field_39430
Lnet/minecraft/class_7479;field_39430:Ljava/lang/String;
named lastPreviewedMessage
Lnet/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 benull
if there is no such query.- Implementation Note:
- If the message is sent instantly, this field is not set.
- Mappings:
Namespace Name Mixin selector official c
Lehg;c:Ljava/lang/String;
intermediary field_39431
Lnet/minecraft/class_7479;field_39431:Ljava/lang/String;
named pendingRequestMessage
Lnet/minecraft/client/network/ChatPreviewer;pendingRequestMessage:Ljava/lang/String;
-
requester
- Mappings:
Namespace Name Mixin selector official d
Lehg;d:Lehf;
intermediary field_39432
Lnet/minecraft/class_7479;field_39432:Lnet/minecraft/class_7516;
named requester
Lnet/minecraft/client/network/ChatPreviewer;requester:Lnet/minecraft/client/network/ChatPreviewRequester;
-
lastResponse
- Mappings:
Namespace Name Mixin selector official e
Lehg;e:Lehg$a;
intermediary field_39334
Lnet/minecraft/class_7479;field_39334:Lnet/minecraft/class_7479$class_7481;
named lastResponse
Lnet/minecraft/client/network/ChatPreviewer;lastResponse:Lnet/minecraft/client/network/ChatPreviewer$Response;
-
-
Constructor Details
-
ChatPreviewer
- Mappings:
Namespace Name Mixin selector official <init>
Lehg;<init>(Lefu;)V
intermediary <init>
Lnet/minecraft/class_7479;<init>(Lnet/minecraft/class_310;)V
named <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 a
Lehg;a()V
intermediary method_44031
Lnet/minecraft/class_7479;method_44031()V
named tryRequestPending
Lnet/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 setpendingRequestMessage
which can be requested by callingtryRequestPending()
.- Mappings:
Namespace Name Mixin selector official a
Lehg;a(Ljava/lang/String;)V
intermediary method_44274
Lnet/minecraft/class_7479;method_44274(Ljava/lang/String;)V
named tryRequest
Lnet/minecraft/client/network/ChatPreviewer;tryRequest(Ljava/lang/String;)V
-
tryRequestInternal
- Mappings:
Namespace Name Mixin selector official d
Lehg;d(Ljava/lang/String;)V
intermediary method_44276
Lnet/minecraft/class_7479;method_44276(Ljava/lang/String;)V
named tryRequestInternal
Lnet/minecraft/client/network/ChatPreviewer;tryRequestInternal(Ljava/lang/String;)V
-
disablePreview
public void disablePreview()Clears this previewer.- Mappings:
Namespace Name Mixin selector official b
Lehg;b()V
intermediary method_44275
Lnet/minecraft/class_7479;method_44275()V
named disablePreview
Lnet/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 e
Lehg;e()V
intermediary method_44036
Lnet/minecraft/class_7479;method_44036()V
named clear
Lnet/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 a
Lehg;a(ILrq;)V
intermediary method_44032
Lnet/minecraft/class_7479;method_44032(ILnet/minecraft/class_2561;)V
named onResponse
Lnet/minecraft/client/network/ChatPreviewer;onResponse(ILnet/minecraft/text/Text;)V
-
cannotConsumePreview
public boolean cannotConsumePreview()Returns whether the previewer cannot consume the preview (because the preview response hasn't arrived or because of the cooldown).- Returns:
- whether the previewer cannot consume the preview (because the preview response hasn't arrived or because of the cooldown)
- Mappings:
Namespace Name Mixin selector official c
Lehg;c()Z
intermediary method_44928
Lnet/minecraft/class_7479;method_44928()Z
named cannotConsumePreview
Lnet/minecraft/client/network/ChatPreviewer;cannotConsumePreview()Z
-
equalsLastPreviewed
Returns whether normalizedtext
equals the last previewed text.- Returns:
- whether normalized
text
equals the last previewed text - Mappings:
Namespace Name Mixin selector official b
Lehg;b(Ljava/lang/String;)Z
intermediary method_44927
Lnet/minecraft/class_7479;method_44927(Ljava/lang/String;)Z
named equalsLastPreviewed
Lnet/minecraft/client/network/ChatPreviewer;equalsLastPreviewed(Ljava/lang/String;)Z
-
getPreviewText
Returns the preview text (also known as the last response text), ornull
if the server responded as such.This does not consume the response.
- Returns:
- the preview text (also known as the last response text), or
null
if the server responded as such - Mappings:
Namespace Name Mixin selector official d
Lehg;d()Lehg$a;
intermediary method_44038
Lnet/minecraft/class_7479;method_44038()Lnet/minecraft/class_7479$class_7481;
named getPreviewText
Lnet/minecraft/client/network/ChatPreviewer;getPreviewText()Lnet/minecraft/client/network/ChatPreviewer$Response;
-
tryConsumeResponse
Returns the consumed response text, ornull
if 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
null
if the server responded as such, or if the response could not be consumed - Mappings:
Namespace Name Mixin selector official c
Lehg;c(Ljava/lang/String;)Lehg$a;
intermediary method_44037
Lnet/minecraft/class_7479;method_44037(Ljava/lang/String;)Lnet/minecraft/class_7479$class_7481;
named tryConsumeResponse
Lnet/minecraft/client/network/ChatPreviewer;tryConsumeResponse(Ljava/lang/String;)Lnet/minecraft/client/network/ChatPreviewer$Response;
-
normalize
Returns themessage
normalized by trimming it and then normalizing spaces.- Returns:
- the
message
normalized by trimming it and then normalizing spaces - Mappings:
Namespace Name Mixin selector official e
Lehg;e(Ljava/lang/String;)Ljava/lang/String;
intermediary method_44039
Lnet/minecraft/class_7479;method_44039(Ljava/lang/String;)Ljava/lang/String;
named normalize
Lnet/minecraft/client/network/ChatPreviewer;normalize(Ljava/lang/String;)Ljava/lang/String;
-