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 ehgintermediary net/minecraft/class_7479named net/minecraft/client/network/ChatPreviewer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic 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 ChatPreviewRequester -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether the previewer cannot consume the preview (because the preview response hasn't arrived or because of the cooldown).private voidclear()Clears the last response and the requester's state.voidClears this previewer.booleanequalsLastPreviewed(String text) Returns whether normalizedtextequals the last previewed text.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 previewText) Called when the preview response was received.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 aLehg;a:Jintermediary field_39328Lnet/minecraft/class_7479;field_39328:Jnamed CONSUME_COOLDOWNLnet/minecraft/client/network/ChatPreviewer;CONSUME_COOLDOWN:J
-
lastPreviewedMessage
- Mappings:
Namespace Name Mixin selector official bLehg;b: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 cLehg;c: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 dLehg;d:Lehf;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 eLehg;e:Lehg$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>Lehg;<init>(Lefu;)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 aLehg;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 aLehg;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 dLehg;d(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()Clears this previewer.- Mappings:
Namespace Name Mixin selector official bLehg;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 eLehg;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 aLehg;a(ILrq;)Vintermediary method_44032Lnet/minecraft/class_7479;method_44032(ILnet/minecraft/class_2561;)Vnamed onResponseLnet/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 cLehg;c()Zintermediary method_44928Lnet/minecraft/class_7479;method_44928()Znamed cannotConsumePreviewLnet/minecraft/client/network/ChatPreviewer;cannotConsumePreview()Z
-
equalsLastPreviewed
Returns whether normalizedtextequals the last previewed text.- Returns:
- whether normalized
textequals the last previewed text - Mappings:
Namespace Name Mixin selector official bLehg;b(Ljava/lang/String;)Zintermediary method_44927Lnet/minecraft/class_7479;method_44927(Ljava/lang/String;)Znamed equalsLastPreviewedLnet/minecraft/client/network/ChatPreviewer;equalsLastPreviewed(Ljava/lang/String;)Z
-
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 dLehg;d()Lehg$a;intermediary method_44038Lnet/minecraft/class_7479;method_44038()Lnet/minecraft/class_7479$class_7481;named getPreviewTextLnet/minecraft/client/network/ChatPreviewer;getPreviewText()Lnet/minecraft/client/network/ChatPreviewer$Response;
-
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 cLehg;c(Ljava/lang/String;)Lehg$a;intermediary method_44037Lnet/minecraft/class_7479;method_44037(Ljava/lang/String;)Lnet/minecraft/class_7479$class_7481;named tryConsumeResponseLnet/minecraft/client/network/ChatPreviewer;tryConsumeResponse(Ljava/lang/String;)Lnet/minecraft/client/network/ChatPreviewer$Response;
-
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 eLehg;e(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;
-